nRF Connect SDK Intermediate Training - Lesson 2 - Exercise 2 - coredump_gdbserver.py crashes when optimize for debug is enabled

Hello,

I am working through the Zephyr training modules (These are great, thanks!) and encountered an issue I do not know how to resolve. This issue applies to general debugging, hence why I am reaching out.

nRF Connect SDK v2.8.0

Specifically, in nRF Connect SDK Intermediate - Exercise 2, step 10: Connect to the debug instance does not work if the .elf being analyzed was generated with the optimization level set to "Optimize for debugging (-Og)" in the build configuration. I am testing on a nRF52840 development kit.

Steps to reproduce:

1. For simplicity, create a new application and copy an existing sample, Lesson 2 - Exercise 2 Solution

2. Add a build configuration and select the nRF52840dk, and change the optimization level to "Optimize for debugging (-Og)"

3. Build the configuration and project

4. Flash the project to the nRF52840dk

5. Open the nRF Serial Terminal built into VS Code

6. Press the reset button on the nRF5280dk and observe the following output

*** Booting nRF Connect SDK v2.8.0-a2386bfc8401 ***
*** Using Zephyr OS v3.7.99-0bc3393fb112 ***
[00:00:00.252,044] <inf> Lesson2_Exercise2: Press button 1 to get a fault error

7. Press button 1 and observe the coredump print to the console

8. Copy all lines starting from 'coredump: #CD:BEGIN#' to '<err> coredump: #CD:END#' and save to a file called dump.log to the root of the project folder 'inter_less2_exer2_solution'

9. Open a Windows command prompt terminal, navigate to the root of the project folder 'inter_less2_exer2_solution' and execute the following two lines:

python C:\ncs\v2.8.0\zephyr\scripts\coredump/coredump_serial_log_parser.py dump.log dump.bin

python C:\ncs\v2.8.0\zephyr\scripts\coredump/coredump_gdbserver.py build\inter_less2_exer2_solution\zephyr/zephyr.elf dump.bin -v

10. Observe the GDB server start with:

[INFO][gdbstub] Waiting GDB connection on port 1234...

11. Open a new Windows command prompt terminal, navigate to the project root folder 'inter_less2_exer2_solution' and execute the following:

C:\ncs\toolchains\2d382dcd92\opt\zephyr-sdk\arm-zephyr-eabi\bin/arm-zephyr-eabi-gdb build\inter_less2_exer2_solution\zephyr/zephyr.elf

12. Observe it start a GDB session with the (gdb) prompt.

13. Connect to the debug instance with the command:

target remote localhost:1234

14. Observe the GDB server crash as soon as you try to connect with the following output:

[INFO][gdbstub] Waiting GDB connection on port 1234...
[INFO][gdbstub] Accepted GDB connection from ('127.0.0.1', 53761)
Traceback (most recent call last):
  File "C:\ncs\v2.8.0\zephyr\scripts\coredump/coredump_gdbserver.py", line 155, in <module>
    main()
  File "C:\ncs\v2.8.0\zephyr\scripts\coredump/coredump_gdbserver.py", line 142, in main
    gdbstub.run(conn)
  File "C:\ncs\v2.8.0\zephyr\scripts\coredump\gdbstubs\gdbstub.py", line 336, in run
    self.handle_general_query_packet(pkt)
  File "C:\ncs\v2.8.0\zephyr\scripts\coredump\gdbstubs\gdbstub.py", line 181, in handle_general_query_packet
    threads_metadata_data = self.logfile.get_threads_metadata()["data"]
                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\ncs\v2.8.0\zephyr\scripts\coredump\coredump_parser\log_parser.py", line 79, in get_threads_metadata
    return self.threads_metadata
           ^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'CoredumpLogFile' object has no attribute 'threads_metadata'. Did you mean: 'get_threads_metadata'?

The same steps above work just fine when the project build configuration is set to "Use project default".

What is causing this?

Thanks,

Derek

Parents Reply
  • Hi there,

    Juts for completeness, I was about to submit the same bug as well.  I hadn't noticed the connection with the debug options, so thanks Derek for that.  

    Any chance of you guys adding a note to the tutorial, warning of the problem?  I spent about an hour trying to fix this - ironic, given that it was a tutorial on debugging!

    Best regards,

    Andy

Children
Related