6060# Note: not using `requests` but using the built-in http.client instead, so
6161# there will be no additional dependencies other than Python itself.
6262try :
63- from httplib import HTTPConnection , HTTPSConnection # noqa: I251
64- from Queue import Queue # noqa: I251
65- from urlparse import urlparse , urlunparse # noqa: I251
63+ from httplib import HTTPConnection , HTTPSConnection
64+ from Queue import Queue
65+ from urlparse import urlparse , urlunparse
6666except ImportError :
6767 from http .client import HTTPConnection , HTTPSConnection
6868 from queue import Queue
@@ -145,7 +145,7 @@ def _pc_in_vector_table(register_list, exception_number, analytics_props):
145145 exc_handler , _ = _read_register (0x0 + vtor + (exception_number * 4 ))
146146 exc_handler &= ~ 0x1 # Clear thumb bit
147147 return exc_handler == curr_pc
148- except Exception : # noqa
148+ except Exception :
149149 analytics_props ["pc_in_vtor_check_error" ] = {"traceback" : traceback .format_exc ()}
150150 return False
151151
@@ -347,7 +347,7 @@ def get_current_registers(self, gdb_thread, analytics_props):
347347 try :
348348 for core_id in range (0 , self .num_cores ):
349349 result .append (self ._read_registers (core_id , gdb_thread , analytics_props ))
350- except Exception : # noqa
350+ except Exception :
351351 analytics_props ["core_reg_collection_error" ] = {"traceback" : traceback .format_exc ()}
352352
353353 return result
@@ -458,15 +458,15 @@ def add_platform_specific_sections(self, cd_writer, inferior, analytics_props):
458458 section .data = inferior .read_memory (section .addr , section .size )
459459 cd_writer .add_section (section )
460460 analytics_props ["{}_ok" .format (short_name )] = True
461- except Exception : # noqa
461+ except Exception :
462462 analytics_props ["{}_collection_error" .format (short_name )] = {
463463 "traceback" : traceback .format_exc ()
464464 }
465465
466466 try :
467467 cd_writer .armv67_mpu = self ._try_collect_mpu_settings ()
468468 print ("Collected MPU config" )
469- except Exception : # noqa
469+ except Exception :
470470 analytics_props ["mpu_collection_error" ] = {"traceback" : traceback .format_exc ()}
471471
472472 def guess_ram_regions (self , elf_sections ):
@@ -489,9 +489,19 @@ def get_current_registers(self, gdb_thread, analytics_props):
489489 # best way. Call this, rip out the first element in each row...that's the register name
490490
491491 #
492- # NOTE: We use the "all" argument below because on some versions of gdb "msp, psp, etc" are not considered part of them
493- # core set. This will also dump all the fpu registers which we don't collect but thats fine
494- info_reg_all_list = gdb .execute ("info reg all" , to_string = True )
492+ # NOTE: Using the 'all-registers' command below, because on some
493+ # versions of gdb "msp, psp, etc" are not considered part of them core
494+ # set. This will also dump all the fpu registers which we don't collect
495+ # but thats fine. 'info all-registers' is the preferred command, where
496+ # 'info reg [all]' is arch-specific, see:
497+ # https://sourceware.org/gdb/onlinedocs/gdb/Registers.html
498+ try :
499+ info_reg_all_list = gdb .execute ("info all-registers" , to_string = True )
500+ except gdb .error :
501+ # Some versions of gdb don't support 'all' and return an error, fall
502+ # back to 'info reg'
503+ info_reg_all_list = gdb .execute ("info reg" , to_string = True )
504+
495505 return (lookup_registers_from_list (self , info_reg_all_list , analytics_props ),)
496506
497507
@@ -539,7 +549,7 @@ def _try_read_register(arch, frame, lookup_name, register_list, analytics_props,
539549 _add_reg_collection_error_analytic (
540550 arch , analytics_props , lookup_name , "<unavailable> value"
541551 )
542- except Exception : # noqa
552+ except Exception :
543553 _add_reg_collection_error_analytic (
544554 arch , analytics_props , lookup_name , traceback .format_exc ()
545555 )
@@ -600,7 +610,7 @@ def _search_list_for_alt_name(reg, found_registers):
600610 # if we can't patch the registers, we'll just fallback to the active state
601611 try :
602612 check_and_patch_reglist_for_fault (register_list , analytics_props )
603- except Exception : # noqa
613+ except Exception :
604614 analytics_props ["fault_register_recover_error" ] = {"traceback" : traceback .format_exc ()}
605615 pass
606616
@@ -786,7 +796,7 @@ def _http(method, base_uri, path, headers=None, body=None):
786796 body = response .read ()
787797 try :
788798 json_body = loads (body )
789- except Exception : # noqa
799+ except Exception :
790800 json_body = None
791801 conn .close ()
792802 return status , reason , json_body
@@ -1063,7 +1073,7 @@ def settings_load():
10631073 try :
10641074 with open (MEMFAULT_CONFIG .json_path , "rb" ) as f :
10651075 return load (f )
1066- except Exception : # noqa
1076+ except Exception :
10671077 return {}
10681078
10691079
@@ -1438,7 +1448,10 @@ def parse_args(self, unicode_args, config):
14381448 )
14391449
14401450 def _auto_int (x ):
1441- return int (x , 0 )
1451+ try :
1452+ return int (x , 0 )
1453+ except ValueError :
1454+ return int (gdb .parse_and_eval (x ))
14421455
14431456 parser .add_argument (
14441457 "--region" ,
@@ -1696,7 +1709,7 @@ def run(self):
16961709 # Throttle a bit
16971710 sleep (0.2 )
16981711
1699- except Exception : # noqa
1712+ except Exception :
17001713 pass # Never fail due to analytics requests erroring out
17011714
17021715
@@ -1711,12 +1724,12 @@ def _track_script_sourced():
17111724 from platform import mac_ver
17121725
17131726 mac_version = mac_ver ()[0 ]
1714- except Exception : # noqa
1727+ except Exception :
17151728 mac_version = ""
17161729
17171730 try :
17181731 gdb_version = gdb .execute ("show version" , to_string = True ).strip ().split ("\n " )[0 ]
1719- except Exception : # noqa
1732+ except Exception :
17201733 gdb_version = ""
17211734
17221735 ANALYTICS .track (
0 commit comments