Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing gdbinit file generation for windows (IDFGH-11562) #12683

Closed

Conversation

MiguelBarro
Copy link
Contributor

Running gdb on windows fails using the following steps:

# launch openocd server (the project is already build & flash)
# 1 & 2 mean different terminal prompts
1> $Env:ESPPORT = "COM3"
1> idf.py -C C:\myproject\ -B $Env:TMP/myproject `
         openocd --openocd-commands "-f interface/ftdi/olimex-arm-usb-ocd-h.cfg -f target/esp32.cfg -c 'adapter speed 5000'"
2> idf.py -B $Env:TMP/myproject gdb -C C:\myproject

gdb fails with the following message:

C:\ProgramData\Espressif\frameworks\esp-idf-v5.1\tools\check_python_dependencies.py:12: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
  import pkg_resources
Executing action: gdb
GNU gdb (esp-gdb) 12.1_20221002
Copyright (C) 2022 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "--host=x86_64-w64-mingw32 --target=xtensa-esp-elf".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word".
add symbol table from file "C:\Users\migue\AppData\Local\Temp\mqtt\bootloader\bootloader.elf"
C:/Users/me/AppData/Local/Temp/myproject\gdbinit\gdbinit:3: Error in sourced command file:
C:/Users/me/AppData/Local/Temp/myproject\gdbinit\symbols:6: Error in sourced command file:
Undefined command: "".  Try "help".
(gdb)

By reviewing the framework generated files two issues were identified:

  • Fixing newline characters of the symbol file. The problem is in the method
    def generate_gdbinit_rom_add_symbols(target: str) -> str:

which generates an array of strings r which joins using:

            return os.linesep.join(r)

this is wrong it should use:

            return '\n'.join(r)
  • gdbinit path separators must be fixed because gdb cannot understand win32 backslash.
        gdbinit_dir = '/'.join([project_desc['build_dir'], 'gdbinit'])
        py_extensions = '/'.join([gdbinit_dir, 'py_extensions'])
        symbols = '/'.join([gdbinit_dir, 'symbols'])
        gdbinit = '/'.join([gdbinit_dir, 'connect'])

Then the original:

    source C:/Users/me/AppData/Local/Temp/myproject\gdbinit\py_extensions
    source C:/Users/me/AppData/Local/Temp/myproject\gdbinit\symbols
    source C:/Users/me/AppData/Local/Temp/myprojectgdbinit\connect

will turn into:

    source C:/Users/me/AppData/Local/Temp/myproject/gdbinit/py_extensions
    source C:/Users/me/AppData/Local/Temp/myproject/gdbinit/symbols
    source C:/Users/me/AppData/Local/Temp/myproject/gdbinit/connect

@CLAassistant
Copy link

CLAassistant commented Nov 28, 2023

CLA assistant check
All committers have signed the CLA.

@espressif-bot espressif-bot added the Status: Opened Issue is new label Nov 28, 2023
@github-actions github-actions bot changed the title Fixing gdbinit file generation for windows Fixing gdbinit file generation for windows (IDFGH-11562) Nov 28, 2023
@igrr
Copy link
Member

igrr commented Nov 28, 2023

Hi @MiguelBarro, thank you for the fix. To ensure that all fixes are propagated to new releases, we only accept PRs to master branch. If you need the fix on one of the release branches, you can mention this in the description and we will backport it.

Could you please rebase your changes to master and change the target branch of the PR?

@MiguelBarro
Copy link
Contributor Author

MiguelBarro commented Nov 28, 2023

I will rebase but please notice it has been only tested for v5.1.1

Signed-off-by: GuyBrush <miguel.barro@live.com>
@MiguelBarro MiguelBarro changed the base branch from release/v5.1 to master November 28, 2023 11:04
Copy link

Messages
📖 Good Job! All checks are passing!

👋 Welcome MiguelBarro, thank you for your first contribution to espressif/esp-idf project!

📘 Please check Contributions Guide for the contribution checklist, information regarding code and documentation style, testing and other topics.

🖊️ Please also make sure you have read and signed the Contributor License Agreement for espressif/esp-idf project.

Pull request review and merge process you can expect

Espressif develops the ESP-IDF project in an internal repository (Gitlab). We do welcome contributions in the form of bug reports, feature requests and pull requests via this public GitHub repository.

  1. An internal issue has been created for the PR, we assign it to the relevant engineer
  2. They review the PR and either approve it or ask you for changes or clarifications
  3. Once the Github PR is approved, we synchronize it into our internal git repository
  4. In the internal git repository we do the final review, collect approvals from core owners and make sure all the automated tests are passing
    • At this point we may do some adjustments to the proposed change, or extend it by adding tests or documentation.
  5. If the change is approved and passes the tests it is merged into the master branch
  6. On next sync from the internal git repository merged change will appear in this public Github repository

Generated by 🚫 dangerJS against 8b52edf

@igrr igrr requested a review from Lapshin November 28, 2023 11:42
@espressif-bot espressif-bot added Status: Done Issue is done internally Resolution: NA Issue resolution is unavailable and removed Status: Opened Issue is new labels Nov 29, 2023
espressif-bot pushed a commit that referenced this pull request Nov 30, 2023
Merges #12683

Signed-off-by: Alexey Lapshin <alexey.lapshin@espressif.com>
movsb pushed a commit to movsb/esp-idf that referenced this pull request Dec 1, 2023
Merges espressif#12683

Signed-off-by: Alexey Lapshin <alexey.lapshin@espressif.com>
@MiguelBarro
Copy link
Contributor Author

In order to backport to release/v5.1 note that after the rebase to master some changes disappear because they were already introduced in #12052. That pull request must be backported too.

espressif-bot pushed a commit that referenced this pull request Dec 16, 2023
Merges #12683

Signed-off-by: Alexey Lapshin <alexey.lapshin@espressif.com>
espressif-bot pushed a commit that referenced this pull request Dec 20, 2023
Merges #12683

Signed-off-by: Alexey Lapshin <alexey.lapshin@espressif.com>
@dobairoland dobairoland closed this Jan 2, 2024
espressif-bot pushed a commit that referenced this pull request Jan 29, 2024
Merges #12683

Signed-off-by: Alexey Lapshin <alexey.lapshin@espressif.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Resolution: NA Issue resolution is unavailable Status: Done Issue is done internally
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants