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

Backtrace for shared libraries: difference between elf and pecoff #53

Open
krlmlr opened this issue Sep 9, 2020 · 2 comments
Open

Backtrace for shared libraries: difference between elf and pecoff #53

krlmlr opened this issue Sep 9, 2020 · 2 comments

Comments

@krlmlr
Copy link

@krlmlr krlmlr commented Sep 9, 2020

In my use case, I don't care about symbols/debug info in the main executable, only for the shared libraries loaded during run time. Everything works fine on Linux x64, which I believe uses elf.c. On MSYS, with pecoff.c, I only get symbols/debug info for the module that I pass as the filename argument to backtrace_create_state(). (I can pass the path to a shared library to backtrace_create_state(), and the file+line information is extracted from there but not from the other shared libraries loaded from the process.)

Could you please shed some light on the difference in the observed behavior? Does elf.c iterate over all loaded libraries, and pecoff.c not? What's the best way to resolve this?

@krlmlr
Copy link
Author

@krlmlr krlmlr commented Sep 9, 2020

Reading backtrace_initialize() in elf.c, indeed it uses dl_iterate_phdr() to iterate over all open libraries. It has done so since the beginning, I can't find anything similar in pecoff.c .

I understand that enumerating libraries and address spaces is difficult to do in a portable way, and that dl_iterate_phdr() is not available on MSYS. To achieve this, I have wrapped code from gperftools in https://github.com/r-prof/procmaps/, the main logic is in sysinfo.cc.

Is there a better way to portably enumerate loaded libraries and address spaces? Would you support this functionality in libbacktrace?

@ianlancetaylor
Copy link
Owner

@ianlancetaylor ianlancetaylor commented Sep 15, 2020

I think it would be reason for the the libbacktrace pecoff.c file to call CreateToolhelp32Snapshot on Windows.

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

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.