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