python interface gdb.execute() to_string is useless

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

python interface gdb.execute() to_string is useless

Emiliano Testa

I'm using the gdb APIs to implement a command and I want to control when
the output of a certain command is sent to the console.

To this end I'm using

s = gdb.execute(cmd, to_string=True)

unfortunately it doesn't seem to do what is says it would:

I can see s is not None when to_string=True BUT it doesn't contain the
output that it should. It went to the console instead.

I think this is a bug.

Many thanks


The output I get (gdb version is "GNU gdb (Ubuntu 8.1-0ubuntu3.2)"):

(gdb) python
 >print ("Before")
 >s = gdb.execute("continue", to_string=True)
 >print ("After")
 >print (s)
loop_then_segv.c: i=0
loop_then_segv.c: i=1
loop_then_segv.c: i=2
loop_then_segv.c: i=3
loop_then_segv.c: i=4
loop_then_segv.c: i=5
loop_then_segv.c: i=6
loop_then_segv.c: i=7
loop_then_segv.c: i=8
loop_then_segv.c: i=9
causing deliberate segv pid=11290.

Program received signal SIGSEGV, Segmentation fault.
0x0804855c in main () at tests/test/generic/loop_then_segv.c:26
26          *(volatile int*)NULL = 0;

(gdb) python
 >print ("Before")
 >s = gdb.execute("continue", to_string=False)
 >print ("After")
 >print (s)

Program terminated with signal SIGSEGV, Segmentation fault.
The program no longer exists.


Emiliano Testa | Software Engineer | Direct: (+44)7512468305 |

[hidden email]

Undo <> | Accelerate software defect resolution by
eliminating the guesswork in failure diagnosis

CI Best Practice: Go Green, Stay Green