-
Notifications
You must be signed in to change notification settings - Fork 3k
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
GCC ARM: Increase develop and release debug level #11059
Conversation
This might be platform dependent. I am compiling using the GNU Tools ARM Embedded toolchain on Windows. |
@desowin, thank you for your changes. |
Interesting. So what format is it using by default? I'd assumed it was defaulting to a sensible version of DWARF. If specifying, why not |
I don't know and neither I do not know how to check for sure... I started inspecting the produced elf files (readelf -S target.elf) and noticed that the one compiled with Without this patch I get following:
With this patch, the output is:
DWARF is debugging standard, that can be used also with tools other than gdb. I don't know how the |
Is this maybe related to this? https://stackoverflow.com/questions/32734222/why-does-gdb-7-4-does-not-show-source-info-on-binaries-generated-with-recent-com But you're using a
|
From my reading of the docs, it enables gdb extensions to the base format, which should(TM) be compatible. I think my main point is that we need to understand exactly what this option is changing - what was the format before, what is it after, and why is this change needed and better than any other potential change. |
That's probably a different issue. The source code information is visible without this change. Adding
Yes, the gdb is from the same GNU Tools ARM Embedded package. I am also using also SEGGER Ozone which is standalone 3rd party debugger - and I observe exactly the same difference as in gdb (only when compiled with
I am seeing "Version: 4" both with and without this change. |
You're right, his symptoms don't match, but his observation about missing I believe I have noticed the symptoms you describe - inability to locate global data, but it's never really bothered me enough to track down - I'm usually interested in local variables or members of I think that's what you're seeing, right? It's not seeing structures that's the problem, it's the ability to locate global named variables? (The symbols are there though, which is how pyOCD thread debugging works - it can find the symbol for osRtxInfo, and show the info using its built-in type layout info). Can you work through all the options in the manual pin down an explicit option that produces the same output as |
According to gcc docs, The biggest difference I observe, is that adding |
I'd like to assume that doesn't apply for a cross-compiler, or at least would apply to the target operating system, so should be platform independent. The OS in this case is "none", so that default could be anything. I would like to think there would be some explicit option that produces the same actual binary as '-g' and it isn't producing some particular unique magic. |
Yes, that's the problem.
If pyOCD does have its own knowledge of how osRtxInfo is structured, then yes, it wouldn't need it in the elf file. Without this change, I know where osRtxInfo is located. I cannot access the inidividual fields without knowing from some other source the offsets. With this change, the elf contains all the offsets.
I can give it a shot, but I don't think I'll manage to pinpoint it. |
It was way too hard to go through the options, so I checked the gcc source code. In Note that optional dwarf version parameter is stored in
The The summary is:
I would propose to not use |
Thank you for thorough investigation - I'd totally failed to register that we were passing level values to But what then is the point of actually adding the If I had to guess why not Looking at the history, it was @SeppoTakalo who put the If this is actually working fine on the debug build, as it has |
In #5708 @SeppoTakalo noted:
As my investigation turns out, there is benefit in providing |
The |
@ARMmbed/team-embeddedplanet This conversation is worth it's weight in rhodium. |
@kjbracey-arm Our CI rarely keeps the elf files. Test runs seems to utilise binary files. Did you guys now conclude whether |
Yes, the The choice between If you prefer just |
I don't see that we have any requirement to explicitly specify DWARF, as opposed to accepting the toolchain's default. The normal assumption should be that the default is correct, and it is. By specifying DWARF, we'd potentially make the system perform worse if a later toolchain release changes default format, by locking ourselves into the current behaviour. The only reason I can see for "dwarf" being in the PR is that you found that it fixed the issue without understanding why. I want to just change the |
Do not specify the debug level for develop and release profiles. Instead rely on the compiler to choose sensible default (-g2). Note that -g1 is minimal debugging information and does not include structure definitions which quite heavily reduces debugging experience. For develop and release profiles this results in elf file containing structure definitions. This does not impact debug profile as it already did use -g3 which is the highest debug level. Compatible debuggers (eg. gdb, SEGGER Ozone) can use the extra information to provide better debugging experience. For example, when compiled .elf is loaded in gdb, this change makes it trivial to access internal RTX data. Without this change on develop profile: (gdb) print osRtxInfo.thread.run 'osRtxInfo' has unknown type; cast it to its declared type With this change on develop profile: (gdb) print osRtxInfo.thread.run $1 = {curr = 0x20014F04, next = 0x20014F04}
Test run: SUCCESSSummary: 11 of 11 test jobs passed |
Description
Do not specify the debug level for develop and release profiles. Instead
rely on the compiler to choose sensible default (-g2). Note that -g1 is
minimal debugging information and does not include structure definitions
which quite heavily reduces debugging experience.
For develop and release profiles this results in elf file containing
structure definitions. This does not impact debug profile as it already
did use -g3 which is the highest debug level.
Compatible debuggers (eg. gdb, SEGGER Ozone) can use the extra information
to provide better debugging experience. For example, when compiled .elf is
loaded in gdb, this change makes it trivial to access internal RTX data.
Without this change on develop profile:
(gdb) print osRtxInfo.thread.run
'osRtxInfo' has unknown type; cast it to its declared type
With this change on develop profile:
(gdb) print osRtxInfo.thread.run
$1 = {curr = 0x20014F04, next = 0x20014F04}
Pull request type
Reviewers
Release Notes