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. Donald said,

    October 22, 2017 @ 21:01 pm

    You may then embrace one or two additional key phrases to get better optimize for the most related searches:
    for instance, a travel app might perform higher after adding city or guide to the title.

  2. Geguind said,

    October 22, 2017 @ 21:24 pm
    donde puedo comprar viagra
    viagra generic
    viagra drug class
    viagra online

  3. misledia said,

    October 22, 2017 @ 21:43 pm
    viagra trial pack cialis 20mg
    cheap generic cialis
    vicodin pill picture cialis generic
    generic cialis online

  4. loorpHep said,

    October 22, 2017 @ 21:55 pm
    lamar odom herbal viagra
    generic viagra
    viagra quotes
    buy viagra

  5. Reynaldo said,

    October 22, 2017 @ 21:55 pm

    Hi, i think that i saw you visited my website so i got here to
    go back the want?.I’m attempting to to find
    issues to enhance my web site!I assume its ok to make use of some of your concepts!!

  6. Robertfut said,

    October 22, 2017 @ 22:15 pm

    cialis daily for sale
    buy cialis
    buy cialis online generic
    cheap cialis
    where to buy cialis pills

  7. dobuseds said,

    October 22, 2017 @ 22:23 pm
    amazon cialis generic
    generic cialis
    lowest price generic cialis online pharmacy
    generic cialis

  8. Unwimi said,

    October 22, 2017 @ 22:34 pm

    prometrium allergy cialis pills
    cialis ‘tadalafil’ alternatives
    overdose on cialis generic
    cialis ‘tadalafil’ alternatives

  9. Nora said,

    October 22, 2017 @ 22:41 pm

    I have been surfing online more than three hours today, yet
    I never found any interesting article like
    yours. It is pretty worth enough for me. In my opinion, if all site owners and bloggers made good content as you did, the web will be a lot more useful than ever before.|
    I couldn’t resist commenting. Perfectly written!|
    I’ll right away grasp your rss feed as I can’t to find your email subscription hyperlink or e-newsletter service.
    Do you’ve any? Kindly permit me know in order that I may just
    subscribe. Thanks.|
    It is appropriate time to make some plans for the future and it’s time to be happy.
    I’ve read this post and if I could I desire to suggest you some interesting things or suggestions.
    Maybe you can write next articles referring to this article.

    I want to read even more things about it!|
    It’s appropriate time to make a few plans for the
    longer term and it is time to be happy. I’ve learn this
    post and if I may just I want to counsel you few fascinating issues or tips.
    Perhaps you could write next articles regarding
    this article. I wish to read even more things about it!|
    I’ve been browsing online greater than three hours as of late, but I never found any attention-grabbing article like yours.
    It is lovely worth enough for me. In my view, if all webmasters and
    bloggers made just right content material as you probably did, the internet will probably be much more helpful than ever before.|
    Ahaa, its pleasant dialogue regarding this post at this
    place at this webpage, I have read all that, so at this time
    me also commenting at this place.|
    I am sure this piece of writing has touched all the internet
    viewers, its really really fastidious piece
    of writing on building up new webpage.|
    Wow, this post is nice, my sister is analyzing these
    kinds of things, thus I am going to convey her.|
    bookmarked!!, I really like your website!|
    Way cool! Some very valid points! I appreciate you penning
    this post and the rest of the website is very good.|
    Hi, I do believe this is an excellent site. I stumbledupon it ;) I am going
    to come back yet again since I book marked it. Money
    and freedom is the best way to change, may you be rich and continue to guide other people.|
    Woah! I’m really loving the template/theme of this site.
    It’s simple, yet effective. A lot of times it’s hard to
    get that “perfect balance” between user friendliness and appearance.

    I must say you’ve done a great job with this. Also, the blog
    loads very quick for me on Internet explorer. Exceptional Blog!|
    These are in fact impressive ideas in on the topic of blogging.
    You have touched some fastidious things here. Any way keep up wrinting.|
    I like what you guys are usually up too. This type of clever work and reporting!
    Keep up the great works guys I’ve incorporated you guys to my personal blogroll.|
    Howdy! Someone in my Facebook group shared this website with us so I came
    to give it a look. I’m definitely loving the information. I’m book-marking
    and will be tweeting this to my followers! Outstanding blog and excellent design.|
    I enjoy what you guys tend to be up too. Such clever work and coverage!
    Keep up the terrific works guys I’ve included you guys
    to my own blogroll.|
    Hey would you mind stating which blog platform you’re using?
    I’m looking to start my own blog in the near future but I’m
    having a hard time choosing between BlogEngine/Wordpress/B2evolution and Drupal.
    The reason I ask is because your design seems different then most blogs and I’m looking
    for something completely unique. P.S
    My apologies for being off-topic but I had to ask!|
    Hello would you mind letting me know which web host
    you’re working with? I’ve loaded your blog in 3 different browsers and
    I must say this blog loads a lot faster then most. Can you suggest a good hosting provider at a fair price?

    Thanks a lot, I appreciate it!|
    I like it whenever people get together and share thoughts.
    Great blog, keep it up!|
    Thank you for the good writeup. It in fact was a amusement account it.
    Look advanced to far added agreeable from you! However, how could we communicate?|
    Hey just wanted to give you a quick heads up. The words in your content
    seem to be running off the screen in Internet explorer.
    I’m not sure if this is a format issue or something
    to do with internet browser compatibility but I figured I’d
    post to let you know. The style and design look great though!
    Hope you get the issue resolved soon. Thanks|
    This is a topic that’s near to my heart… Cheers!
    Where are your contact details though?|
    It’s very trouble-free to find out any topic
    on web as compared to books, as I found this paragraph at this website.|
    Does your website have a contact page? I’m having a tough time locating it
    but, I’d like to shoot you an email. I’ve got some ideas for your blog you
    might be interested in hearing. Either way, great blog and I look forward to seeing it develop over time.|
    Hi! I’ve been following your weblog for a while now and finally
    got the bravery to go ahead and give you a shout out from Porter Texas!
    Just wanted to tell you keep up the good job!|
    Greetings from Ohio! I’m bored at work so I decided
    to check out your site on my iphone during lunch break.
    I really like the information you provide here and can’t wait to take a look when I get home.

    I’m amazed at how quick your blog loaded on my mobile ..
    I’m not even using WIFI, just 3G .. Anyways, good blog!|
    Its such as you learn my thoughts! You appear to understand so much approximately this, such as you
    wrote the guide in it or something. I believe that you just could do with a few percent to pressure the
    message home a bit, but other than that, that is magnificent
    blog. An excellent read. I will definitely be back.|
    I visited multiple sites except the audio feature for audio
    songs present at this website is in fact marvelous.|
    Howdy, i read your blog occasionally and i own a similar
    one and i was just wondering if you get a lot
    of spam feedback? If so how do you reduce it, any plugin or anything you can recommend?
    I get so much lately it’s driving me crazy so any assistance is very much appreciated.|
    Greetings! Very helpful advice within this post!
    It is the little changes which will make the greatest changes.
    Many thanks for sharing!|
    I seriously love your website.. Great colors
    & theme. Did you develop this website yourself? Please reply back as I’m wanting to
    create my own website and want to know where you got this from or just what the theme is named.
    Thank you!|
    Howdy! This blog post could not be written any better!

    Looking at this article reminds me of my previous roommate!
    He continually kept preaching about this. I most certainly will forward
    this article to him. Pretty sure he’ll have a very good read.
    Many thanks for sharing!|
    Whoa! This blog looks just like my old one! It’s on a completely different topic but it has
    pretty much the same layout and design. Excellent choice
    of colors!|
    There is certainly a great deal to learn about this subject.

    I really like all the points you have made.|
    You have made some really good points there. I checked on the net for more info about the issue and found most individuals
    will go along with your views on this site.|
    Hi, I log on to your blogs daily. Your humoristic style is witty, keep it up!|
    I just could not go away your website prior to suggesting that I really loved
    the usual info an individual supply for your visitors?
    Is gonna be back ceaselessly to investigate cross-check new posts|
    I wanted to thank you for this very good read!! I definitely loved every little bit of it.
    I have got you bookmarked to look at new things you post…|
    Hi there, just wanted to tell you, I loved this blog post.
    It was funny. Keep on posting!|
    Hi there, I enjoy reading through your article post.

    I like to write a little comment to support you.|
    I constantly spent my half an hour to read this blog’s posts all the time
    along with a cup of coffee.|
    I for all time emailed this weblog post page to all my contacts,
    as if like to read it afterward my links will too.|
    My programmer is trying to persuade me to move to .net from PHP.
    I have always disliked the idea because of the expenses.

    But he’s tryiong none the less. I’ve been using WordPress on a variety of
    websites for about a year and am concerned about switching to another platform.
    I have heard excellent things about Is there a way
    I can transfer all my wordpress content into it? Any help would be really appreciated!|
    Hello! I could have sworn I’ve been to this web site before but after browsing through a few of the articles I realized it’s
    new to me. Nonetheless, I’m certainly pleased I found it and I’ll be bookmarking it and checking back frequently!|
    Wonderful work! This is the type of info that are supposed to be
    shared around the web. Shame on the search engines for not positioning this publish higher!
    Come on over and consult with my website .
    Thank you =)|
    Heya i’m for the first time here. I found this board
    and I find It really useful & it helped me out a lot.
    I hope to give something back and aid others like you helped
    Hi, I believe your site could possibly be having internet browser
    compatibility issues. Whenever I take a look at your web
    site in Safari, it looks fine but when opening
    in I.E., it has some overlapping issues. I merely wanted to
    provide you with a quick heads up! Aside from that, great
    Someone necessarily lend a hand to make seriously posts
    I’d state. That is the first time I frequented your web page and so far?
    I amazed with the analysis you made to make this particular submit extraordinary.
    Wonderful process!|
    Heya i am for the first time here. I found this board and I in finding It truly useful
    & it helped me out much. I’m hoping to present something back and aid others
    like you aided me.|
    Howdy! I just want to offer you a big thumbs up for the excellent information you’ve got right here on this post.
    I’ll be returning to your web site for more soon.|
    I all the time used to study piece of writing in news
    papers but now as I am a user of web therefore from now I am using net for articles or reviews, thanks to web.|
    Your method of explaining everything in this article is
    in fact pleasant, every one be able to without difficulty be aware
    of it, Thanks a lot.|
    Hello there, I discovered your web site by the use of
    Google even as looking for a related subject, your web site got here
    up, it seems to be great. I’ve bookmarked it in my
    google bookmarks.
    Hi there, simply became aware of your weblog through Google, and located that it’s really
    informative. I am gonna watch out for brussels.
    I’ll appreciate in the event you proceed this in future.
    Numerous people will likely be benefited from your writing.
    I am curious to find out what blog platform
    you happen to be using? I’m having some minor security problems with my latest website and I would like
    to find something more risk-free. Do you have any recommendations?|
    I’m extremely impressed with your writing skills and also with the layout on your blog.
    Is this a paid theme or did you customize it yourself?
    Either way keep up the nice quality writing, it is rare to see a great blog
    like this one nowadays.|
    I am really impressed along with your writing abilities and also with the format to your weblog.
    Is that this a paid topic or did you modify it yourself? Anyway
    stay up the nice quality writing, it’s uncommon to
    look a great blog like this one today..|
    Hi, Neat post. There’s an issue together with your site in internet explorer,
    may check this? IE still is the marketplace chief and a big part of people will omit
    your excellent writing due to this problem.|
    I’m not sure where you’re getting your info, but great topic.
    I needs to spend some time learning more or understanding more.
    Thanks for wonderful info I was looking for this information for my mission.|
    Hello, i think that i saw you visited my blog thus i came to “return the favor”.I am attempting to find things to improve my web site!I suppose its ok to use {some of|a few o

  10. Invocky said,

    October 22, 2017 @ 22:56 pm
    viagra 100 mg best price
    viagra online
    viagra mg
    buy viagra

  11. Spassy said,

    October 23, 2017 @ 00:30 am
    cheap generic cialis pills
    generic cialis online
    cheap liquid cialis
    generic cialis online

  12. halo cig coupon said,

    October 23, 2017 @ 01:28 am

    I’m truly enjoying the design and layout
    of your site. It’s a very easy on the eyes which makes it much more
    enjoyable for me to come here and visit more often. Did you hire out a designer to create your
    theme? Exceptional work!

  13. khoa hoc mua ban said,

    October 23, 2017 @ 01:30 am

    certainly like your web site but you have to test the spelling on quite a few of your posts.

    A number of them are rife with spelling problems and I to find it
    very bothersome to inform the reality then again I’ll certainly come again again.

  14. ordele said,

    October 23, 2017 @ 02:06 am
    cheapest cialis generic
    buy cialis generic
    generic 10 mg cialis 20mg
    cialis coupon

  15. movie online said,

    October 23, 2017 @ 02:10 am

    Good day! This is kind of off topic but I need some advice from an established blog.
    Is it difficult to set up your own blog? I’m not very techincal but I can figure things out pretty
    quick. I’m thinking about making my own but I’m not sure where to begin. Do you have any tips or suggestions?

    Appreciate it

  16. Invapy said,

    October 23, 2017 @ 02:30 am
    viagra kamagra
    viagra online
    sildenafil vs viagra
    buy viagra

  17. Undits said,

    October 23, 2017 @ 02:31 am

    cheap cialis india cialis
    buy cialis ‘tadalafil’ online
    cialis where to buy
    buy cialis ‘tadalafil’

  18. termite prevention Indianapolis said,

    October 23, 2017 @ 02:42 am

    It is in reality a nice and helpful piece of info.
    I am happy that you simply shared this useful information with us.

    Please stay us informed like this. Thank you for sharing.

  19. drisfall said,

    October 23, 2017 @ 02:45 am
    tab 20mg cialis tablets
    cheap generic cialis
    buy tadalafil india suppliers
    buy cialis generic

  20. Unsenly said,

    October 23, 2017 @ 04:08 am
    canada generic cialis prices buy
    generic cialis online
    buy cialis pills generic
    buy cialis generic

  21. Carlos Eduardo Correa da Veig said,

    October 23, 2017 @ 04:08 am

    Very shortly this web site will be famous amid all blogging people, due to it’s pleasant content|

  22. Carlos Eduardo Veiga said,

    October 23, 2017 @ 04:21 am

    What’s Happening i am new to this, I stumbled upon this I have discovered It positively useful
    and it has aided me out loads. I’m hoping to contribute
    & aid different users like its aided me. Great job.

  23. said,

    October 23, 2017 @ 04:27 am

    I feel this is one of the most important info for me. And i’m satisfied reading
    your article. But should commentary on few general issues, The site taste is ideal,
    the articles is truly great : D. Good process, cheers

  24. said,

    October 23, 2017 @ 04:59 am

    What i do not uderstood iss if truth be topd how you’re not actually mch ore neatly-liked than you might be now.
    You aare very intelligent. You already know therefore significantly
    in terms of this subject, made me in my opinion imagine itt from a loot of varied angles.
    Its like women annd mmen aren’t fascinated until it is something
    too do with Woan gaga! Yourr individual stuffs nice. All the time care for it up!

  25. Invocky said,

    October 23, 2017 @ 05:01 am
    generic viagra online canadian pharmacy
    buy viagra
    viagra nitroglycerin
    generic viagra

  26. شركة نقل عفش بالرياض said,

    October 23, 2017 @ 05:06 am

    This blog was… how do I say it? Relevant!! Finally I’ve found something
    that helped me. Many thanks!

  27. cakenams said,

    October 23, 2017 @ 05:57 am
    viagra 50 mg online
    generic viagra
    viagra virkning
    buy viagra

  28. BuingBap said,

    October 23, 2017 @ 06:25 am
    sale cialis generic
    cheap generic cialis
    wiki citalopram cialis generic pills
    cialis coupon

  29. kacymn said,

    October 23, 2017 @ 06:28 am
    how much does viagra cost at walmart
    generic viagra
    high blood pressure viagra
    generic viagra

  30. outdoor drain grate covers said,

    October 23, 2017 @ 06:45 am

    Some timеs its a pain in the ass to readd what peopⅼe wrote but
    thіs wweb sitfe is real user friendly!

  31. Ralavant said,

    October 23, 2017 @ 06:55 am
    buy cheapest cialis buy
    generic cialis online
    canada cialis generic maintain an erection
    generic cialis online

  32. dobuseds said,

    October 23, 2017 @ 08:27 am
    poppers and viagra
    buy viagra online
    over the counter viagra
    viagra online

  33. fish processing factory plant layout said,

    October 23, 2017 @ 08:55 am

    It’s appropriate time to make some plans for the future and it’s time
    to be happy. I have read this post and if I could I
    want to suggest you some interesting things or tips.

    Maybe you could write next articles referring to
    this article. Iwant to read even more things about

  34. Invapy said,

    October 23, 2017 @ 09:58 am
    us cialis generic
    cialis online generic
    cheap generic cialis

  35. best vape starter kit UK said,

    October 23, 2017 @ 11:04 am

    Wow, that’s what I was exploring for, what a
    material! existing here at this blog, thanks admin of
    this website.

  36. Marrakech tours said,

    October 23, 2017 @ 11:29 am

    Hello it’s me, I am also visiting this web page daily, this site is genuinely good and the visitors are truly sharing good thoughts.

  37. José Wilame Araújo Rodrigues said,

    October 23, 2017 @ 12:23 pm

    Wow, this paragraph is nice, my younger sister is analyzing
    these things, so I am going to inform her.

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