Files
seer/tests/helloskip/README
T

80 lines
3.2 KiB
Plaintext
Raw Normal View History

2025-02-18 18:34:44 -06:00
Online doc for writing mi commands in python.
https://sourceware.org/gdb/current/onlinedocs/gdb.html/GDB_002fMI-Commands-In-Python.html#GDB_002fMI-Commands-In-Python
https://sourceware.org/gdb/current/onlinedocs/gdb.html/Basic-Python.html#Basic-Python
2025-03-03 17:32:33 -06:00
Online doc for gdb's skip command.
https://sourceware.org/gdb/current/onlinedocs/gdb.html/Skipping-Over-Functions-and-Files.html
2025-02-18 18:34:44 -06:00
The following code snippet shows how some trivial MI commands can be implemented in Python:
class MISkip(gdb.MICommand):
"""Run the 'skip' command."""
def __init__(self, name, mode):
self._mode = mode
super(MISkip, self).__init__(name)
def invoke(self, argv):
if self._mode == 'dict':
return { 'dict': { 'argv' : argv } }
elif self._mode == 'list':
return { 'list': gdb.execute ("info skip", to_string=True) }
else:
return { 'string': ", ".join(argv) }
MISkip("-skip-list", "list")
The last line instantiate the class, creating one new GDB/MI commands -skip-list.
Each time a subclass of gdb.MICommand is instantiated, the new command is automatically registered with GDB.
Source the py file at the gdb prompt.
(gdb) source MISkip.py
Depending on how the Python code is read into GDB, you may need to import the gdb module explicitly.
The following example shows a GDB session in which the above commands have been added:
(gdb)
-skip-list
2025-03-26 19:57:22 -05:00
^done,list="Num Enb Glob File RE Function\n1 y n <none> n std::vector<int, std::allocator<int> >::back()\n2 y n <none> n std::unique_ptr<int, std::default_delete<int> >::operator*() const\n"
^done,list="Num Enb Glob File RE Function\n
1 y n <none> n std::vector<int, std::allocator<int> >::back()\n
2 y n <none> n std::unique_ptr<int, std::default_delete<int> >::operator*() const\n"
['helloskipxxxxxxxxxxxxxxxxxxxxxxx.cpp']
info skip
Num Enb Glob File RE Function
1 y n <none> n std::vector<int, std::allocator<int> >::back()
2 y n <none> n std::unique_ptr<int, std::default_delete<int> >::operator*() const
3 y n helloskip.cpp n <none>
4 y n helloskipxxxxxxxxxxxxxxxxxxxxxxx.cpp n <none>
2025-02-18 18:34:44 -06:00
2025-02-22 13:23:15 -06:00
2025-02-18 18:34:44 -06:00
Run Seer this way:
$ /usr/local/bin/seergdb --project=project.seer
2025-02-22 13:23:15 -06:00
[ ] The return string has 'n' characters but I think they should be '\n'. Seer parsing bug with escaped '\n'????
2025-02-18 18:34:44 -06:00
[ ] Handle the parsing of the return string and return a python table.
2025-03-26 19:57:22 -05:00
Use this to see if '-info-skip' or any other skip command is know.
-info-gdb-mi-command skip-list
-info-gdb-mi-command skip-delete
-info-gdb-mi-command skip-enable
-info-gdb-mi-command skip-...
The '-skip-list'
^done,skips=[
{number="1",enabled="y",glob="n",file="<none>",re="n",function="std::vector<int, std::allocator<int> >::back()"},
{number="2",enabled="y",glob="n",file="<none>",re="n",function="<none>"}
]