[lldb] Fix python errors in gdbremote.py

Fix exceptions encountered while debugging gdb protocol

Differential Revision: https://reviews.llvm.org/D120792
This commit is contained in:
Dominic Chen 2022-03-01 22:54:59 -08:00
parent 1cfcbf197c
commit cd89f94aa9
1 changed files with 17 additions and 13 deletions

View File

@ -260,6 +260,12 @@ def stop_gdb_log(debugger, command, result, dict):
dest='verbose',
help='display verbose debug info',
default=False)
parser.add_option(
'--plot',
action='store_true',
dest='plot',
help='plot packet latencies by packet type',
default=False)
parser.add_option(
'-q',
'--quiet',
@ -556,11 +562,11 @@ class Packet:
return kvp
def split(self, ch):
return string.split(self.str, ch)
return self.str.split(ch)
def split_hex(self, ch, byte_order):
hex_values = list()
strings = string.split(self.str, ch)
strings = self.str.split(ch)
for str in strings:
hex_values.append(Packet(str).get_hex_uint(byte_order))
return hex_values
@ -888,7 +894,7 @@ def rsp_vCont(options, cmd, cmd_args, rsp):
def cmd_vAttach(options, cmd, args):
(extra_command, args) = string.split(args, ';')
(extra_command, args) = args.split(';')
if extra_command:
print("%s%s(%s)" % (cmd, extra_command, args))
else:
@ -1212,9 +1218,13 @@ def decode_packet(s, start_index=0):
def rsp_json(options, cmd, cmd_args, rsp):
print('%s() reply:' % (cmd))
json_tree = json.loads(rsp)
print(json.dumps(json_tree, indent=4, separators=(',', ': ')))
if not rsp:
return
try:
json_tree = json.loads(rsp)
print(json.dumps(json_tree, indent=4, separators=(',', ': ')))
except json.JSONDecodeError:
return
def rsp_jGetLoadedDynamicLibrariesInfos(options, cmd, cmd_args, rsp):
if cmd_args:
@ -1541,7 +1551,7 @@ def parse_gdb_log(file, options):
print(" %24s %11.6f %5.2f%% %6d %9.6f" % (
item, packet_total_time, packet_percent, packet_count,
float(packet_total_time) / float(packet_count)))
if options.plot:
if options and options.plot:
plot_latencies(packet_times)
if __name__ == '__main__':
@ -1558,12 +1568,6 @@ if __name__ == '__main__':
dest='verbose',
help='display verbose debug info',
default=False)
parser.add_option(
'--plot',
action='store_true',
dest='plot',
help='plot packet latencies by packet type',
default=False)
parser.add_option(
'-q',
'--quiet',