Skip to content

Commit c140a66

Browse files
committed
Merge branch 'feature/coredump_pygdbmi' into 'master'
espcoredump: use pygdbmi for interaction with GDB Closes IDF-48 See merge request espressif/esp-idf!8841
2 parents 158ae5c + 23a679a commit c140a66

File tree

6 files changed

+352
-632
lines changed

6 files changed

+352
-632
lines changed

components/espcoredump/espcoredump.py

Lines changed: 340 additions & 603 deletions
Large diffs are not rendered by default.

components/espcoredump/test/test_espcoredump.py

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,24 +28,14 @@
2828

2929

3030
class TestESPCoreDumpFileLoader(unittest.TestCase):
31-
def setUp(self):
32-
self.tmp_file = 'tmp'
33-
self.dloader = espcoredump.ESPCoreDumpFileLoader(path='coredump.b64', b64=True)
34-
self.assertIsInstance(self.dloader, espcoredump.ESPCoreDumpFileLoader)
35-
36-
def tearDown(self):
37-
self.dloader.cleanup()
38-
3931
def testESPCoreDumpFileLoaderWithoutB64(self):
40-
t = espcoredump.ESPCoreDumpFileLoader(path='coredump.b64', b64=False)
41-
self.assertIsInstance(t, espcoredump.ESPCoreDumpFileLoader) # invoke for coverage of open()
42-
t.cleanup()
43-
44-
def test_cannot_remove_dir(self):
45-
self.dloader.remove_tmp_file(fname='.') # silent failure (but covers exception inside)
32+
loader = espcoredump.ESPCoreDumpFileLoader(path='coredump.b64', b64=False)
33+
loader.cleanup()
4634

4735
def test_create_corefile(self):
48-
self.assertEqual(self.dloader.create_corefile(core_fname=self.tmp_file, off=0, rom_elf=None), self.tmp_file)
36+
loader = espcoredump.ESPCoreDumpFileLoader(path='coredump.b64', b64=True)
37+
loader.create_corefile()
38+
loader.cleanup()
4939

5040

5141
if __name__ == '__main__':

components/espcoredump/test/test_espcoredump.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22

33
{ coverage debug sys \
44
&& coverage erase \
5-
&& coverage run -a --source=espcoredump ../espcoredump.py info_corefile -m -t b64 -c coredump.b64 test.elf &> output \
5+
&& coverage run -a --source=espcoredump ../espcoredump.py info_corefile -m -t b64 -c coredump.b64 -s core.elf test.elf &> output \
66
&& diff expected_output output \
7+
&& coverage run -a --source=espcoredump ../espcoredump.py info_corefile -m -t elf -c core.elf test.elf &> output2 \
8+
&& diff expected_output output2 \
79
&& coverage run -a --source=espcoredump ./test_espcoredump.py \
810
&& coverage report \
911
; } || { echo 'The test for espcoredump has failed!'; exit 1; }

tools/idf_monitor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -777,7 +777,7 @@ def process_coredump(self):
777777
self._print(output)
778778
self._output_enabled = False # Will be reenabled in check_coredump_trigger_after_print
779779
except subprocess.CalledProcessError as e:
780-
yellow_print("Failed to run espcoredump script: {}\n\n".format(e))
780+
yellow_print("Failed to run espcoredump script: {}\n{}\n\n".format(e, e.output))
781781
self._output_enabled = True
782782
self._print(COREDUMP_UART_START + b'\n')
783783
self._print(self._coredump_buffer)

tools/test_idf_monitor/idf_monitor_wrapper.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@
2727
import idf_monitor
2828

2929

30-
ELF_FILE = './dummy.elf' # ELF file used for starting the monitor
30+
ELF_FILE = 'dummy.elf' # ELF file used for starting the monitor
3131

3232

3333
def monitor_serial_reader_state(serial_reader, file_to_create):
3434
"""
35-
The pupose of this wrapper is to monitor the serial reader state of idf_monitor.py. file_to_create is created
35+
The purpose of this wrapper is to monitor the serial reader state of idf_monitor.py. file_to_create is created
3636
after the serial reader thread has been started. The existence of this file will indicate to
3737
run_test_idf_monitor.py that idf_monitor.py is ready to process inputs.
3838
"""
@@ -50,7 +50,7 @@ def main():
5050
args = parser.parse_args()
5151

5252
serial_instance = serial.serial_for_url(args.port, 115200, do_not_open=True)
53-
monitor = idf_monitor.Monitor(serial_instance, ELF_FILE, args.print_filter, 'make', 'xtensa-esp32-elf-', 'CR')
53+
monitor = idf_monitor.Monitor(serial_instance, ELF_FILE, args.print_filter, 'make', toolchain_prefix='xtensa-esp32-elf-', eol='CR')
5454
sys.stderr.write('Monitor instance has been created.\n')
5555
monitor_thread = threading.Thread(target=monitor_serial_reader_state,
5656
args=(monitor.serial_reader, args.serial_alive_file))

tools/test_idf_monitor/tests/core1_out.txt

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ I (401) esp_core_dump_uart: Press Enter to print core dump to UART...
3636
Core Dump detected!
3737
I (434) esp_core_dump_uart: Print core dump to uart...
3838
I (434) esp_core_dump_elf: Found tasks: 8
39-
ERROR: GDB/MI command failed (error / msg="No symbol table is loaded. Use the \"file\" command.")!
4039
espcoredump.py v0.4-dev
4140
===============================================================
4241
==================== ESP32 CORE DUMP START ====================
@@ -112,48 +111,40 @@ a15 0x0 0
112111
6 process 1073412788 0x400812c4 in ?? ()
113112
7 process 1073432444 0x40087e10 in ?? ()
114113
8 process 1073413520 0x400812c4 in ?? ()
115-
ERROR: GDB/MI command failed (error / msg="No symbol table is loaded. Use the \"file\" command.")!
116114

117115
==================== THREAD 1 (TCB: 0x3ffb5e80, name: '') =====================
118116
#0 0x400e37f7 in ?? ()
119117
#1 0x400d0c31 in ?? ()
120118
#2 0x40087018 in ?? ()
121-
ERROR: GDB/MI command failed (error / msg="No symbol table is loaded. Use the \"file\" command.")!
122119

123120
==================== THREAD 2 (TCB: 0x3ffb6d48, name: '') =====================
124121
#0 0x40087010 in ?? ()
125-
ERROR: GDB/MI command failed (error / msg="No symbol table is loaded. Use the \"file\" command.")!
126122

127123
==================== THREAD 3 (TCB: 0x3ffb65e4, name: '') =====================
128124
#0 0x40087010 in ?? ()
129-
ERROR: GDB/MI command failed (error / msg="No symbol table is loaded. Use the \"file\" command.")!
130125

131126
==================== THREAD 4 (TCB: 0x3ffb77a0, name: '') =====================
132127
#0 0x400812c4 in ?? ()
133128
#1 0x40089806 in ?? ()
134129
#2 0x400898f3 in ?? ()
135130
#3 0x40087018 in ?? ()
136-
ERROR: GDB/MI command failed (error / msg="No symbol table is loaded. Use the \"file\" command.")!
137131

138132
==================== THREAD 5 (TCB: 0x3ffb4bf0, name: '') =====================
139133
#0 0x400812c4 in ?? ()
140134
#1 0x4008913b in ?? ()
141135
#2 0x400d0d5c in ?? ()
142136
#3 0x40087018 in ?? ()
143-
ERROR: GDB/MI command failed (error / msg="No symbol table is loaded. Use the \"file\" command.")!
144137

145138
==================== THREAD 6 (TCB: 0x3ffafab4, name: '') =====================
146139
#0 0x400812c4 in ?? ()
147140
#1 0x40087e10 in ?? ()
148141
#2 0x400d1f4b in ?? ()
149142
#3 0x40087018 in ?? ()
150-
ERROR: GDB/MI command failed (error / msg="No symbol table is loaded. Use the \"file\" command.")!
151143

152144
==================== THREAD 7 (TCB: 0x3ffb477c, name: '') =====================
153145
#0 0x40087e10 in ?? ()
154146
#1 0x40081a2b in ?? ()
155147
#2 0x40087018 in ?? ()
156-
ERROR: GDB/MI command failed (error / msg="No symbol table is loaded. Use the \"file\" command.")!
157148

158149
==================== THREAD 8 (TCB: 0x3ffafd90, name: '') =====================
159150
#0 0x400812c4 in ?? ()

0 commit comments

Comments
 (0)