Lists: | pgsql-hackers |
---|
From: | HuangQi <huangqiyx(at)gmail(dot)com> |
---|---|
To: | pgsql-hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | gdb with postgres |
Date: | 2011-06-06 07:43:04 |
Message-ID: | BANLkTi=ih7K9q7osYwtTBw+VKY51tjdJ_g@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
Hi,
I was using gdb to debug postgres. In order to debug the backend of
running query, I start postgres first and use "select * from
pg_backend_pid()" to ask for backend pid. Then I start gdb in another bash
window with "gdb postgres" and attach the pid obtained above and set the
breakpoint. Then I run the query from the first window. However, the
debugging precess which is shown below is not going to the breakpoint. I
tried many different breakpoints, but it always start from the 305
client_read_ended().
GNU gdb 6.6
Copyright (C) 2006 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain
conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "sparc-sun-solaris2.10"...
(gdb) b qp_add_paths_to_joinrel
Breakpoint 1 at 0x1a6744: file joinpath.c, line 67.
(gdb) attach 23903
Attaching to program `/usrlocal/pgsql/bin/postgres', process 23903
Retry #1:
Retry #2:
Retry #3:
Retry #4:
[New LWP 1]
0xff0cbaa4 in _rt_boot () from /usr/lib/ld.so.1
(gdb) n
Single stepping until exit from function _rt_boot,
which has no line number information.
secure_read (port=0x4a7760, ptr=0x455948, len=8192) at be-secure.c:305
305 client_read_ended();
(gdb) n
pq_recvbuf () at pqcomm.c:767
767 if (r < 0)
(gdb) n
769 if (errno == EINTR)
(gdb) n
782 if (r == 0)
(gdb) n
788 return EOF;
(gdb) n
791 PqRecvLength += r;
(gdb)
Any one know what is going wrong? BTW, as you can see, the system is
solaris.
--
Best Regards
Huang Qi Victor
From: | Pavan Deolasee <pavan(dot)deolasee(at)gmail(dot)com> |
---|---|
To: | HuangQi <huangqiyx(at)gmail(dot)com> |
Cc: | pgsql-hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: gdb with postgres |
Date: | 2011-06-06 07:46:35 |
Message-ID: | BANLkTin7tK5G5X_-caZzR+tXZhgn2s3Axw@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
On Mon, Jun 6, 2011 at 1:13 PM, HuangQi <huangqiyx(at)gmail(dot)com> wrote:
> Hi,
> I was using gdb to debug postgres. In order to debug the backend of
> running query, I start postgres first and use "select * from
> pg_backend_pid()" to ask for backend pid. Then I start gdb in another bash
> window with "gdb postgres" and attach the pid obtained above and set the
> breakpoint. Then I run the query from the first window. However, the
> debugging precess which is shown below is not going to the breakpoint. I
> tried many different breakpoints, but it always start from the 305
> client_read_ended().
>
Please compile with -O0 -g flags to see all the debug symbols.
CFLAGS="-O0 -g" ./configure --enable-debug
Thanks,
Pavan
--
Pavan Deolasee
EnterpriseDB http://www.enterprisedb.com
From: | HuangQi <huangqiyx(at)gmail(dot)com> |
---|---|
To: | Pavan Deolasee <pavan(dot)deolasee(at)gmail(dot)com> |
Cc: | pgsql-hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: gdb with postgres |
Date: | 2011-06-06 07:57:29 |
Message-ID: | BANLkTi=qD4SMP_OeMOqfjh8E9e9XHXk8sg@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
Sorry, but recompile with this flag still doesn't work.
On 6 June 2011 15:46, Pavan Deolasee <pavan(dot)deolasee(at)gmail(dot)com> wrote:
> On Mon, Jun 6, 2011 at 1:13 PM, HuangQi <huangqiyx(at)gmail(dot)com> wrote:
> > Hi,
> > I was using gdb to debug postgres. In order to debug the backend of
> > running query, I start postgres first and use "select * from
> > pg_backend_pid()" to ask for backend pid. Then I start gdb in another
> bash
> > window with "gdb postgres" and attach the pid obtained above and set the
> > breakpoint. Then I run the query from the first window. However, the
> > debugging precess which is shown below is not going to the breakpoint. I
> > tried many different breakpoints, but it always start from the 305
> > client_read_ended().
> >
>
> Please compile with -O0 -g flags to see all the debug symbols.
>
> CFLAGS="-O0 -g" ./configure --enable-debug
>
> Thanks,
> Pavan
>
> --
> Pavan Deolasee
> EnterpriseDB http://www.enterprisedb.com
>
--
Best Regards
Huang Qi Victor
From: | Robert Haas <robertmhaas(at)gmail(dot)com> |
---|---|
To: | HuangQi <huangqiyx(at)gmail(dot)com> |
Cc: | pgsql-hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: gdb with postgres |
Date: | 2011-06-06 13:44:50 |
Message-ID: | BANLkTin0cGarhdsTpnrdms7R4CYCk_RcOw@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
On Mon, Jun 6, 2011 at 3:43 AM, HuangQi <huangqiyx(at)gmail(dot)com> wrote:
> Hi,
> I was using gdb to debug postgres. In order to debug the backend of
> running query, I start postgres first and use "select * from
> pg_backend_pid()" to ask for backend pid. Then I start gdb in another bash
> window with "gdb postgres" and attach the pid obtained above and set the
> breakpoint. Then I run the query from the first window. However, the
> debugging precess which is shown below is not going to the breakpoint. I
> tried many different breakpoints, but it always start from the 305
> client_read_ended().
>
> GNU gdb 6.6
> Copyright (C) 2006 Free Software Foundation, Inc.
> GDB is free software, covered by the GNU General Public License, and you are
> welcome to change it and/or distribute copies of it under certain
> conditions.
> Type "show copying" to see the conditions.
> There is absolutely no warranty for GDB. Type "show warranty" for details.
> This GDB was configured as "sparc-sun-solaris2.10"...
> (gdb) b qp_add_paths_to_joinrel
> Breakpoint 1 at 0x1a6744: file joinpath.c, line 67.
> (gdb) attach 23903
> Attaching to program `/usrlocal/pgsql/bin/postgres', process 23903
> Retry #1:
> Retry #2:
> Retry #3:
> Retry #4:
> [New LWP 1]
> 0xff0cbaa4 in _rt_boot () from /usr/lib/ld.so.1
> (gdb) n
> Single stepping until exit from function _rt_boot,
> which has no line number information.
> secure_read (port=0x4a7760, ptr=0x455948, len=8192) at be-secure.c:305
> 305 client_read_ended();
> (gdb) n
> pq_recvbuf () at pqcomm.c:767
> 767 if (r < 0)
> (gdb) n
> 769 if (errno == EINTR)
> (gdb) n
> 782 if (r == 0)
> (gdb) n
> 788 return EOF;
> (gdb) n
> 791 PqRecvLength += r;
> (gdb)
> Any one know what is going wrong? BTW, as you can see, the system is
> solaris.
Perhaps you want "c" for "continue" rather than "n" for "next".
--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
From: | HuangQi <huangqiyx(at)gmail(dot)com> |
---|---|
To: | Robert Haas <robertmhaas(at)gmail(dot)com> |
Cc: | pgsql-hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: gdb with postgres |
Date: | 2011-06-06 13:47:06 |
Message-ID: | BANLkTintv+e8j5qk4XjU8eMNngcp2JWyFQ@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
If I enter c, gdb will directly finish executing this process and current
query will finish. Furthermore, if I enter next query, gdb will not debug it
and stay in continue status.
On 6 June 2011 21:44, Robert Haas <robertmhaas(at)gmail(dot)com> wrote:
> On Mon, Jun 6, 2011 at 3:43 AM, HuangQi <huangqiyx(at)gmail(dot)com> wrote:
> > Hi,
> > I was using gdb to debug postgres. In order to debug the backend of
> > running query, I start postgres first and use "select * from
> > pg_backend_pid()" to ask for backend pid. Then I start gdb in another
> bash
> > window with "gdb postgres" and attach the pid obtained above and set the
> > breakpoint. Then I run the query from the first window. However, the
> > debugging precess which is shown below is not going to the breakpoint. I
> > tried many different breakpoints, but it always start from the 305
> > client_read_ended().
> >
> > GNU gdb 6.6
> > Copyright (C) 2006 Free Software Foundation, Inc.
> > GDB is free software, covered by the GNU General Public License, and you
> are
> > welcome to change it and/or distribute copies of it under certain
> > conditions.
> > Type "show copying" to see the conditions.
> > There is absolutely no warranty for GDB. Type "show warranty" for
> details.
> > This GDB was configured as "sparc-sun-solaris2.10"...
> > (gdb) b qp_add_paths_to_joinrel
> > Breakpoint 1 at 0x1a6744: file joinpath.c, line 67.
> > (gdb) attach 23903
> > Attaching to program `/usrlocal/pgsql/bin/postgres', process 23903
> > Retry #1:
> > Retry #2:
> > Retry #3:
> > Retry #4:
> > [New LWP 1]
> > 0xff0cbaa4 in _rt_boot () from /usr/lib/ld.so.1
> > (gdb) n
> > Single stepping until exit from function _rt_boot,
> > which has no line number information.
> > secure_read (port=0x4a7760, ptr=0x455948, len=8192) at be-secure.c:305
> > 305 client_read_ended();
> > (gdb) n
> > pq_recvbuf () at pqcomm.c:767
> > 767 if (r < 0)
> > (gdb) n
> > 769 if (errno == EINTR)
> > (gdb) n
> > 782 if (r == 0)
> > (gdb) n
> > 788 return EOF;
> > (gdb) n
> > 791 PqRecvLength += r;
> > (gdb)
> > Any one know what is going wrong? BTW, as you can see, the system is
> > solaris.
>
> Perhaps you want "c" for "continue" rather than "n" for "next".
>
> --
> Robert Haas
> EnterpriseDB: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>
--
Best Regards
Huang Qi Victor
From: | Robert Haas <robertmhaas(at)gmail(dot)com> |
---|---|
To: | HuangQi <huangqiyx(at)gmail(dot)com> |
Cc: | pgsql-hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: gdb with postgres |
Date: | 2011-06-06 13:55:15 |
Message-ID: | BANLkTinuZf_dyUue+G2XwJ9yZY1cerxasw@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
On Mon, Jun 6, 2011 at 9:47 AM, HuangQi <huangqiyx(at)gmail(dot)com> wrote:
> If I enter c, gdb will directly finish executing this process and current
> query will finish. Furthermore, if I enter next query, gdb will not debug it
> and stay in continue status.
Hmm, that must mean your breakpoint isn't properly set.
Instead of doing gdb postgres and then using attach, try just doing
gdb -p PIDNAME, then set your breakpoint, then continue. That's how
I've always done it, anyway...
--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
From: | "Kevin Grittner" <Kevin(dot)Grittner(at)wicourts(dot)gov> |
---|---|
To: | "HuangQi" <huangqiyx(at)gmail(dot)com> |
Cc: | "Robert Haas" <robertmhaas(at)gmail(dot)com>, "pgsql-hackers" <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: gdb with postgres |
Date: | 2011-06-06 13:57:36 |
Message-ID: | 4DEC9680020000250003E1B9@gw.wicourts.gov |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
HuangQi <huangqiyx(at)gmail(dot)com> wrote:
>>> (gdb) b qp_add_paths_to_joinrel
>>> Breakpoint 1 at 0x1a6744: file joinpath.c, line 67.
>>> (gdb) attach 23903
> If I enter c, gdb will directly finish executing this process and
> current query will finish.
Are you absolutely sure that running your query will result in a
call to this function?
-Kevin
From: | HuangQi <huangqiyx(at)gmail(dot)com> |
---|---|
To: | Kevin Grittner <Kevin(dot)Grittner(at)wicourts(dot)gov> |
Cc: | Robert Haas <robertmhaas(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: gdb with postgres |
Date: | 2011-06-07 06:53:13 |
Message-ID: | BANLkTimXJSUX9sAS=J9app3OcVMaarBmEg@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
On 6 June 2011 21:57, Kevin Grittner <Kevin(dot)Grittner(at)wicourts(dot)gov> wrote:
> HuangQi <huangqiyx(at)gmail(dot)com> wrote:
>
> >>> (gdb) b qp_add_paths_to_joinrel
> >>> Breakpoint 1 at 0x1a6744: file joinpath.c, line 67.
> >>> (gdb) attach 23903
>
> > If I enter c, gdb will directly finish executing this process and
> > current query will finish.
>
> Are you absolutely sure that running your query will result in a
> call to this function?
>
> -Kevin
>
Thanks guys for your idea. I found the solution. Because after made some
change in postgres and make them, I didn't stop the server first. Now I stop
it and start after reinstall, then using gdb is just fine. Thanks for your
ideas.
--
Best Regards
Huang Qi Victor