Re: Postgres and gdb: p debug_query_string RE: Query

Started by Garo Hussenjianabout 23 years ago1 messagesgeneral
Jump to latest
#1Garo Hussenjian
garo@xapnet.com

Marco,

Instead of 'p debug_query_string'...

Use 'x/s debug_query_string' which should give the actual query!

Regards,
Garo.

Hello Garo,

I'm sorry to bother you, but after searching on Google, I found that you have
had the exact same problem as I currently have. Unfortunately, the answer to
the problem isn't listed on Google.

The problem is when attaching gdb to a postgres process, after giving the 'p
debug_query_string' command, it doesn't show the query. How did you fix this
problem?

$ gdb /path/to/postgres-executable
gdb> attach PID-OF-PROCESS
gdb> p debug_query_string
gdb> quit

Thanks, Tom.

Here's what I got going...

semerjia% gdb usr/local/pgsql/bin/postmaster
GNU gdb 4.18
< MORE GDB STUFF... >
(gdb) attach 43179
Attaching to program: /usr/home/semerjia/usr/local/pgsql/bin/postmaster,
process 43179
Reading symbols from /usr/lib/libz.so.2...done.
Reading symbols from /usr/lib/libcrypt.so.2...done.
Reading symbols from /usr/lib/libm.so.2...done.
Reading symbols from /usr/lib/libutil.so.3...done.
Reading symbols from /usr/lib/libreadline.so.4...done.
Reading symbols from /usr/lib/libc.so.4...done.
Reading symbols from /usr/lib/libncurses.so.5...done.
Reading symbols from /usr/libexec/ld-elf.so.1...done.
0x28346088 in read () from /usr/lib/libc.so.4
(gdb) p debug_query_string
$1 = 138514480
(gdb)

This should work unless you are running a stripped backend executable.
(On many systems, the "file" command can tell you whether an executable
has been stripped of debug symbols.)

I can't tell if this worked... What is '$1 = 138514480'. After running gdb,
the process STAT for 42179 changed from R to T so I kill'ed it...

Kind regards,
Marco Kraaijeveld

=-=-==-=-=-==

Xapnet Internet Solutions
1501 Powell St., Suite N
Emeryville, CA 94608

Tel - (510) 655-9771
Fax - (510) 655-9775
Web - http://www.xapnet.com