diff --git a/lldb/examples/python/gdbremote.py b/lldb/examples/python/gdbremote.py index 3045bb0170886..8b6a268496214 100755 --- a/lldb/examples/python/gdbremote.py +++ b/lldb/examples/python/gdbremote.py @@ -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 @@ def get_key_value_pairs(self): 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 @@ def parse_gdb_log(file, options): 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',