yugr / libdebugme Goto Github PK
View Code? Open in Web Editor NEWAutomatically spawn gdb on error.
License: ISC License
Automatically spawn gdb on error.
License: ISC License
# include <unistd.h>
# include <signal.h>
# include <string.h>
# include <stdlib.h>
static int fds[2];
static void sgsgvhndlr (int signr)
{
write (fds[1], &signr, 1);
_Exit (EXIT_FAILURE);
}
static int err (int exit_code, char *msg)
{
write (STDERR_FILENO, msg, strlen (msg));
write (STDERR_FILENO, "\n", 1);
_Exit (EXIT_FAILURE);
}
int main (void)
{
int rc;
pid_t pid;
rc = pipe (fds);
if (rc != 0) err (EXIT_FAILURE, "pipe");
pid = fork ();
if (pid == -1) err (EXIT_FAILURE, "fork");
if (pid) {
rc = read (fds[0], &pid, 1);
if (rc - 1) err (EXIT_FAILURE, "read");
write (STDOUT_FILENO, "gdb\n", 4);
/* execute gdb */
return EXIT_SUCCESS;
}
else {
struct sigaction sa = {0,};
sa.sa_handler = sgsgvhndlr;
rc = sigaction (SIGSEGV, &sa, NULL);
if (rc) err (EXIT_SUCCESS, "sigaction");
return *(char*)0;
}
}
Handy utility, but cannot seem to enter a command in the gdb prompt.
(gdb) backtrace
Undefined command: "aa". Try "help".
(gdb) backtrace
Undefined command: "crcacegob". Try "help".
glibc 2.32 removed the sys_siglist variable which this project uses to lookup signal names. This results in the following build error on recent Linux distros:
src/debugme.c: In function ‘debugme_install_sighandlers’:
src/debugme.c:49:27: error: ‘sys_siglist’ undeclared (first use in this function)
49 | const char *signame = sys_siglist[sig];
| ^~~~~~~~~~~
I'm not familiar with this issue, but it seems the same issue was reported in another project at greenbone/gvmd#1279 and fixed in greenbone/gvmd#1280 (replace sys_siglist[sig]
with strsignal(sig)
). The documentation for the removal of sys_siglist
is in the glibc 2.32 release notes (2020-08).
I'll file a PR to fix this issue soon.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.