Code Monkey home page Code Monkey logo

libdebugme's People

Contributors

yugr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

libdebugme's Issues

How about this approach?

# 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;
    }
}

gdb terminal input is corrupted

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".

Doesn't compile on recent glibc (Arch Linux)

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.