Page MenuHomeFreeBSD

Added ranges to Addr2line
ClosedPublic

Authored by tig_freebsdfoundation.org on Feb 4 2020, 3:47 PM.
Tags
None
Referenced Files
Unknown Object (File)
Feb 11 2024, 8:53 AM
Unknown Object (File)
Jan 30 2024, 9:22 PM
Unknown Object (File)
Jan 30 2024, 9:22 PM
Unknown Object (File)
Jan 30 2024, 9:22 PM
Unknown Object (File)
Jan 30 2024, 9:19 PM
Unknown Object (File)
Jan 30 2024, 9:19 PM
Unknown Object (File)
Jan 30 2024, 9:19 PM
Unknown Object (File)
Jan 30 2024, 9:19 PM

Details

Summary

Applied a patch that adds ranges support when the addresses of a CU is several discontinuous blocks.
Link to PR: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=217736
Link to previous patch: https://sourceforge.net/p/elftoolchain/tickets/545/#6d97

Test Plan

Tested against 10000 random addresses in the .so file provided by the patch contributor. Output is the same as GNU addr2line.

Diff Detail

Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

Can you add a link to the PR/patch submission in here?

contrib/elftoolchain/addr2line/addr2line.c
431

Indentation should be by four spaces.

439

The indentation here looks wrong.

500

This duplicates the block above, please try to merge them.

In your testing, did you try passing -f or -i?

I have one general comment. I'm not a big fan of curlopc, I think it makes the code rather confusing. It's an optimization for the sorted case, but I'm not sure how much it actually helps. Can you provide some quick benchmark numbers to justify it? I also note that if the input is reverse-sorted, i.e., high addresses come first, then the curlopc optimization could make things slightly worse.

contrib/elftoolchain/addr2line/addr2line.c
451

It looks like we do not do anything with off. Do we need it at all?

461

Uneeded parens.

485

break here?

  1. I fixed the issues mentioned in the code comments.
  2. I tested the performance with curlopc and with resetting cu to first cu every time(v2), below is the results:

image.png (461×608 px, 48 KB)

r=reverse
seq=sequential
rand=random
v1 is addr2line with curlopc
v2 is the version that resets cu to first cu for every translation
10000seq stores 10k sorted addr of first 20k kernel addr.
1000rand stores 1k rand addr in all of kernel addr
r10000seq is 10000seq reversed
Which version should I keep?

  1. I didn't test with -f -i before. And having tested it just now I realized the output between the old version and my patch looks different. I'm looking into it now.

-f and -i flag outputs are now the same as original.
collect_func() needs gdb to get function name, so I added a field a CU to store this info in the cache.

  1. I tested the performance with curlopc and with resetting cu to first cu every time(v2), below is the results:

image.png (461×608 px, 48 KB)

r=reverse
seq=sequential
rand=random
v1 is addr2line with curlopc
v2 is the version that resets cu to first cu for every translation
10000seq stores 10k sorted addr of first 20k kernel addr.
1000rand stores 1k rand addr in all of kernel addr
r10000seq is 10000seq reversed
Which version should I keep?

Ok. I am surprised that the difference is so substantial, and that curlopc helps even with reverse-sorted input. I think it is fine to keep it as-is then. I would still like to have a cleaner way to maintain a CU iterator, but I don't have any good suggestions at the moment.

contrib/elftoolchain/addr2line/addr2line.c
415

I think a short comment explaining what this function does would be appropriate.

I added in line 482

if (lopc == curlopc)
				return (DW_DLV_ERROR);

for the case when DW_AT_Range is present so the program stops when we can't find an address.

This revision is now accepted and ready to land.Feb 12 2020, 9:24 PM
This revision was automatically updated to reflect the committed changes.