python interface gdb.execute() to_string is useless

Emiliano Testa <[email protected]>
Newsgroups gmane.comp.gdb.devel
Message-ID <[email protected]>
Hello,

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

Emiliano


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


(gdb) python
 >print ("Before")
 >s = gdb.execute("continue", to_string=True)
 >print ("After")
 >print (s)
 >end
Before
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;
After

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

Program terminated with signal SIGSEGV, Segmentation fault.
The program no longer exists.
After
None
(gdb)

-- 

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

[email protected]

Undo <https://undo.io> | Accelerate software defect resolution by 
eliminating the guesswork in failure diagnosis


CI Best Practice: Go Green, Stay Green 
<https://info.undo.io/go-green-stay-green>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.