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

Update CMakeLists.txt for better debug info #677

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

JinjieZhao
Copy link

Add -fstandalone-debug to emit full debug info

Add -fstandalone-debug to emit full debug info
@skyzh
Copy link
Member

skyzh commented Jan 8, 2024

do you have any comparison on the debug information produced before and after this option is enabled? i.e., do you see more information in your debugger?

@JinjieZhao
Copy link
Author

Without -fstandalone-debug
p str -> error: summary string parsing error
image
With -fstandalone-debug
image

@skyzh
Copy link
Member

skyzh commented Jan 9, 2024

Hmm. This is weird as the debug info should be already embedded in the executable file? I assume the flag only helps generating some debug symbol files outside the executable.

@JinjieZhao
Copy link
Author

Yes, it is weird.

For gcc, this flag helps generating some debug symbol files outside the executable.
For clang, this flag adds more debug info in the executable. see https://clang.llvm.org/docs/UsersManual.html#controlling-debug-information

@prashanthduvvada
Copy link
Contributor

the '-fstandalone-debug' flag doesn't exist in g++. The g++ does all the prints that clang with '-fstandalone-debug' does by default.

The fix isn't correct. It requires a check if it's g++ or clang.

@prashanthduvvada prashanthduvvada added the bug Something isn't working (correctness). Mark issues with this. label Aug 9, 2024
CMakeLists.txt Outdated
@@ -116,7 +116,7 @@ message("${BUSTUB_SANITIZER} sanitizer will be enabled in debug mode.")
# Compiler flags.
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall -Wextra -Werror")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wno-unused-parameter -Wno-attributes") # TODO: remove
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0 -ggdb -fsanitize=${BUSTUB_SANITIZER} -fno-omit-frame-pointer -fno-optimize-sibling-calls")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0 -ggdb -fsanitize=${BUSTUB_SANITIZER} -fno-omit-frame-pointer -fno-optimize-sibling-calls -fstandalone-debug")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs a check if it's clang compiler or not

JinjieZhao and others added 3 commits August 24, 2024 19:32
Previously, the `-fstandalone-debug` flag was added unconditionally, which caused errors when using GCC. This commit adds a check to ensure the flag is only applied when using the Clang compiler, preventing issues with GCC.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working (correctness). Mark issues with this.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants