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

--with-debug is ignored? #362

Open
spolakh opened this issue Jun 11, 2021 · 4 comments
Open

--with-debug is ignored? #362

spolakh opened this issue Jun 11, 2021 · 4 comments
Assignees
Labels
help needed This feature/issue is unlikely to be addressed by maintainers. So PR is needed.

Comments

@spolakh
Copy link

spolakh commented Jun 11, 2021

https://github.com/d12frosted/homebrew-emacs-plus/blob/master/Formula/emacs-plus%4028.rb

it doesn't look like the value of this option affects anything?

I'm trying to debug an emacs 100% cpu hang and am trying to run it with gdb to do it. I've brew uninstall emacs-plus@28ed, and then intsalled with brew install emacs-plus@28 --with-debug --with-native-comp, but when I'm trying to run gdb on it (gdb /usr/local/Cellar/emacs-plus@28/28.0.50/Emacs.app/Contents/MacOS/Emacs), I get

GNU gdb (GDB) 10.2
Copyright (C) 2021 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-apple-darwin19.6.0".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from Emacs...
(No debugging symbols found in Emacs)

I suspect that the --with-debug option is ignored

@d12frosted
Copy link
Owner

It is not ignored, and it should be working.

ENV.append "CFLAGS", "-g -Og" if build.with? "debug"

Could you please build verbosely and share output?

@s-m-t
Copy link

s-m-t commented Sep 20, 2023

'brew install emacs-plus@28 --with-debug --keep-tmp'
or
'./build 28 --with-debug --keep-tmp'

The problem is that clang doesn't actually produce the debugging symbols if you separate the compiling and linking stages as emacs does it just keeps references in the executable to the symbols left in the object files. You have to run dsymutil on the emacs executable to go searching for the object files to produce the dSYM bundle. However, brew will delete those object files before you have a chance to run dsymutil because it considers them temporary files so you have to pass '--keep-tmp'.

further reading if you are interested:
https://stackoverflow.com/questions/32297349/why-does-a-2-stage-command-line-build-with-clang-not-generate-a-dsym-directory?rq=3
https://stackoverflow.com/questions/10044697/where-how-
does-apples-gcc-store-dwarf-inside-an-executable/12827463#12827463
https://wiki.dwarfstd.org/Apple%27s_%22Lazy%22_DWARF_Scheme.md

@d12frosted easy fix might be to automatically pass --keep-tmp if --with-debug is selected. Or possibly have the build script run dsymutil automatically

@d12frosted
Copy link
Owner

@s-m-t you can try modifying the following line locally to see if it works:

ENV.append "CFLAGS", "-g -Og" if build.with? "debug"

If that works, let's just pass --keep-tmp and call it a day :)

@d12frosted d12frosted added help needed This feature/issue is unlikely to be addressed by maintainers. So PR is needed. and removed install error labels Aug 25, 2024
@swapneils
Copy link

I think this might be due to not having the .gdbinit file (or .lldbinit file) from the same source code that Emacs was built from.

Is there any way to make that accessible in the installation directory?
(Also not sure whether those files have a dependency on other parts of the source being available for debugging)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help needed This feature/issue is unlikely to be addressed by maintainers. So PR is needed.
Projects
None yet
Development

No branches or pull requests

4 participants