-
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.
* feat: enable backward-cpp * fix BINDIR for different compilation modes in elfutils
- Loading branch information
Showing
9 changed files
with
282 additions
and
12 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
exports_files(["backward.cc"]) | ||
|
||
cc_binary( | ||
name = "suicide", | ||
srcs = ["suicide.cc"], | ||
deps = ["@backward-cpp"], | ||
) | ||
|
||
exports_files(["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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
cc_library( | ||
name = "backward-cpp", | ||
include_prefix = "backward", | ||
srcs = ["@//third_party/backward-cpp:backward.cpp"], | ||
hdrs = ["backward.hpp"], | ||
deps = [ | ||
"@//third_party:libdwarf", | ||
"@elfutils//:elf", | ||
"@//third_party:libunwind", | ||
], | ||
visibility = ["//visibility:public"], | ||
# Link any binary that depends (directly or indirectly) on this C++ library | ||
# in all the object files for the files listed in srcs, even if some contain | ||
# no symbols referenced by the binary. | ||
# Without this the backward.cpp file won't be included and then won't | ||
# initialize | ||
alwayslink = True, | ||
defines = [ | ||
# For libdwarf | ||
"BACKWARD_HAS_DWARF=1", | ||
# For libunwind | ||
"BACKWARD_HAS_LIBUNWIND=1", | ||
], | ||
) |
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,7 @@ | ||
#include "backward.hpp" | ||
|
||
namespace backward { | ||
|
||
backward::SignalHandling sh; | ||
|
||
} // namespace backward |
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,11 @@ | ||
#include <iostream> | ||
|
||
/** | ||
* Obvious suicide function to test stacktrace printing of backward-cpp | ||
*/ | ||
int main() { | ||
std::cout << "Running suicide application" << std::endl; | ||
int* ptr = nullptr; | ||
*ptr += 1; | ||
return 0; | ||
} |
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,65 @@ | ||
LIBELF_HDRS = glob(["libelf/elf32_*.c"]) + [ | ||
"lib/crc32.c", | ||
"lib/next_prime.c", | ||
"libelf/elf.h", | ||
"libelf/gelf.h", | ||
"libelf/libelf.h", | ||
] | ||
|
||
cc_library( | ||
name = "elf", | ||
srcs = glob([ | ||
"libelf/*.c", | ||
]) + [ | ||
"config.h", | ||
"lib/eu-config.h", | ||
"lib/fixedsizehash.h", | ||
"lib/system.h", | ||
"libelf/abstract.h", | ||
"libelf/chdr_xlate.h", | ||
"libelf/common.h", | ||
"libelf/dl-hash.h", | ||
"libelf/elf-knowledge.h", | ||
"libelf/exttypes.h", | ||
"libelf/gelf_xlate.h", | ||
"libelf/gnuhash_xlate.h", | ||
"libelf/libelfP.h", | ||
"libelf/nlist.h", | ||
"libelf/note_xlate.h", | ||
"libelf/version_xlate.h", | ||
], | ||
hdrs = LIBELF_HDRS, | ||
copts = [ | ||
"-Iexternal/elfutils/libelf", | ||
"-Iexternal/elfutils/lib", | ||
"-I$(BINDIR)/external/elfutils", | ||
"-DHAVE_CONFIG_H", | ||
# Disable all warnings | ||
"-w", | ||
], | ||
visibility = ["//visibility:public"], | ||
# Code seems to just include <libelf.h> | ||
includes = ["libelf"], | ||
deps = [ | ||
"@zlib", | ||
], | ||
) | ||
|
||
genrule( | ||
name = "config_h", | ||
srcs = [ | ||
"configure", | ||
"libelf/libelf.h", | ||
"libdw/known-dwarf.h", | ||
"config/config.rpath", | ||
"config/ar-lib", | ||
"config/compile", | ||
"config/config.guess", | ||
"config/config.sub", | ||
"config/missing", | ||
"config/install-sh", | ||
] + glob(["**/*.in"]), | ||
outs = ["config.h"], | ||
cmd = "./$(location configure) --disable-debuginfod --disable-libdebuginfod" + | ||
"&& cp config.h $(location config.h)", | ||
) |
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,41 @@ | ||
cc_library( | ||
name = "libdwarf", | ||
srcs = glob([ | ||
"libdwarf/*.c", | ||
]) + [ | ||
"config.h", | ||
], | ||
hdrs = glob([ | ||
"libdwarf/*.h", | ||
]), | ||
copts = [ | ||
"-Ibazel-out/k8-dbg/bin/external/libdwarf ", | ||
"-DHAVE_CONFIG_H", | ||
], | ||
strip_include_prefix = "libdwarf", | ||
includes = [ | ||
"libdwarf", | ||
], | ||
visibility = ["//visibility:public"], | ||
deps = [ | ||
"@elfutils//:elf", | ||
], | ||
) | ||
|
||
genrule( | ||
name = "config_h", | ||
srcs = [ | ||
"configure", | ||
"install-sh", | ||
"config.guess", | ||
"config.sub", | ||
"configure.ac", | ||
"ltmain.sh", | ||
"ar-lib", | ||
"compile", | ||
"missing", | ||
] + glob(["**/*.in"]), | ||
outs = ["config.h"], | ||
cmd = "./$(location configure) " + | ||
"&& cp config.h $(location config.h)", | ||
) |
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,36 @@ | ||
cc_library( | ||
name = "zlib", | ||
srcs = [ | ||
"adler32.c", | ||
"compress.c", | ||
"crc32.c", | ||
"crc32.h", | ||
"deflate.c", | ||
"deflate.h", | ||
"gzclose.c", | ||
"gzguts.h", | ||
"gzlib.c", | ||
"gzread.c", | ||
"gzwrite.c", | ||
"infback.c", | ||
"inffast.c", | ||
"inffast.h", | ||
"inffixed.h", | ||
"inflate.c", | ||
"inflate.h", | ||
"inftrees.c", | ||
"inftrees.h", | ||
"trees.c", | ||
"trees.h", | ||
"uncompr.c", | ||
"zconf.h", | ||
"zutil.c", | ||
"zutil.h", | ||
], | ||
hdrs = ["zlib.h"], | ||
copts = [ | ||
# Ignore all warnings | ||
"-w", | ||
], | ||
visibility = ["//visibility:public"], | ||
) |