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

[llvm-symbolizer] Improve output for addresses with no line correspondence #92403

Open
bd1976bris opened this issue May 16, 2024 · 1 comment

Comments

@bd1976bris
Copy link
Collaborator

bd1976bris commented May 16, 2024

My understanding is that the convention for addresses with no line correspondence is to associate them with line 0.

From the DWARF 5 spec section 6.2.2 State Machine Registers from the entry on the meaning of the line register:

An unsigned integer indicating a source line
number. Lines are numbered beginning at 1.
The compiler may emit the value 0 in cases
where an instruction cannot be attributed to any
source line

We should improve the tool behavior for such addresses to avoid confusion to users.

Suggestions for improvement:

1. Print <unknown> rather than line 0 for such addresses:

Current output:

llvm-symbolizer.exe --obj=main.elf 0x0000000000000177
f3
main.c:0:0

Proposed:

llvm-symbolizer.exe --obj=main.elf 0x0000000000000177
f3
main.c:<unknown>
*Warning: no line correspondence for address. Please try a nearby address or use --skip-line-zero(#82240) *

Although, perhaps it isn't even possible to give a reasonable file for such addresses (compiler inlining scenarios etc) - in which case perhaps only printing the function name would be preferable?

2. Do not show context lines:

I noticed that for --print-source-context-lines for line zero addresses you currently get very confusing output where the lines around line zero are displayed:

Current output:

llvm-symbolizer.exe 0x0000000000000156 --obj=main.elf --print-source-context-lines=3
f3
main.c:0:0
1 : static int gvar1 = 0;
2 : static int gvar2 = 0;
3 : static int gvar3 = 0;

Proposed:

llvm-symbolizer.exe 0x0000000000000156 --obj=main.elf --print-source-context-lines=3
f3
main.c:<unknown>
*Warning: no line correspondence for address so no context displayed. Please try a nearby address or use --skip-line-zero(#82240) *

Other notes:

@llvmbot
Copy link
Collaborator

llvmbot commented May 16, 2024

@llvm/issue-subscribers-tools-llvm-symbolizer

Author: bd1976bris (bd1976bris)

My understanding is that the convention for addresses with no line correspondence is to associate them with line 0.

We should improve the tool behavior for such addresses to avoid confusion to users.

Suggestions for improvement:

1. Print &lt;unknown&gt; rather than line 0 for such addresses:

Current output:
>llvm-symbolizer.exe --obj=main.elf 0x0000000000000177
f3
main.c:0:0

Proposed:
>llvm-symbolizer.exe --obj=main.elf 0x0000000000000177
f3
main.c:&lt;unknown&gt;
*Warning: no line correspondence for address. Please try a nearby address or use --skip-line-zero(#82240) *

Although, perhaps it isn't even possible to give a reasonable file for such addresses (compiler inlining scenarios etc) - in which case perhaps only printing the function name would be preferable?

2. Do not show context lines:

I noticed that for --print-source-context-lines for line zero addresses you currently get very confusing output where the lines around line zero are displayed:

Current output:
>llvm-symbolizer.exe 0x0000000000000156 --obj=main.elf --print-source-context-lines=3
f3
main.c:0:0
1 : static int gvar1 = 0;
2 : static int gvar2 = 0;
3 : static int gvar3 = 0;

Proposed:
>llvm-symbolizer.exe 0x0000000000000156 --obj=main.elf --print-source-context-lines=3
f3
main.c:&lt;unknown&gt;
*Warning: no line correspondence for address so no context displayed. Please try a nearby address or use --skip-line-zero(#82240) *

Other notes:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants