Skip to content

Commit

Permalink
debugging: lab-data: reformat linked_list.py
Browse files Browse the repository at this point in the history
When trying to open linked_list.py in an editor with a proper Python LSP
configured, we get a ton of warnings and errors. Get rid of those by
reformatting the file.

Signed-off-by: Alexis Lothoré <[email protected]>
  • Loading branch information
Tropicao committed Dec 10, 2024
1 parent 700efc9 commit c10094b
Showing 1 changed file with 26 additions and 22 deletions.
48 changes: 26 additions & 22 deletions lab-data/debugging/nfsroot/root/gdb/linked_list.py
Original file line number Diff line number Diff line change
@@ -1,38 +1,42 @@
import gdb


class StructNamePrinter:
"Print a struct name"
"Print a struct name"

def __init__(self, val):
self.val = val

def __init__(self, val):
self.val = val
def to_string(self):
return "TODO"

def to_string(self):
return "TODO"

def struct_name_lookup_function(val):
if str(val.type) == 'struct name':
return StructNamePrinter(val)
if str(val.type) == 'struct name':
return StructNamePrinter(val)

return None

return None

gdb.pretty_printers.append(struct_name_lookup_function)


class PrintSList (gdb.Command):
def __init__(self):
super(PrintSList, self).__init__("printslist", gdb.COMMAND_USER)
def __init__(self):
super(PrintSList, self).__init__("printslist", gdb.COMMAND_USER)

def invoke(self, arg, from_tty):
args = gdb.string_to_argv(arg)
if len(args) < 2:
print("Usage: printslist <list head> <next field name>")
return
def invoke(self, arg, from_tty):
args = gdb.string_to_argv(arg)
if len(args) < 2:
print("Usage: printslist <list head> <next field name>")
return

list = gdb.parse_and_eval(args[0])
next_field = args[1]
elem = list['slh_first']
while elem != 0:
print(elem.dereference())
elem = TODO
list = gdb.parse_and_eval(args[0])
next_field = args[1]
elem = list['slh_first']
while elem != 0:
print(elem.dereference())
elem = TODO


PrintSList()
PrintSList()

0 comments on commit c10094b

Please sign in to comment.