Обсуждение: Using gdb to obtain statement

Поиск
Список
Период
Сортировка

Using gdb to obtain statement

От
"Markus Wollny"
Дата:
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

Re: Using gdb to obtain statement

От
Andreas Seltenreich
Дата:
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