From 646f3fb8011409f10b43e0d20efc053b9543ff30 Mon Sep 17 00:00:00 2001 From: Roland Dobai Date: Thu, 12 Nov 2020 14:33:49 +0100 Subject: [PATCH 1/3] tools: Fix non-existing key in espcoredump's GDMI payload --- components/espcoredump/espcoredump.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/components/espcoredump/espcoredump.py b/components/espcoredump/espcoredump.py index e3daad179f..8ea0bf8601 100755 --- a/components/espcoredump/espcoredump.py +++ b/components/espcoredump/espcoredump.py @@ -1303,7 +1303,8 @@ def gdbmi_freertos_get_task_name(p, tcb_addr): # type: (GdbController, int) -> """ Get FreeRTOS task name given the TCB address """ try: val = gdbmi_data_evaluate_expression(p, "(char*)((TCB_t *)0x%x)->pcTaskName" % tcb_addr) - except ESPCoreDumpError: + except (ESPCoreDumpError, KeyError): + # KeyError is raised when "value" is not in "payload" return '' # Value is of form '0x12345678 "task_name"', extract the actual name From 82ee1d4683053ca59e6ed139ced5c0761873d4f9 Mon Sep 17 00:00:00 2001 From: Roland Dobai Date: Thu, 12 Nov 2020 21:02:23 +0100 Subject: [PATCH 2/3] tools: Increase the internal GDB response delay for espcoredump CI tests --- components/espcoredump/espcoredump.py | 13 ++++++++++++- components/espcoredump/test/test_espcoredump.sh | 4 ++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/components/espcoredump/espcoredump.py b/components/espcoredump/espcoredump.py index 8ea0bf8601..65c7aad46c 100755 --- a/components/espcoredump/espcoredump.py +++ b/components/espcoredump/espcoredump.py @@ -30,6 +30,8 @@ import time from pygdbmi.gdbcontroller import GdbController, DEFAULT_GDB_TIMEOUT_SEC +_gdb_timeout_sec = DEFAULT_GDB_TIMEOUT_SEC + IDF_PATH = os.getenv('IDF_PATH') if not IDF_PATH: sys.stderr.write("IDF_PATH is not found! Set proper IDF_PATH in environment.\n") @@ -1234,7 +1236,7 @@ def gdbmi_run_cmd_get_responses(p, cmd, resp_message, resp_type, multiple=True, # type: (GdbController, str, typing.Optional[str], str, bool, typing.Optional[str], typing.Optional[str]) -> list p.write(cmd, read_response=False) - t_end = time.time() + DEFAULT_GDB_TIMEOUT_SEC + t_end = time.time() + _gdb_timeout_sec filtered_response_list = [] all_responses = [] while time.time() < t_end: @@ -1494,6 +1496,12 @@ def main(): type=int, default=os.environ.get('ESPTOOL_BAUD', esptool.ESPLoader.ESP_ROM_BAUD)) + parser.add_argument( + '--gdb-timeout-sec', + help='Overwrite the default internal delay for gdb responses', + type=int, + default=DEFAULT_GDB_TIMEOUT_SEC) + subparsers = parser.add_subparsers( dest='operation', help='Run coredumper {command} -h for additional help') @@ -1537,6 +1545,9 @@ def main(): args = parser.parse_args() + global _gdb_timeout_sec + _gdb_timeout_sec = args.gdb_timeout_sec + log_level = logging.CRITICAL if args.debug == 0: log_level = logging.CRITICAL diff --git a/components/espcoredump/test/test_espcoredump.sh b/components/espcoredump/test/test_espcoredump.sh index 0445d1491f..3829c16755 100755 --- a/components/espcoredump/test/test_espcoredump.sh +++ b/components/espcoredump/test/test_espcoredump.sh @@ -2,9 +2,9 @@ { coverage debug sys \ && coverage erase \ - && coverage run -a --source=espcoredump ../espcoredump.py info_corefile -m -t b64 -c coredump.b64 -s core.elf test.elf &> output \ + && coverage run -a --source=espcoredump ../espcoredump.py --gdb-timeout-sec 5 info_corefile -m -t b64 -c coredump.b64 -s core.elf test.elf &> output \ && diff expected_output output \ - && coverage run -a --source=espcoredump ../espcoredump.py info_corefile -m -t elf -c core.elf test.elf &> output2 \ + && coverage run -a --source=espcoredump ../espcoredump.py --gdb-timeout-sec 5 info_corefile -m -t elf -c core.elf test.elf &> output2 \ && diff expected_output output2 \ && coverage run -a --source=espcoredump ./test_espcoredump.py \ && coverage report \ From 2ecf66eba3094cdb5f8a7819ed6134b4fc395bdc Mon Sep 17 00:00:00 2001 From: Roland Dobai Date: Wed, 18 Nov 2020 18:48:23 +0100 Subject: [PATCH 3/3] tools: Wait and dump the initial messages during gdbmi initialization --- components/espcoredump/espcoredump.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/components/espcoredump/espcoredump.py b/components/espcoredump/espcoredump.py index 65c7aad46c..3a713ccf10 100755 --- a/components/espcoredump/espcoredump.py +++ b/components/espcoredump/espcoredump.py @@ -1271,7 +1271,8 @@ def gdbmi_start(gdb_path, gdb_cmds, core_filename, prog_filename): # type: (str gdb_args.append(prog_filename) res = GdbController(gdb_path=gdb_path, gdb_args=gdb_args) # Consume initial output by issuing a dummy command - res.write("-data-list-register-values x pc", timeout_sec=5) + gdbmi_run_cmd_get_responses(res, "-data-list-register-values x pc", None, "console", multiple=True, + done_message="done", done_type="result") return res