-
Notifications
You must be signed in to change notification settings - Fork 183
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
debugging: lab-data: reformat linked_list.py
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
Showing
1 changed file
with
26 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |