gdb: fix commands formatting
This commit is contained in:
parent
f0f9de8660
commit
176cdc8069
@ -5,6 +5,13 @@ import gdb
|
|||||||
import time
|
import time
|
||||||
import re
|
import re
|
||||||
import json
|
import json
|
||||||
|
import pwd
|
||||||
|
import grp
|
||||||
|
import stat
|
||||||
|
import time
|
||||||
|
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
|
|
||||||
class DumpMemory(gdb.Command):
|
class DumpMemory(gdb.Command):
|
||||||
"""Dump memory info into a file."""
|
"""Dump memory info into a file."""
|
||||||
@ -41,8 +48,10 @@ class DumpMemory(gdb.Command):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
print("Usage: dm [pattern]\n\twhith pattern : heap, stack or any value in /proc/self/maps")
|
print("Usage: dm [pattern]\n\twhith pattern : heap, stack or any value in /proc/self/maps")
|
||||||
|
|
||||||
|
|
||||||
DumpMemory()
|
DumpMemory()
|
||||||
|
|
||||||
|
|
||||||
class DumpJson(gdb.Command):
|
class DumpJson(gdb.Command):
|
||||||
"""Dump std::string as a styled JSON."""
|
"""Dump std::string as a styled JSON."""
|
||||||
|
|
||||||
@ -67,11 +76,14 @@ class DumpJson(gdb.Command):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Parse json error! {args}")
|
print(f"Parse json error! {args}")
|
||||||
|
|
||||||
|
|
||||||
DumpJson()
|
DumpJson()
|
||||||
|
|
||||||
tp = {}
|
tp = {}
|
||||||
|
|
||||||
|
|
||||||
class Tracepoint(gdb.Breakpoint):
|
class Tracepoint(gdb.Breakpoint):
|
||||||
|
|
||||||
def __init__(self, *args):
|
def __init__(self, *args):
|
||||||
super().__init__(*args)
|
super().__init__(*args)
|
||||||
self.silent = True
|
self.silent = True
|
||||||
@ -99,7 +111,10 @@ class Tracepoint(gdb.Breakpoint):
|
|||||||
# do not stop at tracepoint
|
# do not stop at tracepoint
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
class SetTracepoint(gdb.Command):
|
class SetTracepoint(gdb.Command):
|
||||||
|
""" Everytime the function in parameter get called, a message is printed with the argument used """
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__("tp", gdb.COMMAND_USER)
|
super().__init__("tp", gdb.COMMAND_USER)
|
||||||
|
|
||||||
@ -110,11 +125,13 @@ class SetTracepoint(gdb.Command):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(e)
|
print(e)
|
||||||
|
|
||||||
|
|
||||||
def finish(event):
|
def finish(event):
|
||||||
for t, p in tp.items():
|
for t, p in tp.items():
|
||||||
c = p.count
|
c = p.count
|
||||||
print(f"Tracepoint '{t}' Count: {c}")
|
print(f"Tracepoint '{t}' Count: {c}")
|
||||||
|
|
||||||
|
|
||||||
gdb.events.exited.connect(finish)
|
gdb.events.exited.connect(finish)
|
||||||
SetTracepoint()
|
SetTracepoint()
|
||||||
|
|
||||||
@ -134,6 +151,7 @@ class EndPoint(gdb.FinishBreakpoint):
|
|||||||
print(f"\tCost: {diff}")
|
print(f"\tCost: {diff}")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
class StartPoint(gdb.Breakpoint):
|
class StartPoint(gdb.Breakpoint):
|
||||||
def __init__(self, *a, **kw):
|
def __init__(self, *a, **kw):
|
||||||
super().__init__(*a, **kw)
|
super().__init__(*a, **kw)
|
||||||
@ -170,7 +188,10 @@ class StartPoint(gdb.Breakpoint):
|
|||||||
EndPoint(self, internal=True)
|
EndPoint(self, internal=True)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
class Profile(gdb.Command):
|
class Profile(gdb.Command):
|
||||||
|
""" Profile execution time of a function """
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__("prof", gdb.COMMAND_USER)
|
super().__init__("prof", gdb.COMMAND_USER)
|
||||||
|
|
||||||
@ -180,19 +201,10 @@ class Profile(gdb.Command):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(e)
|
print(e)
|
||||||
|
|
||||||
|
|
||||||
Profile()
|
Profile()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
import pwd
|
|
||||||
import grp
|
|
||||||
import stat
|
|
||||||
import time
|
|
||||||
|
|
||||||
from datetime import datetime
|
|
||||||
|
|
||||||
|
|
||||||
class StatPrint:
|
class StatPrint:
|
||||||
def __init__(self, val):
|
def __init__(self, val):
|
||||||
self.val = val
|
self.val = val
|
||||||
@ -258,6 +270,8 @@ class StatPrint:
|
|||||||
out += f"Change: {self.get_time(st_ctim)}\n"
|
out += f"Change: {self.get_time(st_ctim)}\n"
|
||||||
out += "}"
|
out += "}"
|
||||||
return out
|
return out
|
||||||
|
|
||||||
|
|
||||||
# Could be disabled at runtime with:
|
# Could be disabled at runtime with:
|
||||||
# disable pretty-print global sp
|
# disable pretty-print global sp
|
||||||
# then check "info pretty-print"
|
# then check "info pretty-print"
|
||||||
|
Loading…
Reference in New Issue
Block a user