File tree 1 file changed +24
-0
lines changed
1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change 3
3
import time
4
4
import select
5
5
import os
6
+ import lldb
6
7
7
8
def clearjdb (debugger , command , result , internal_dict ):
8
9
run_jdb_quit ()
@@ -36,6 +37,29 @@ def run_jdb_quit():
36
37
except Exception as e :
37
38
print (f"Error running jdb: { e } " )
38
39
40
+ def System_String_Summary (valobj , internal_dict ):
41
+ try :
42
+ data_ptr = valobj .GetChildMemberWithName ("_firstChar" )
43
+ length = valobj .GetChildMemberWithName ("_stringLength" ).GetValueAsUnsigned ()
44
+ if data_ptr and length :
45
+ process = valobj .GetProcess ()
46
+ error = lldb .SBError ()
47
+ address = data_ptr .GetLoadAddress ()
48
+ if address == lldb .LLDB_INVALID_ADDRESS :
49
+ return "<invalid address>"
50
+ string_data = process .ReadMemory (address , length * 2 , error ) # UTF-16 encoding uses 2 bytes per character
51
+ if error .Success ():
52
+ return string_data .decode ("utf-16" )
53
+ else :
54
+ return f"<error reading memory: { error } >"
55
+ except Exception as e :
56
+ return f"<error reading string: { e } >"
57
+ return "<empty>"
58
+
59
+ def __lldb_init_module (debugger , internal_dict ):
60
+ debugger .HandleCommand ('type summary add --python-function lldb_commands.System_String_Summary "String"' )
61
+ print ('The "formatter" command has been installed!' )
62
+
39
63
# Allow direct execution of this script
40
64
if __name__ == "__main__" :
41
65
run_jdb_quit ()
You can’t perform that action at this time.
0 commit comments