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

Allow to use crash handler code from the crashpad library #62

Merged
merged 6 commits into from
May 31, 2024

Conversation

konraddysput
Copy link
Collaborator

@konraddysput konraddysput commented May 28, 2024

Why

Crashpad allows using direct methods like HandlerMain to generate a minidump and send it via Java Crash Handler. Right now, we're including crashpad handler code in the crashpad_handler.so we're unable to call methods like HandlerMain.

This change allows defining a variable that cmake can set to tell where to include handler code.

ref: BT-2852

@konraddysput konraddysput added the enhancement New feature or request label May 28, 2024
@konraddysput konraddysput self-assigned this May 28, 2024
@konraddysput konraddysput requested a review from gm4sl May 28, 2024 13:26
Copy link
Contributor

@gm4sl gm4sl left a comment

Choose a reason for hiding this comment

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

The log message should explain why this change is being made and maybe link to the internal ticket.

target_include_directories(handler PUBLIC ..)
else ()
add_executable(handler main.cc)
set_property(TARGET handler PROPERTY ENABLE_EXPORTS 1)
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't need to specify ENABLE_EXPORTS if a separate target is being generated for the static library.


if (ANDROID)
if (CUSTOM_CRASHPAD_HANDLER_DESTINATION)
Copy link
Contributor

Choose a reason for hiding this comment

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

Should CUSTOM_CRASHPAD_HANDLER_DESTINATION be supported for the static library as well?

target_compile_features(handler PUBLIC cxx_std_17)
target_include_directories(handler PRIVATE ..)
target_link_libraries(handler PRIVATE client tools compat snapshot minidump)
if (HANDLER STREQUAL "INTEGRATED")
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of having the user set a separate, likely hard to find CMake variable, maybe create the static library unconditionally, or maybe conditioned on ANDROID instead, along with a comment explaining how is intended to be used. Something like,

# Used to implement a work-around for launching the Crashpad handler stored in an APK.
if (ANDROID)
    add_library(handlerlib STATIC ${CRASHPAD_HANDLER_LIBRARY_FILES})
    target_compile_features(handlerlib PUBLIC cxx_std_17)
    target_link_libraries(handlerlib PRIVATE client tools compat snapshot minidump)
    target_include_directories(handlerlib PUBLIC ..)
endif(ANDROID)

This would require updating the name used in the backtrace-android commit:

target_link_libraries(backtrace-native handlerlib)

handler/CMakeLists.txt Show resolved Hide resolved
COMMAND ${CMAKE_COMMAND} -E copy
$<TARGET_FILE:handler>
${CUSTOM_CRASHPAD_HANDLER_DESTINATION}
COMMAND ${CMAKE_COMMAND} -E copy
Copy link
Contributor

Choose a reason for hiding this comment

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

(nit) These changes seem unnecessary in this PR.

@konraddysput konraddysput merged commit d3f854b into backtrace May 31, 2024
15 checks passed
@konraddysput konraddysput deleted the feature/integrated-crash-handler branch May 31, 2024 15:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants