forked from flashlight/flashlight
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Attach backtrace signal handling with fl::init() (flashlight#1132)
Summary: Downstream libs didn't properly initialize signal handling because the backward-cpp signal handler was a static in a C++ file and that could be loaded arbitrarily based on compilation options (static vs shared) and platforms. Move signal handling init into `fl::init()`, which now calls `initLogging()` which conditionally calls `initBackward()` if compiled to not be a noop. Also change the name of the directory from `common/backward` to `common/stacktrace`. Pull Request resolved: flashlight#1132 Test Plan: CI Reviewed By: bwasti Differential Revision: D46824199 Pulled By: jacobkahn fbshipit-source-id: b42efc045ea2528e86d61f2288b4e2d0d2c1863d
- Loading branch information
1 parent
daf3558
commit 7c6736d
Showing
11 changed files
with
82 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/* | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* This source code is licensed under the MIT-style license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
#pragma once | ||
|
||
namespace fl::detail { | ||
|
||
/** | ||
* Initialize stack tracing with backward-cpp. No-op if Flashlight is not built | ||
* with backward-cpp. | ||
*/ | ||
void initBackward(); | ||
|
||
} // namespace fl::detail |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
cmake_minimum_required(VERSION 3.16) | ||
|
||
# backward-cpp | ||
option(FL_USE_BACKWARD_CPP "Build with backward-cpp support" OFF) | ||
if (FL_USE_BACKWARD_CPP) | ||
find_package(Backward CONFIG) | ||
if (NOT Backward_FOUND) | ||
message(STATUS "backward-cpp not found - will download from source.") | ||
include(${PROJECT_SOURCE_DIR}/cmake/BuildBackwardCpp.cmake) | ||
endif() | ||
add_backward(flashlight) # include dirs and compiler defs | ||
# trace demangler libs | ||
set_property(TARGET flashlight APPEND PROPERTY | ||
INTERFACE_LINK_LIBRARIES "${BACKWARD_LIBRARIES}") | ||
endif() | ||
target_sources(flashlight PRIVATE ${CMAKE_CURRENT_LIST_DIR}/Backward.cpp) | ||
target_compile_definitions(flashlight PUBLIC | ||
FL_USE_BACKWARD_CPP=$<BOOL:${FL_USE_BACKWARD_CPP}>) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters