Reputation: 8052
I've been following this amazing (video) tutorial to create custom user defined GDB command using python
here is my code
import os
import gdb
class BugReport (gdb.Command):
"""Collect required info for a bug report"""
def __init__(self):
super(BugReport, self).__init__("bugreport", gdb.COMMAND_USER)
def invoke(self, arg, from_tty):
pagination = gdb.parameter("pagination")
if pagination: gdb.execute("set pagination off")
f = open("/tmp/bugreport.txt", "w")
f.write(gdb.execute("thread apply all backtrace full", to_string=True))
f.close()
os.system("uname -a >> /tmp/bugreport.txt")
if pagination: gdb.execute("set pagination on")
BugReport()
but when I try to source this code inside gdb I get following error:
(gdb) source mybugreport.py
Traceback (most recent call last):
File "mybugreport.py", line 19, in <module>
BugReport()
TypeError: function missing required argument 'name' (pos 1)
what I'm doing wrong?
Upvotes: 1
Views: 59
Reputation: 213754
what I'm doing wrong?
Python is indentation-sensitive. You want:
class BugReport (gdb.Command):
"""Collect required info for a bug report"""
def __init__(self):
super(BugReport, self).__init__("bugreport", gdb.COMMAND_USER)
def invoke(self, arg, from_tty):
pagination = gdb.parameter("pagination")
...
BugReport()
Upvotes: 1