-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move symbolizer to folly/debugging/symbolizer
Summary: The following targets were moved to folly/debugging/symbolizer: ``` //folly/experimental/symbolizer:dwarf //folly/experimental/symbolizer:elf //folly/experimental/symbolizer:symbolized_frame //folly/experimental/symbolizer:line_reader //folly/experimental/symbolizer:stack_trace //folly/experimental/symbolizer:elf_cache //folly/experimental/symbolizer:symbolize_printer //folly/experimental/symbolizer:symbolizer //folly/experimental/symbolizer:signal_handler ``` `arc f` was applied This is a codemod. It was automatically generated and will be landed once it is approved and tests are passing in sandcastle. You have been added as a reviewer by Sentinel or Butterfly. p:mesymk.folly Differential Revision: D59254804 fbshipit-source-id: e73a726a48269e17276b3e5031537d1f64d989ba
- Loading branch information
1 parent
5f051d6
commit 7654c3d
Showing
43 changed files
with
2,530 additions
and
2,194 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,209 @@ | ||
load("@fbcode_macros//build_defs:cpp_library.bzl", "cpp_library") | ||
|
||
oncall("fbcode_entropy_wardens_folly") | ||
|
||
cpp_library( | ||
# @autodeps-skip | ||
name = "dwarf", | ||
srcs = [ | ||
"Dwarf.cpp", | ||
"DwarfImpl.cpp", | ||
"DwarfLineNumberVM.cpp", | ||
"DwarfSection.cpp", | ||
"DwarfUtil.cpp", | ||
], | ||
headers = [ | ||
"Dwarf.h", | ||
"DwarfImpl.h", | ||
"DwarfLineNumberVM.h", | ||
"DwarfSection.h", | ||
"DwarfUtil.h", | ||
], | ||
deps = [ | ||
"//folly:optional", | ||
"//folly/lang:safe_assert", | ||
"//folly/portability:config", | ||
"//folly/portability:unistd", | ||
], | ||
exported_deps = [ | ||
"fbsource//third-party/libdwarf:dwarf", | ||
"//folly:function", | ||
"//folly:range", | ||
"//folly/experimental/symbolizer:elf", | ||
"//folly/experimental/symbolizer:elf_cache", | ||
"//folly/experimental/symbolizer:symbolized_frame", | ||
], | ||
external_deps = [ | ||
"glog", | ||
], | ||
) | ||
|
||
cpp_library( | ||
name = "elf", | ||
srcs = [ | ||
"Elf.cpp", | ||
], | ||
headers = [ | ||
"Elf.h", | ||
"Elf-inl.h", | ||
], | ||
deps = [ | ||
"//folly:exception", | ||
"//folly:scope_guard", | ||
"//folly/lang:c_string", | ||
"//folly/portability:sys_mman", | ||
], | ||
exported_deps = [ | ||
"//folly:conv", | ||
"//folly:likely", | ||
"//folly:range", | ||
"//folly/lang:safe_assert", | ||
"//folly/portability:config", | ||
], | ||
external_deps = [ | ||
"glog", | ||
], | ||
) | ||
|
||
cpp_library( | ||
name = "symbolized_frame", | ||
srcs = ["SymbolizedFrame.cpp"], | ||
headers = ["SymbolizedFrame.h"], | ||
exported_deps = [ | ||
"//folly:range", | ||
], | ||
) | ||
|
||
cpp_library( | ||
name = "line_reader", | ||
srcs = ["LineReader.cpp"], | ||
headers = ["LineReader.h"], | ||
deps = [ | ||
"//folly:file_util", | ||
], | ||
exported_deps = [ | ||
"//folly:range", | ||
], | ||
) | ||
|
||
cpp_library( | ||
name = "stack_trace", | ||
srcs = ["StackTrace.cpp"], | ||
headers = ["StackTrace.h"], | ||
deps = [ | ||
"//folly:cpp_attributes", | ||
"//folly:portability", | ||
"//folly/portability:config", | ||
"//folly/portability:libunwind", | ||
"//folly/tracing:async_stack", | ||
], | ||
exported_deps = [ | ||
"//folly/portability:sys_types", | ||
], | ||
) | ||
|
||
cpp_library( | ||
name = "elf_cache", | ||
srcs = [ | ||
"ElfCache.cpp", | ||
], | ||
headers = [ | ||
"ElfCache.h", | ||
], | ||
deps = [ | ||
"//folly:scope_guard", | ||
"//folly/portability:sys_mman", | ||
], | ||
exported_deps = [ | ||
"//folly:optional", | ||
"//folly:range", | ||
"//folly/experimental/symbolizer:elf", | ||
"//folly/hash:hash", | ||
"//folly/memory:reentrant_allocator", | ||
"//folly/portability:config", | ||
], | ||
exported_external_deps = [ | ||
"boost", | ||
], | ||
) | ||
|
||
cpp_library( | ||
name = "symbolize_printer", | ||
srcs = [ | ||
"SymbolizePrinter.cpp", | ||
], | ||
headers = [ | ||
"SymbolizePrinter.h", | ||
], | ||
deps = [ | ||
"//folly:demangle", | ||
"//folly:file_util", | ||
"//folly:scope_guard", | ||
"//folly/io:iobuf", | ||
"//folly/lang:to_ascii", | ||
], | ||
exported_deps = [ | ||
"//folly:fbstring", | ||
"//folly:range", | ||
"//folly/experimental/symbolizer:symbolized_frame", | ||
], | ||
) | ||
|
||
cpp_library( | ||
name = "symbolizer", | ||
srcs = [ | ||
"Symbolizer.cpp", | ||
], | ||
headers = [ | ||
"Symbolizer.h", | ||
], | ||
deps = [ | ||
"//folly:file_util", | ||
"//folly:memory", | ||
"//folly:scope_guard", | ||
"//folly:synchronized", | ||
"//folly/container:evicting_cache_map", | ||
"//folly/experimental/symbolizer:elf", | ||
"//folly/experimental/symbolizer:line_reader", | ||
"//folly/experimental/symbolizer/detail:debug", | ||
"//folly/lang:safe_assert", | ||
"//folly/lang:to_ascii", | ||
"//folly/memory:sanitize_address", | ||
"//folly/portability:sys_mman", | ||
"//folly/tracing:async_stack", | ||
], | ||
exported_deps = [ | ||
"//folly:fbstring", | ||
"//folly:optional", | ||
"//folly:range", | ||
"//folly:string", | ||
"//folly/experimental/symbolizer:dwarf", | ||
"//folly/experimental/symbolizer:elf_cache", | ||
"//folly/experimental/symbolizer:stack_trace", | ||
"//folly/experimental/symbolizer:symbolize_printer", | ||
"//folly/experimental/symbolizer:symbolized_frame", | ||
"//folly/io:iobuf", | ||
"//folly/portability:config", | ||
"//folly/portability:unistd", | ||
], | ||
) | ||
|
||
cpp_library( | ||
name = "signal_handler", | ||
srcs = [ | ||
"SignalHandler.cpp", | ||
], | ||
headers = [ | ||
"SignalHandler.h", | ||
], | ||
deps = [ | ||
"//folly:scope_guard", | ||
"//folly/experimental/symbolizer:symbolizer", | ||
"//folly/lang:to_ascii", | ||
"//folly/portability:sys_syscall", | ||
"//folly/portability:unistd", | ||
], | ||
external_deps = [ | ||
"glog", | ||
], | ||
) |
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,87 @@ | ||
/* | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
// DWARF record parser | ||
|
||
#pragma once | ||
|
||
#include <folly/Function.h> | ||
#include <folly/Range.h> | ||
#include <folly/debugging/symbolizer/DwarfUtil.h> | ||
#include <folly/experimental/symbolizer/Elf.h> | ||
#include <folly/experimental/symbolizer/ElfCache.h> | ||
#include <folly/experimental/symbolizer/SymbolizedFrame.h> | ||
|
||
namespace folly { | ||
namespace symbolizer { | ||
|
||
#if FOLLY_HAVE_DWARF && FOLLY_HAVE_ELF | ||
|
||
/** | ||
* DWARF record parser. | ||
* | ||
* We only implement enough DWARF functionality to convert from PC address | ||
* to file and line number information. | ||
* | ||
* This means (although they're not part of the public API of this class), we | ||
* can parse Debug Information Entries (DIEs), abbreviations, attributes (of | ||
* all forms), and we can interpret bytecode for the line number VM. | ||
* | ||
* We can interpret DWARF records of version 2, 3, or 4, although we don't | ||
* actually support many of the version 4 features (such as VLIW, multiple | ||
* operations per instruction) | ||
* | ||
* Note that the DWARF record parser does not allocate heap memory at all. | ||
* This is on purpose: you can use the parser from | ||
* memory-constrained situations (such as an exception handler for | ||
* std::out_of_memory) If it weren't for this requirement, some things would | ||
* be much simpler: the Path class would be unnecessary and would be replaced | ||
* with a std::string; the list of file names in the line number VM would be | ||
* kept as a vector of strings instead of re-executing the program to look for | ||
* DW_LNE_define_file instructions, etc. | ||
*/ | ||
class Dwarf { | ||
/** | ||
* Note that Dwarf uses (and returns) StringPiece a lot. | ||
* The StringPieces point within sections in the ELF file, and so will | ||
* be live for as long as the passed-in ElfFile is live. | ||
*/ | ||
public: | ||
/** Create a DWARF parser around an ELF file. */ | ||
Dwarf(ElfCacheBase* elfCache, const ElfFile* elf); | ||
|
||
/** | ||
* Find the file and line number information corresponding to address. | ||
* If `eachParameterName` is provided, the callback will be invoked once | ||
* for each parameter of the function. | ||
*/ | ||
bool findAddress( | ||
uintptr_t address, | ||
LocationInfoMode mode, | ||
SymbolizedFrame& frame, | ||
folly::Range<SymbolizedFrame*> inlineFrames = {}, | ||
folly::FunctionRef<void(const folly::StringPiece name)> | ||
eachParameterName = {}) const; | ||
|
||
private: | ||
ElfCacheBase* elfCache_; | ||
DebugSections defaultDebugSections_; | ||
}; | ||
|
||
#endif | ||
|
||
} // namespace symbolizer | ||
} // namespace folly |
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
Oops, something went wrong.