使用VS 2012调试PostgrelSQL
欢迎转载,转载请标明出处:http://blog.****.net/notbaron/article/details/51100550
1 其他相关工具
l Perl安装
http://www.activestate.com/activeperl/downloads
l bsion、diff、gettext
http://gnuwin32.sourceforge.net/packages.html
l flex
http://www.postgresql.org/ftp/misc/winflex/
具体安装,蛤蟆已有笔记,大家查看即可。
l PostgrelSQl
http://www.postgresql.org/ftp/source/
l VS 2012
这个大家自己网上找个可用的版本吧,然后把安装路径加到PATH变量,
C:\Program Files (x86)\Microsoft VisualStudio 11.0\VC\bin
2 生成VS解决方案
到路径 ..\postgresql-9.5.2\src\tools\msvc
perl.exemkvcbuild.pl
Detected hardware platform: Win32
Generating win32ver.rc for src/backend
Generating win32ver.rc for src/timezone
Generating win32ver.rc forsrc/backend/snowball
Generating win32ver.rc forsrc/pl/plpgsql/src
Generating win32ver.rc for src/backend/replication/libpqwalreceiver
Generating win32ver.rc forsrc/interfaces/ecpg/pgtypeslib
Generating win32ver.rc forsrc/interfaces/ecpg/ecpglib
Generating win32ver.rc forsrc/interfaces/ecpg/compatlib
Generating win32ver.rc forsrc/interfaces/ecpg/preproc
Generating win32ver.rc forsrc/interfaces/ecpg/test
Generating win32ver.rc forsrc/test/isolation
Generating win32ver.rc for src/bin/initdb
Generating win32ver.rc for src/bin/pgbench
Files src/bin/pgbench/exprscan.l
Files src/bin/pgbench/exprparse.y
Generating win32ver.rc forsrc/bin/pg_archivecleanup
Generating win32ver.rc forsrc/bin/pg_config
Generating win32ver.rc forsrc/bin/pg_controldata
Generating win32ver.rc for src/bin/pg_ctl
Generating win32ver.rc forsrc/bin/pg_resetxlog
Generating win32ver.rc forsrc/bin/pg_test_fsync
Generating win32ver.rc forsrc/bin/pg_test_timing
Generating win32ver.rc forsrc/bin/pg_upgrade
Generating win32ver.rc for src/bin/psql
Files src/bin/psql/psqlscan.l
Generating win32ver.rc forsrc/bin/pg_basebackup
Generating win32ver.rc forsrc/bin/pg_rewind
Generating win32ver.rc for src/bin/pgevent
Generating win32ver.rc for src/bin/pg_dump
Generating win32ver.rc for contrib/pgcrypto
Generating win32ver.rc forcontrib/adminpack
Generating win32ver.rc forcontrib/auth_delay
Generating win32ver.rc forcontrib/auto_explain
Generating win32ver.rc forcontrib/btree_gin
Generating win32ver.rc forcontrib/btree_gist
Generating win32ver.rc for contrib/chkpass
Generating win32ver.rc for contrib/citext
Generating win32ver.rc for contrib/cube
Files contrib/cube/cubescan.l
Files contrib/cube/cubeparse.y
Generating win32ver.rc for contrib/dblink
Generating win32ver.rc for contrib/dict_int
Generating win32ver.rc forcontrib/dict_xsyn
Generating win32ver.rc forcontrib/earthdistance
Generating win32ver.rc for contrib/file_fdw
Generating win32ver.rc forcontrib/fuzzystrmatch
Generating win32ver.rc for contrib/hstore
Generating win32ver.rc for contrib/intarray
Generating win32ver.rc for contrib/isn
Generating win32ver.rc for contrib/lo
Generating win32ver.rc for contrib/ltree
Generating win32ver.rc for contrib/oid2name
Generating win32ver.rc forcontrib/pageinspect
Generating win32ver.rc forcontrib/passwordcheck
Generating win32ver.rc forcontrib/pgrowlocks
Generating win32ver.rc for contrib/pgstattuple
Generating win32ver.rc forcontrib/pg_buffercache
Generating win32ver.rc forcontrib/pg_freespacemap
Generating win32ver.rc forcontrib/pg_prewarm
Generating win32ver.rc forcontrib/pg_standby
Generating win32ver.rc for contrib/pg_stat_statements
Generating win32ver.rc for contrib/pg_trgm
Generating win32ver.rc forcontrib/postgres_fdw
Generating win32ver.rc for contrib/seg
Files contrib/seg/segscan.l
Files contrib/seg/segparse.y
Generating win32ver.rc for contrib/spi
Generating win32ver.rc forcontrib/tablefunc
Generating win32ver.rc for contrib/tcn
Generating win32ver.rc forcontrib/test_decoding
Generating win32ver.rc for contrib/tsearch2
Generating win32ver.rc forcontrib/tsm_system_rows
Generating win32ver.rc forcontrib/tsm_system_time
Generating win32ver.rc for contrib/unaccent
Generating win32ver.rc for contrib/vacuumlo
Generating win32ver.rc forsrc/test/modules/dummy_seclabel
Generating win32ver.rc forsrc/test/modules/test_ddl_deparse
Generating win32ver.rc forsrc/test/modules/test_parser
Generating win32ver.rc forsrc/test/modules/test_rls_hooks
Generating win32ver.rc forsrc/test/modules/test_shm_mq
Generating win32ver.rc forsrc/test/modules/worker_spi
Generating win32ver.rc forsrc/backend/utils/mb/conversion_procs/ascii_and_mic
Generating win32ver.rc forsrc/backend/utils/mb/conversion_procs/cyrillic_and_mi
c
Generating win32ver.rc forsrc/backend/utils/mb/conversion_procs/euc_cn_and_mic
Generating win32ver.rc forsrc/backend/utils/mb/conversion_procs/euc_jp_and_sjis
Generating win32ver.rc forsrc/backend/utils/mb/conversion_procs/euc_kr_and_mic
Generating win32ver.rc forsrc/backend/utils/mb/conversion_procs/euc_tw_and_big5
Generating win32ver.rc forsrc/backend/utils/mb/conversion_procs/latin2_and_win1
250
Generating win32ver.rc forsrc/backend/utils/mb/conversion_procs/latin_and_mic
Generating win32ver.rc forsrc/backend/utils/mb/conversion_procs/utf8_and_ascii
Generating win32ver.rc forsrc/backend/utils/mb/conversion_procs/utf8_and_big5
Generating win32ver.rc for src/backend/utils/mb/conversion_procs/utf8_and_cyrill
ic
Generating win32ver.rc forsrc/backend/utils/mb/conversion_procs/utf8_and_euc_cn
Generating win32ver.rc forsrc/backend/utils/mb/conversion_procs/utf8_and_euc_jp
Generating win32ver.rc for src/backend/utils/mb/conversion_procs/utf8_and_euc_kr
Generating win32ver.rc forsrc/backend/utils/mb/conversion_procs/utf8_and_euc_tw
Generating win32ver.rc forsrc/backend/utils/mb/conversion_procs/utf8_and_gb1803
0
Generating win32ver.rc forsrc/backend/utils/mb/conversion_procs/utf8_and_gbk
Generating win32ver.rc forsrc/backend/utils/mb/conversion_procs/utf8_and_iso885
9
Generating win32ver.rc forsrc/backend/utils/mb/conversion_procs/utf8_and_iso885
9_1
Generating win32ver.rc for src/backend/utils/mb/conversion_procs/utf8_and_johab
Generating win32ver.rc forsrc/backend/utils/mb/conversion_procs/utf8_and_sjis
Generating win32ver.rc forsrc/backend/utils/mb/conversion_procs/utf8_and_win
Generating win32ver.rc forsrc/backend/utils/mb/conversion_procs/utf8_and_uhc
Generating win32ver.rc forsrc/backend/utils/mb/conversion_procs/utf8_and_euc200
4
Generating win32ver.rc forsrc/backend/utils/mb/conversion_procs/utf8_and_sjis20
04
Generating win32ver.rc forsrc/backend/utils/mb/conversion_procs/euc2004_sjis200
4
Generating win32ver.rc for src/bin/scripts
Generating win32ver.rc for src/test/regress
Generating win32ver.rc forsrc/bin/pg_xlogdump
Copying pg_config_os.h...
Generating pg_config.h...
Copying pg_config_ext.h...
Generating src/interfaces/ecpg/ecpglib/ecpglib.def...
Generatingsrc/interfaces/ecpg/compatlib/compatlib.def...
Generatingsrc/interfaces/ecpg/pgtypeslib/pgtypeslib.def...
Generating probes.h...
Generating errcodes.h...
Generating libpq.rc...
Generating ecpg_config.h...
Generating pg_config_paths.h...
在源码包的上层目录上生成VS解决方案
用VS打开后,编译;
也可以直接使用命令编译,执行buildDEBUG命令;
如果需要某些特性,如openssl支持,新建config.pl,然后加入$config->{openssl} ='openssl安装路径',然后再执行
3 调试
使用VS打开解决方案,右键单击要调试的程序,例如initdb,选择属性->配置属性->调试,输入调试参数和工作目录,例如参数为-D,工作目录为d: \pgsqldata,最后确定;
右键点击要initdb->调试->进入并单步执行新实例,这样就可以调试initdb了。
4 错误
4.1 生成解决方案错误
Unable to determine Visual Studio version:The nmake version could not be determ ined. at Mkvcbuild.pm line 81.
答:注:2012版本的vsVersion为11.00,2010版本的vsVersion为10.00,而2008版本的vsVersion为9.00
将:
my $vsVersion =DetermineVisualStudioVersion();
改成
my $vsVersion = '11.00';
修改config.pl:
注释Config.pl文件中的如下内容:
#ldap => 1, # --with-ldap
#extraver => undef, # --with-extra-version=<string>
#nls => undef, # --enable-nls=<path>
#tap_tests => undef, #--enable-tap-tests
#tcl => undef, # --with-tls=<path>
#perl => undef, # --with-perl
#python => undef, # --with-python=<path>
#openssl => undef, # --with-openssl=<path>
#uuid => undef, #--with-ossp-uuid
#xml => undef, # --with-libxml=<path>
#xslt => undef, # --with-libxslt=<path>
#iconv => undef, # (not in configure, path to iconv)
#zlib => undef # --with-zlib=<path>
4.2 编译错误
src/port/dirent.c : fatal errorC1902:程序数据库管理器不匹配;请检查安装
答:将mspdb110.dll文件从路径
C:\Program Files (x86)\Microsoft VisualStudio 11.0\VC\bin
删除。
该文件当时是为了使用cl.exe从下面路径复制过来的。
C:\Program Files (x86)\Microsoft VisualStudio 11.0\Common7\IDE
5 其他相关文档
http://wiki.postgresql.org/wiki/PgkernalDebugEnvironmentSetup
再分享一下我老师大神的人工智能教程吧。零基础!通俗易懂!风趣幽默!还带黄段子!希望你也加入到我们人工智能的队伍中来!http://www.captainbed.net