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

please add hints to error message "no debug info in Mach-O executable" #122

Closed
bhaible opened this issue May 20, 2024 · 5 comments
Closed

Comments

@bhaible
Copy link

bhaible commented May 20, 2024

The error message

libbacktrace: no debug info in Mach-O executable

gives no clue as to how to fix this issue.

Please change the message to

libbacktrace: no debug info in Mach-O executable. Make sure to use option '-g' and to invoke 'dsymutil'.

Rationale:
I used libbacktrace in a project with Automake, and it produced this error message. I then spent several hours:

  • trying all possible debugging options of the clang compiler,
  • trying a simple program - and in this simple program the stack traces worked.

How to reproduce:
foo.c.gz

It works in one step:

$ clang -g -O2 -I$HOME/include -L$HOME/lib foo.c -lbacktrace
$ ./a.out
Simple stack trace:
0x1002832e7
Full stack trace (requires debug info):
0x100283303 print_trace
        /Users/haible/foo.c:53
0x100283303 dummy_function
        /Users/haible/foo.c:60
0x100283303 main
        /Users/haible/foo.c:72

But it doesn't work in two steps, until a dsymutil invocation has been performed:

$ clang -g -O2 -I$HOME/include foo.c -c && clang -g -O2 -L$HOME/lib foo.o -lbacktrace
$ ./a.out
Simple stack trace:
0x102bf72e7
Full stack trace (requires debug info):
libbacktrace: no debug info in Mach-O executable
$ dsymutil a.out
$ ./a.out
Simple stack trace:
0x100e3b2e7
Full stack trace (requires debug info):
0x100e3b303 print_trace
        /Users/haible/foo.c:53
0x100e3b303 dummy_function
        /Users/haible/foo.c:60
0x100e3b303 main
        /Users/haible/foo.c:72

References:

If the error message had given me a hint to the missing dsymutil invocation, it would have saved me a lot of time.

@ianlancetaylor
Copy link
Owner

The intent is that you should not have to run dsymutil. Something is wrong. However, I don't have access to a MacOS system myself to debug this.

@bhaible
Copy link
Author

bhaible commented May 21, 2024

Something is wrong.

Maybe it's related to the test suite failures that I see on macOS 12? I've now reported them at #123 .

The intent is that you should not have to run dsymutil.

Oh, you mean, libbacktrace is supposed to look at the file names stored in the executable (nm -pa a.out | grep OSO) and read the debugging information found in these files? This approach would only suffice in 1 out of 3 cases.

There are 3 cases:

  • a) The executable is in the build tree, and the .o and .a files are still in the build tree, at their original locations.
  • b) The executable is in the build tree, and the .o and .a files have been moved or deleted.
  • c) The executable has been installed in a public location, and the build tree no longer exists.

In case a), dsymutil is not needed, if libbacktrace reads the debugging information from each of the .o files.

In case b) and c), dsymutil is needed. Therefore, for these cases, it is worth to improve the error message.

In case c) the user needs also to install the executable.dSYM directory; I hope they will understand this when they know about dsymutil.

@cooljeanius
Copy link

Related: GCC bug 97082 and GCC bug 105590

@ianlancetaylor
Copy link
Owner

Thanks, I improved the error messages slightly.

@bhaible
Copy link
Author

bhaible commented Jul 11, 2024

Thank you. I appreciate it.

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

No branches or pull requests

3 participants