Home > Archive > PostgreSQL Discussion > August 2005 > Using gdb to obtain statement









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Using gdb to obtain statement
Markus Wollny

2005-08-24, 11:24 am

Hello!

As pg_stat_activity.current_query truncates statements to about 255
characters, I've tinkered a bit with gdb, as suggested by Tom Lane a
little while ago. But when I attach to the backend in question, the only
output I get from p debug_query_string is some number, for example:

mysrv:/var/log # gdb /opt/pgsql/bin/postgres 1485
GNU gdb 5.2.1
Copyright 2002 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 "i586-suse-linux"...
Attaching to program: /opt/pgsql/bin/postgres, process 1485
Reading symbols from /lib/libz.so.1...done.
Loaded symbols for /lib/libz.so.1
Reading symbols from /lib/libreadline.so.4...done.
Loaded symbols for /lib/libreadline.so.4
Reading symbols from /lib/libcrypt.so.1...done.
Loaded symbols for /lib/libcrypt.so.1
Reading symbols from /lib/libresolv.so.2...done.
Loaded symbols for /lib/libresolv.so.2
Reading symbols from /lib/libnsl.so.1...done.
Loaded symbols for /lib/libnsl.so.1
Reading symbols from /lib/libdl.so.2...done.
Loaded symbols for /lib/libdl.so.2
Reading symbols from /lib/i686/libm.so.6...done.
Loaded symbols for /lib/i686/libm.so.6
Reading symbols from /lib/i686/libc.so.6...done.
Loaded symbols for /lib/i686/libc.so.6
Reading symbols from /lib/libncurses.so.5...done.
Loaded symbols for /lib/libncurses.so.5
Reading symbols from /lib/ld-linux.so.2...done.
Loaded symbols for /lib/ld-linux.so.2
Reading symbols from /usr/lib/gconv/ISO8859-1.so...done.
Loaded symbols for /usr/lib/gconv/ISO8859-1.so
Reading symbols from /lib/libnss_files.so.2...done.
Loaded symbols for /lib/libnss_files.so.2
0x40198cd4 in read () from /lib/i686/libc.so.6
(gdb) p debug_query_string
$1 = 137763608

What am I doing wrong?

Kind regards

Markus

---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faq

Andreas Seltenreich

2005-08-24, 1:25 pm

Markus Wollny schrob:

> 0x40198cd4 in read () from /lib/i686/libc.so.6
> (gdb) p debug_query_string
> $1 = 137763608
>
> What am I doing wrong?


You are looking at the string's pointer. You could display it with
e.g.

printf "%s\n", debug_query_string

HTH
Andreas

---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend

Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2008 droptable.com