Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to get output from gdb.execute in PythonGDB (GDB 7.1)?
    primarykey
    data
    text
    <p>I'm currently writing a Python GDB script. The problem is that it has to be compatible with GDB 7.1. So I first wrote the script for GDB 7.3.1 and used the following function to receive the output of an gdb command (GDB 7.3.1):</p> <pre><code>myvar = gdb.execute("info target", False, True) </code></pre> <p>The last parameter of this function is that it should return the result as a string (which makes perfectly sense; why else would I execute such a command ;) )</p> <p>In GDB Version 7.1 though it seems that the last parameter <a href="http://sourceware.org/gdb/current/onlinedocs/gdb/Basic-Python.html#Basic-Python" rel="noreferrer">isn't available</a> thus this line(GDB 7.1):</p> <pre><code>myvar = gdb.execute("info target", False) </code></pre> <p>returns <code>None</code>.</p> <p>Is there any chance to retrieve the output of this command? I already tried to redirect the standard output of my python script into a file, then loading this file but apparently the standard input and output of my python script is <a href="http://sourceware.org/gdb/current/onlinedocs/gdb/Python-API.html#Python-API" rel="noreferrer">overwritten by the gdb environment</a> so the output from the gdb.execute command is not be written to my file.</p> <p>The only thing I could think of now is to wrap my script up with a bash script that first opens gdb with a python script that executes various commands and then pipe that into a file. Then open gdb again but with another python script that loads the file, parses it and then executes other commands based on the input from the file and so on. But this is a really the ugliest solution I can think of.</p> <p>So is there a way to receive the output of an gdb.execute in GDB 7.1?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload