diff --git a/share/qtcreator/gdbmacros/dumper.py b/share/qtcreator/gdbmacros/dumper.py index dd57646627b1fd4c77bb5efa6a94852d96e98d6d..37cde4b5b7402caef27c2f319be3125bd24d82de 100644 --- a/share/qtcreator/gdbmacros/dumper.py +++ b/share/qtcreator/gdbmacros/dumper.py @@ -59,6 +59,110 @@ def parseAndEvaluate(exp): gdb.execute("set logging off") return gdb.history(0) + +class Breakpoint: + def __init__(self): + self.number = None + self.filename = None + self.linenumber = None + self.address = [] + self.function = None + self.fullname = None + self.condition = None + self.times = None + +def listOfBreakpoints(d): + file = tempfile.mkstemp(prefix="gdbpy_") + filename = file[1] + gdb.execute("set logging off") + gdb.execute("set logging redirect off") + gdb.execute("set logging file %s" % filename) + gdb.execute("set logging redirect on") + gdb.execute("set logging on") + gdb.execute("info break") + gdb.execute("set logging off") + gdb.execute("set logging redirect off") + + # [bkpt={number="1",type="breakpoint",disp="keep",enabled="y", + #addr="0x0804da6d",func="testHidden()",file="../app.cpp", + #fullname="...",line="1292",times="1",original-location="\"app.cpp\":1292"}, + # Num Type Disp Enb Address What\n" + #1 breakpoint keep y 0x0804da6d in testHidden() at app.cpp:1292 + #\tbreakpoint already hit 1 time + #2 breakpoint keep y 0x080564d3 in espace::..doit(int) at ../app.cpp:1210\n" + #3 breakpoint keep y <PENDING> \"plugin.cpp\":38\n" + #4 breakpoint keep y <MULTIPLE> \n" + #4.1 y 0x08056673 in Foo at ../app.cpp:126\n" + #4.2 y 0x0805678b in Foo at ../app.cpp:126\n" + #5 hw watchpoint keep y &main\n" + + file = open(filename, "r") + lines = [] + for line in file: + if len(line) == 0 or line.startswith(" "): + continue + lines.append(line) + file.close() + os.remove(filename) + + lines.reverse() + bp = Breakpoint() + for line in lines: + if line[0] < '0' or line[0] > '9': + continue + if line.startswith("\tstop only if "): + bp.condition = line[14:] + continue + if line.startswith("\tbreakpoint already hit "): + bp.times = line[24:] + continue + number = line[0:5] + pos0x = line.find(" 0x") + posin = line.find(" in ") + posat = line.find(" at ") + poscol = line.find(":", posat) + if pos0x < posin and pos0x != -1: + bp.address.append(line[pos0x + 1 : posin]) + if line.find("<PENDING>") >= 0: + bp.address.append("<PENDING>") + if posin < posat and posin != -1: + bp.function = line[posin + 4 : posat] + if posat < poscol and poscol != -1: + bp.filename = line[posat + 4 : poscol] + if poscol != -1: + bp.linenumber = line[poscol + 1 : -1] + + if '.' in number: # Part of multiple breakpoint. + continue + + # A breakpoint of its own + bp.number = int(number) + d.putCommaIfNeeded() + d.put('bkpt={number="%s"' % bp.number) + d.put(',type="breakpoint"') + d.put(',disp="keep"') + d.put(',enabled="y"') + for address in bp.address: + d.put(',addr="%s"' % address) + if not bp.function is None: + d.put(',func="%s"' % bp.function) + if not bp.filename is None: + d.put(',file="%s"' % bp.filename) + if not bp.fullname is None: + d.put(',fullname="%s"' % bp.fullname) + if not bp.linenumber is None: + d.put(',line="%s"' % bp.linenumber) + if not bp.condition is None: + d.put(',cond="%s"' % bp.condition) + if not bp.fullname is None: + d.put(',fullname="%s"' % bt.fullname) + if not bp.times is None: + d.put(',times="1"' % bp.times) + #d.put('original-location="-"') + d.put('}') + bp = Breakpoint() + + def listOfLocals(varList): try: frame = gdb.selected_frame() @@ -503,7 +607,15 @@ class FrameCommand(gdb.Command): if len(locals) and len(watchers): sep = "," - print('data=[' + locals + sep + watchers + ']\n') + # + # Breakpoints + # + #d.safeoutput = "" + #listOfBreakpoints(d) + #d.pushOutput() + #breakpoints = d.safeoutput + + print('data=[' + locals + sep + watchers + '],bkpts=[' + breakpoints + ']\n') def handleWatch(self, d, exp, iname):