What's the "discriminator" in addr2line?
Asked Answered
R

2

27

When running addr2line in some programs, I get a "discriminator N" comment at the end of the line:

main at /tmp/nsievebits.c:56 (discriminator 3)

The man page doesn't mention it, and a quick Google search seems to indicate mostly source code files, with no clear explanation. Is it some intentionally undocumented feature? More importantly, should I worry about it at all?

Righthander answered 17/1, 2013 at 14:8 Comment(0)
A
25

As far as I understand, discriminator can be useful when there are more than one code path on a single line, see more there (or, alternatively, there if the link is broken). You can safely ignore those, but if one knows how to read them, they can give you very precise information about where exactly the stack points to.

Algar answered 27/6, 2013 at 19:33 Comment(3)
A database error prevents me from accessing this resource. Do you have another link maybe?Swimming
@Swimming and anyone else: here's an archive link web.archive.org/web/20230408145136/https://wiki.dwarfstd.org/… "The compiler needs to be enhanced to provide the additional discriminator parameter in .loc pseudo-ops at each point where a new basic block begins following a conditional transfer of control for the same source line. The first block should have a discriminator of zero, and each conditional transfer of control within the source line should increment the discriminator by 1."Fenn
@Fenn Thanks for the link and the notice, added the archive link tooAlgar
F
0

A trusted programmer tells me "discriminator n is an artifact of Link Time Optimization, and is unrelated to source"

Fenn answered 26/3 at 17:31 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.