-
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.
* c++ify bunch of files * fix tracer env issue (std::string was not available in fork due to `init()` not being called in fork) * some refactoring * making parts optional * add a bit of debug
- Loading branch information
Showing
9 changed files
with
139 additions
and
34 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 |
---|---|---|
@@ -1,18 +1,46 @@ | ||
This is a compiler-explorer fork of the glibc-tools repository, which contains tools and library provided by glibc that | ||
either have been deprectated of moved out from the project. At the time of this fork, it contained only libSegFault. | ||
|
||
Changes to libSegFault: | ||
## Changes to libSegFault | ||
- CMake for building | ||
- Improved stack tracing with [cpptrace](https://github.com/jeremy-rifkin/cpptrace) | ||
|
||
Dependencies: | ||
## Dependencies | ||
|
||
- GCC 11 or higher (or equivalent) | ||
- Cpptrace depends on libdwarf, zlib, zstd, and is configured to use libunwind. | ||
|
||
Contributing: | ||
## Contributing | ||
|
||
To build locally run `make build`. Example usage: | ||
|
||
``` | ||
LD_PRELOAD=$LD_PRELOAD:build/libSegFault.so LIBSEGFAULT_TRACER=build/tracer ./some_program | ||
``` | ||
|
||
## Environment variables | ||
|
||
### Required | ||
|
||
* LIBSEGFAULT_TRACER | ||
- Full path to the `tracer` program | ||
|
||
### Optional | ||
|
||
* SEGFAULT_SIGNALS="..." | ||
- Space separated list of signals to listen to | ||
- Supported values are: segv, ill, abrt, fpe, bus, stkflt, all | ||
|
||
* LIBSEGFAULT_REGISTERS=1 | ||
- Include the state of all the registers | ||
|
||
* LIBSEGFAULT_MEMORY=1 | ||
- Include a memory map | ||
|
||
* LIBSEGFAULT_DEBUG=1 | ||
- For situations when libSegFault doesn't work as expected | ||
|
||
### Deprecated / Should not use | ||
|
||
* SEGFAULT_USE_ALTSTACK | ||
* SEGFAULT_OUTPUT_NAME |
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,51 @@ | ||
#include <cstdlib> | ||
#include <cstring> | ||
|
||
const char *getTracerProgram() | ||
{ | ||
static const char *emptystr = ""; | ||
if (const char *value = getenv("LIBSEGFAULT_TRACER")) | ||
{ | ||
return value; | ||
} | ||
|
||
return emptystr; | ||
} | ||
|
||
bool isDebugMode() | ||
{ | ||
if (const char *value = getenv("LIBSEGFAULT_DEBUG")) | ||
{ | ||
if (strcmp(value, "1") == 0) | ||
return true; | ||
} | ||
|
||
return false; | ||
} | ||
|
||
bool useAlternativeStack() | ||
{ | ||
return getenv("SEGFAULT_USE_ALTSTACK") != 0; | ||
} | ||
|
||
bool dumpRegisters() | ||
{ | ||
if (const char *value = getenv("LIBSEGFAULT_REGISTERS")) | ||
{ | ||
if (strcmp(value, "1") == 0) | ||
return true; | ||
} | ||
|
||
return false; | ||
} | ||
|
||
bool dumpMemory() | ||
{ | ||
if (const char *value = getenv("LIBSEGFAULT_MEMORY")) | ||
{ | ||
if (strcmp(value, "1") == 0) | ||
return true; | ||
} | ||
|
||
return false; | ||
} |
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 @@ | ||
#pragma once | ||
|
||
bool isDebugMode(); | ||
const char *getTracerProgram(); | ||
bool useAlternativeStack(); | ||
bool dumpRegisters(); | ||
bool dumpMemory(); |
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