美文网首页
postgresql debug

postgresql debug

作者: perryn | 来源:发表于2018-05-16 19:48 被阅读25次
    • postgresql architecture
    simpe-architecture.jpg
    • postgresql build
    //postgresql can't setting datadir during build
    [postgres@CentOS7 postgresql-10.3]$ ./configure --prefix=/postgres/postgresql103  --enable-nls=zh_CN.UTF-8 --enable-debug 'CFLAGS=-O0 -g' --enable-thread-safety --enable-dtrace --enable-profiling 
    [postgres@CentOS7 postgresql-10.3]$make -j4 && make install
     [postgres@CentOS7 postgresql-10.3] ./pg_ctl -D /postgres/postgresql103/data -l logfile start
    
    • postgresql debug demo
    //main postion:src/backend/main
    [postgres@CentOS7 bin]$ gdb ./postgres  
    (gdb) set args -p 8788  -D /postgres/postgresql103/data/
    (gdb) br main  //core main
    Breakpoint 1 at 0x6d804b: file main.c, line 62.
    (gdb) br PostmasterMain  //entery main function
    Breakpoint 2 at 0x791da3: file postmaster.c, line 579.
    (gdb) br ServerLoop  //listen sock util client connected
    Breakpoint 3 at 0x7935c3: file postmaster.c, line 1678.
    (gdb) br ConnCreate //init a connection
    Breakpoint 4 at 0x7949a7: file postmaster.c, line 2435.
    (gdb) br BackendStartup //fork process for a conenction
    Breakpoint 5 at 0x796f33: file postmaster.c, line 4018.
    (gdb) br PostgresMain
    Breakpoint 8 at 0x826b0d: file postgres.c, line 3587.
    
    • break info
    (gdb) info break
    Num     Type           Disp Enb Address            What
    1       breakpoint     keep y   0x00000000006d804b in main at main.c:62
            breakpoint already hit 1 time
    2       breakpoint     keep y   0x0000000000791da3 in PostmasterMain at postmaster.c:579
            breakpoint already hit 1 time
    3       breakpoint     keep y   0x00000000007935c3 in ServerLoop at postmaster.c:1678
            breakpoint already hit 1 time
    4       breakpoint     keep y   0x00000000007949a7 in ConnCreate at postmaster.c:2435
            breakpoint already hit 3 times
    5       breakpoint     keep y   0x0000000000796f33 in BackendStartup at postmaster.c:4018
            breakpoint already hit 3 times
    6       breakpoint     keep y   0x00000000007948eb in canAcceptConnections at postmaster.c:2377
            breakpoint already hit 5 times
    7       breakpoint     keep y   0x00000000007886d1 in fork_process at fork_process.c:47
            breakpoint already hit 5 times
    8       breakpoint     keep y   0x0000000000826b0d in PostgresMain at postgres.c:3587
    

    相关文章

      网友评论

          本文标题:postgresql debug

          本文链接:https://www.haomeiwen.com/subject/vuemdftx.html