Debug: update PyCortexMDebug to latest and refactor (#574)
* Debug: update PyCortexDebug to latest and refactor. * Debug: format sources. Dockerfile: add missing dependency. Make: switch to gdb-py. * Debug: port PyCortexMDebug to python2 * Docker: add missing debug dependencies * Debug: cleanup local include in svd_gdb.py
This commit is contained in:
20
debug/PyCortexMDebug/cmdebug/dwt_gdb.py
Normal file → Executable file
20
debug/PyCortexMDebug/cmdebug/dwt_gdb.py
Normal file → Executable file
@@ -38,12 +38,14 @@ class DWT(gdb.Command):
|
||||
def __init__(self):
|
||||
gdb.Command.__init__(self, "dwt", gdb.COMMAND_DATA)
|
||||
|
||||
def read(self, address, bits=32):
|
||||
@staticmethod
|
||||
def read(address, bits=32):
|
||||
"""Read from memory (using print) and return an integer"""
|
||||
value = gdb.selected_inferior().read_memory(address, bits / 8)
|
||||
return struct.unpack_from("<i", value)[0]
|
||||
|
||||
def write(self, address, value, bits=32):
|
||||
@staticmethod
|
||||
def write(address, value, bits=32):
|
||||
"""Set a value in memory"""
|
||||
gdb.selected_inferior().write_memory(address, bytes(value), bits / 8)
|
||||
|
||||
@@ -53,7 +55,7 @@ class DWT(gdb.Command):
|
||||
self.write(DWT_CTRL, 0)
|
||||
self.is_init = True
|
||||
|
||||
s = map(lambda x: x.lower(), str(args).split(" "))
|
||||
s = list(map(lambda x: x.lower(), str(args).split(" ")))
|
||||
# Check for empty command
|
||||
if s[0] in ["", "help"]:
|
||||
self.print_help()
|
||||
@@ -100,7 +102,8 @@ class DWT(gdb.Command):
|
||||
gdb.write(args)
|
||||
self.print_help()
|
||||
|
||||
def complete(self, text, word):
|
||||
@staticmethod
|
||||
def complete(text, word):
|
||||
text = str(text).lower()
|
||||
s = text.split(" ")
|
||||
|
||||
@@ -135,7 +138,8 @@ class DWT(gdb.Command):
|
||||
def cpicnt_reset(self, value=0):
|
||||
self.write(DWT_CPICNT, value & 0xFF)
|
||||
|
||||
def print_help(self):
|
||||
@staticmethod
|
||||
def print_help():
|
||||
gdb.write("Usage:\n")
|
||||
gdb.write("=========\n")
|
||||
gdb.write("dwt:\n")
|
||||
@@ -149,4 +153,8 @@ class DWT(gdb.Command):
|
||||
gdb.write("dwt cyccnt\n")
|
||||
gdb.write("\tDisplay the cycle count\n")
|
||||
gdb.write("\td(default):decimal, x: hex, o: octal, b: binary\n")
|
||||
return ()
|
||||
return
|
||||
|
||||
|
||||
# Registers our class to GDB when sourced:
|
||||
DWT()
|
||||
|
Reference in New Issue
Block a user