crash handling

Estaba yo preguntándome esta tarde si sería posible lanzar de forma automática gdb cuando un programa cascara, sin necesidad de ponerse a depurar después, reproducir el bug, etc, al estilo del manejador de errores que instala Visual Studio en Windows que pregunta si se desea depurar la aplicación.

Me ha salido algo como esto (HTML horrible para el coloreado de sintaxis patrocinado por Vim):

#include <sys/types.h>
#include <unistd.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>

void attach_gdb(int signum)
    pid_t gdbpid;
    pid_t debuggee_pid = getpid();
    int gdb_exit_status;
    char pidbuf[100];
    char exebuf[100]; // should be safe unless PIDs reach ~90 digits ;P
    sprintf(pidbuf, "%d", debuggee_pid);
    sprintf(exebuf, "/proc/%d/exe", debuggee_pid);
    printf("Signal %d received. Attaching GDB to process. PID=%d\n", signum, debuggee_pid);

    if ((gdbpid = fork()) == 0)
        execlp("gdb", "gdb", exebuf, pidbuf, NULL);

    waitpid(gdbpid, &gdb_exit_status, 0); // hold on, we want to be debugged

void __attribute__((constructor)) setup_handler()
    struct sigaction sa, old_sa;
    sa.sa_handler = attach_gdb;
    // Register the handler for all actions which dump core by default
    sigaction(SIGSEGV, &sa, &old_sa);
    sigaction(SIGFPE, &sa, &old_sa);
    sigaction(SIGABRT, &sa, &old_sa);
    sigaction(SIGILL, &sa, &old_sa);
    sigaction(SIGQUIT, &sa, &old_sa);

Si se compila como librería dinámica y se enlaza a cualquiera de nuestros programas (o se precarga con LD_PRELOAD) lanza un gdb asociado al proceso al recibir cualquiera de las señales que causarían un core dump y terminación del programa :D.

¿Alguna idea para mejorarlo y que sea práctico? ¿Existe ya algo asi en un paquete Debian que hace mil cosas molonas más? (seguro que sí XD).

1 Comment »

  1. said,

    May 21, 2017 @ 23:39 pm

    Good post! We will be linking to this great post on our website.
    Keep up the good writing.

  2. replica watches said,

    May 22, 2017 @ 01:47 am

    I do consider all the ideas you’ve presented on your post. They are really convincing and can definitely work. Still, the posts are very quick for starters. May just you please lengthen them a bit from next time? Thank you for the post.

  3. ralph lauren said,

    May 22, 2017 @ 01:48 am

    You are my intake, I possess few blogs and rarely run out from post :). “No opera plot can be sensible, for people do not sing when they are feeling sensible.” by W. H. Auden.

  4. Raymon said,

    May 22, 2017 @ 02:08 am

    Good day! Do you use Twitter? I’d like to follow you if that would be okay.

    I’m undoubtedly enjoying your blog and look forward to new updates.

  5. Shelia said,

    May 22, 2017 @ 03:09 am

    Right here is the right webpage for anyone who wants to
    find out about this topic. You understand a whole lot its almost tough to argue with you (not that I
    really will need to…HaHa). You definitely put a new spin on a topic
    that’s been discussed for ages. Excellent stuff, just great!

  6. minecraft pe maps download said,

    May 22, 2017 @ 03:14 am

    Hello there! This post couldn’t be written any better!
    Reading through this post reminds me of my previous room mate!
    He always kept talking about this. I will forward this post to him.
    Fairly certain he will have a good read. Thanks for sharing!

  7. best broadband and tv deals said,

    May 22, 2017 @ 05:25 am

    I don’t even know how I ended up here, but I thought this post was great.

    I don’t know who you are but definitely you’re going to a famous
    blogger if you aren’t already ;) Cheers!

  8. nhl jerseys said,

    May 22, 2017 @ 07:04 am

    Very interesting subject , regards for putting up. “The friendship that can cease has never been real.” by Saint Jerome.

  9. michael kors outlet clearance said,

    May 22, 2017 @ 07:04 am

    I conceive this web site holds some really excellent information for everyone :D. “The ground that a good man treads is hallowed.” by Johann von Goethe.

  10. cheapest broadband uk said,

    May 22, 2017 @ 11:01 am

    Way cool! Some very valid points! I appreciate you writing this article and also the rest of the site is also very

  11. minecraft maps download said,

    May 22, 2017 @ 13:11 pm

    Hello there! Do you know if they make any plugins to protect against hackers?

    I’m kinda paranoid about losing everything I’ve worked hard
    on. Any tips?

  12. said,

    May 22, 2017 @ 14:30 pm

    Everyone loves what you guys tend to be up too. This sort of clever work and exposure!
    Keep up the great works guys I’ve incorporated you
    guys to my blogroll.

  13. Selma said,

    May 22, 2017 @ 17:06 pm

    I’ve learn some good stuff here. Definitely worth bookmarking for revisiting.

    I wonder how much attempt you set to make one of these great informative web site.

  14. coach outlet said,

    May 22, 2017 @ 23:25 pm

    Nice read, I just passed this onto a colleague who was doing some research on that. And he just bought me lunch as I found it for him smile So let me rephrase that: Thank you for lunch! “We know what happens to people who stay in the middle of the road. They get run over.” by Ambrose Gwinett Bierce.

  15. family court determines said,

    May 23, 2017 @ 03:56 am

    Good day I am so delighted I found your webpage, I really found you by
    error, while I was researching on Askjeeve for something else, Anyways I am here now and would just like to say thank you
    for a fantastic post and a all round interesting blog (I also love the theme/design), I don’t have time to read it all at the
    moment but I have book-marked it and also added in your RSS feeds, so when I have time I will be back
    to read more, Please do keep up the excellent jo.

  16. travel to canada said,

    May 23, 2017 @ 16:32 pm

    Definitely believe that which you said. Your favorite reason appeared
    to be on the web the simplest thing to be aware of.

    I say to you, I certainly get annoyed while
    people think about worries that they plainly do not know about.

    You managed to hit the nail upon the top as well as defined
    out the whole thing without having side effect , people could take
    a signal. Will probably be back to get more. Thanks

  17. said,

    May 23, 2017 @ 21:34 pm

    Thanks for sharing your thoughts about court determines.


  18. Chelsea Wallace said,

    May 24, 2017 @ 00:43 am

    This is a comment to the Nightly build » crash handling webmaster. Your website is missing out on at least 300 visitors per day. Our traffic system will dramatically increase your traffic to your website: – We offer 500 free targeted visitors during our free trial period and we offer up to 30,000 targeted visitors per month. Hope this helps :) Unsubscribe here:

  19. said,

    May 24, 2017 @ 04:30 am

    Fantastic site. Lots of helpful info here.

    I’m sending it to several friends ans also sharing in delicious.
    And of course, thank you in your sweat!

  20. BillieInole said,

    May 24, 2017 @ 10:35 am

    Employees within this field have diverse job possibilities and task roles offered to them. 1. PCAis care for the cleanliness, workout, medicine and interaction – amongst other things – of these sufferers, and enjoy a crucial position within their everyday well being. Secretary in Nursing- For those seeking function within a nursing home or aged care service, Co-Workers in Medical work as a member of the nursing crew, supporting nurses and encouraging aged patients in their actions of everyday living. Homecare secretary- home-care personnel enjoy a crucial purpose for the aged or ill who demand help and guidance but do not desire to transfer to a lasting nursing home center. The services they provide may transfer beyond the administration of medicine and other medical attention and include help with usual home duties, daily activities and interpersonal interaction. 4. Area assistance workers play an integrated position for making the elderly or ill involved and productive group people. Agedcare education is contained in many agedcare classes, to give learners the knowledge essential to create a constructive and important difference while in the lifestyles of elderly people. A very important thing about aged care classes may be the individual pleasure it provides.
    best original custom paper writing service
    how do i write a book report
    15% off – best research paper writing service

  21. amazing vacation said,

    May 24, 2017 @ 13:09 pm

    Excellent beat ! I wish to apprentice at the same time as you amend your website, how can i subscribe for
    a blog website? The account helped me a applicable deal. I were tiny bit familiar of this your broadcast provided vibrant
    transparent idea

  22. Luther said,

    May 24, 2017 @ 14:08 pm

    If you would like to obtain a great deal from this paragraph then you
    have to apply such techniques to your won blog.

  23. said,

    May 24, 2017 @ 14:42 pm

    Right now it seems like BlogEngine is the preferred blogging platform out there right now.
    (from what I’ve read) Is that what you are using on your blog?

  24. Annis said,

    May 24, 2017 @ 14:49 pm

    I like the helpful info you provide in your articles.
    I will bookmark your blog and check again here regularly.
    I’m quite sure I’ll learn many new stuff right here!
    Good luck for the next!

  25. said,

    May 24, 2017 @ 20:34 pm

    Greetings! Very useful advice within this article! It is the little
    changes that make the biggest changes. Thanks a lot for sharing!

  26. said,

    May 25, 2017 @ 01:39 am

    This design is incredible! You most certainly know how
    to keep a reader entertained. Between your wit and your videos, I was almost moved to
    start my own blog (well, almost…HaHa!) Excellent
    job. I really loved what you had to say, and more than that, how you presented it.
    Too cool!

  27. Silvia Odete Morani Massad said,

    May 25, 2017 @ 04:48 am

    Wow, this paragraph is nice, my younger sister is analyzing such things, therefore
    I am going to let know her.

  28. Adalberto said,

    May 25, 2017 @ 08:42 am

    If you want to take a good deal from this article then you have to
    apply these methods to your won webpage.

  29. csgo skins said,

    May 25, 2017 @ 09:48 am

    I was recommended this web site by my cousin. I am not sure whether this post is written by him as no one
    else know such detailed about my problem. You are
    incredible! Thanks!

  30. Terence said,

    May 25, 2017 @ 09:49 am

    Great delivery. Outstanding arguments. Keep up the great spirit.

  31. cheap mink lashes said,

    May 25, 2017 @ 09:58 am

    Good write-up. I definitely love this site. Keep it up!

  32. Bud said,

    May 25, 2017 @ 10:33 am

    Does your site have a contact page? I’m having trouble locating it but, I’d like to shoot you an e-mail.

    I’ve got some recommendations for your blog you might be interested in hearing.
    Either way, great blog and I look forward to seeing it expand over time.

  33. said,

    May 25, 2017 @ 10:51 am

    Excellent article. Keep posting such kind of information on your blog.
    Im really impressed by your blog.
    Hello there, You’ve done a great job. I’ll definitely digg it and in my
    opinion suggest to my friends. I am confident they’ll be benefited from this site.

  34. buy madden 17 coins said,

    May 25, 2017 @ 11:36 am

    Hi there to every body, it’s my first visit of
    this website; this webpage carries remarkable and actually fine stuff in favor of readers.

  35. said,

    May 25, 2017 @ 11:39 am

    My brother suggested I might like this website. He used to be entirely right.

    This post truly made my day. You can not consider simply how much time
    I had spent for this info! Thanks!

  36. said,

    May 25, 2017 @ 13:09 pm

    Have you ever thought about creating an ebook or guest authoring on other
    sites? I have a blog based upon on the same topics you discuss and would love to have you share some stories/information. I know my readers would appreciate your work.
    If you are even remotely interested, feel free to shoot me an e-mail.

  37. fut 18 coins said,

    May 25, 2017 @ 17:43 pm

    I am regular reader, how are you everybody? This
    paragraph posted at this web page is genuinely

  38. cheap mink eyelashes said,

    May 25, 2017 @ 17:46 pm

    Appreciate the recommendation. Will try it out.

  39. BillieInole said,

    May 25, 2017 @ 18:34 pm

    From your standard choices people produce for the cutting-edge of medical investigation, questionable healthcare problems produce headlines each day. The regions of disagreement offer many options to get a powerful conversation or dissertation. Many problems concerning maternity, start and early childhood provide powerful possibilities. Vaccines, attachment parenting vs. enabling children “cry it out,” breast feeding and early toilet training are all places in which a tiny investigation can help you create a great convincing discussion. Loads of controversies surrounding youngster health offer persuasive topic sides. Abstinence vs. freely accessible birth control, perhaps the drinking age must be changed, at what age teenagers ought to be permitted to create wellness selections for themselves, and what wellness information doctors should really be needed to tell an adolescentis parents are reasons that both sides maintain powerful research. Political and Legitimate Health Problems Consequently may the issue of whether surfaces should drive individuals to accept cure they don’t really want; feasible subtopics contain vaccines, forced contraception, psychological treatment, medicine treatment and finish-of-living care. Nutritional Health Issues Diet controversies abound. Genetically altered plants are believed poison by some as well as the reply to world hunger by others. Some genuinely believe that obesity is definitely a health condition, while some argue.
    professional writing help
    free essay writing service uk
    essay writers world reviews

  40. african vacation said,

    May 25, 2017 @ 22:04 pm

    I am in fact delighted to glance at this website posts which contains
    lots of valuable data, thanks for providing such data.

  41. said,

    May 26, 2017 @ 03:27 am

    Hi there would you mind sharing which blog platform you’re working with?

    I’m looking to start my own blog soon but I’m having a difficult time making a decision between BlogEngine/Wordpress/B2evolution and Drupal.
    The reason I ask is because your design and style
    seems different then most blogs and I’m looking for something completely
    unique. P.S My apologies for getting off-topic but I had to ask!

RSS feed for comments on this post · TrackBack URI

Leave a Comment

This blog is protected by Dave\'s Spam Karma 2: 17770 Spams eaten and counting...