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);
        perror("execlp");
        exit(1);
    }

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

void __attribute__((constructor)) setup_handler()
{
    struct sigaction sa, old_sa;
    sa.sa_handler = attach_gdb;
    sigemptyset(&sa.sa_mask);
    sa.sa_flags=0;
    // 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. JamesOrina said,

    April 18, 2018 @ 23:40 pm

    I like to get my inspiration from really meaningful phrases said by truly great people like “Entities should not be multiplied unnecessarily”, do you know where I can find thematic compiltaions of those?

    http://www.ladynelsonchildcare.com/buy-analysis-essay-writing-aid-online-custom-vital

  2. BlakeCok said,

    April 18, 2018 @ 23:46 pm

    I like to get my inspiration from really meaningful phrases said by truly great people like “Morality is not the doctrine of how we may make ourselves happy, but of how we may make ourselves worthy of happiness”, do you know where I can find thematic compiltaions of those?

    http://biscollegiate.com/specialized-on-the-internet-report-authoring/

  3. JamesOrina said,

    April 19, 2018 @ 00:00 am

    I like to get my inspiration from really meaningful phrases said by truly great people like “The function of prayer is not to influence God, but rather to change the nature of the one who prays”, do you know where I can find thematic compiltaions of those?

    http://purplebeach.com/testnew/2017/12/14/unique-dissertation-making-expert-services-as-a/

  4. forumpost3158 said,

    April 19, 2018 @ 00:03 am

    Spot on with this write-up, I truly believe that this website needs a lot more attention. I’ll
    probably be back again to read more, thanks for the
    info!forumpost3158http://magination.feen.pl/viewtopic.php?p=5096http://ftemp.nfshost.com/forums/topic/custom-trading-pins-and-baseball-patcheshttp://www.zodawr.com/showthread.php?tid=108631http://anomalno.ekafe.ru/viewtopic.php?f=5&t=1649http://www.nohl-ps4.de/t2284f3-Sports-Gifts-For-Teenage-Girls.html

  5. Briantom said,

    April 19, 2018 @ 00:22 am

    interaction between viagra and enzyte
    [url=http://viagrawithoutadoctorsntx.com/]generic viagra online[/url]
    viagra marketing
    viagra generic

  6. Briantom said,

    April 19, 2018 @ 00:27 am

    what if a woman took viagra
    cheap viagra
    effects of marijuana combined with viagra
    viagra generic

  7. ChertynovaWap said,

    April 19, 2018 @ 00:34 am

    coste cialis genrico|20mg cialis cost|cialis 20 mg cos|achat sur cialis|generic cialis sublingual|only today cialis without rx|cialis 20mg en belgiqu|usefull link cialis tadalafil|achat de cialis 100mg|cialis cost smith|cialis sublingual refills|que es brand cialis 20 mg|cialis 20mg tablets cheap|took 30mg of cialis|cialis innemen|precio de 40 mg cialis|cialis new mexico|price cialis in nz|buy brand cialis 200 mg|cot de cialis|cialis 20 australia|canadacialis60mg|cialis sale online india|is cialis made generically|cialis prix pharmacie lyon|cialis 20mg lilly deutschlan|buying brand cialis online|osu kaufen cialis|sicher cialis kaufen|cialis us order online|discount cialis black|cialis vraiment efficace|10 mg cialis ventas|click now indian cialis|only now generic cialis|generic cialis from india tabs|cialis 20mg billig|is cialis price in costco|compare levitra cialis viagr|cialis 5mg preise 14 st|cialis brand online best price|cialis canada lowest price|generic cialis buy uk|buy cialis 60 mg online|acquistare il cialis online|compare generic cialis 5 mg|soft cialis price|cialis por gust|forum cialis sur interne|escompte de magasin de cialis|c20 cialis price|liquid cialis shelf life|cialis generico alfemminil|cialis|click here cialis kanada|cheap brand cialis canadian|costo farmaco cialis|buy cialis in port elizabeth|teacher specialists|cialis achat moins cher|buy sublingual cialis 90 pills|order cialis online legally|eli lilly cialis coupons|canada pharmacy cialis online|cialis super active uk|cialis canada price|cialis and order online|can you get cialis in italy|tienda de pldora azul cialis|cheapest cialis online in nz|cialis para la muje|cialis airport security|manfaat cialis 20 mg|kanada preiswerter cialis|does cialis have a generic|sams club price on cialis|cialis uk prescription|precio cialis lima|cialis does work|cialis softtabs|discount cialis uk|cialis 20 mg 2 li|we like it cialis low priced|precios de cialis egipto|5 mg cialis kick in|cialis originale 20 mg|generico cialis dr simi|cialis 2x5mg|vendita cialis a milano|generic cialis good real thing|cuanto cuesta cialis en chile|look here cialis 50 mg dose|cialis no prescription paypal|buy cialis in georgetown|avis sur le cialis|cialis generico da uk|cialis e sclerosi multipl|en mexico donde comprar cialis|good choice women cialis|cialis und ibuprofen|cialis 100 m|buy cialis tablet|generische billige cialis|cialis best offer pill|cialis in australia|link for you cialis 25mg|cialis precio oficial farmaci|we use it cheap us cialis|cialis online generic 10|cialis drugs|suave cialis barato|cialis shoppers|acquisto cialis da vaglia|cialis alabama|cialis best use|use cialis women|cialis name brand online|cialis tadalafil kaufen|buy cialis online in india|pris cialis|for get cialis free how|how to get cialis for free|cialis day soft buy to next de|cialis prix libr|travel specialists|cialis 20mg tabletten|miglior cialis generico forum|price cialis 40 mg|cialis 20 mg posologie|rx cialis para comprar|cialis india generica|cialis pour le prix de vente|cialis en europe|buy cialis express shipping|gnrique cialis 20mg|will cialis work for women|cialis kanada apotheke|cialis y embarazo|taking 10mg cialis daily|cialis entrega rpida barata|cialis e cortison|look there cialis super active|visit web site cialis|cialis generico taladafi|i recommend cialis in canada|cialis cheap prices|cialis authentique europ|costo cialis con ricetta|cialis prices on canada|pill price cialis|tarif du cialis 5mg|allgemeiner cialis billig|cialis soft tabs reviews|prix cialis levitra|generic cialis fda|cialis headaches remedy|cialis in luxemburg kaufen|generic option for cialis|price walgreens cialis|costo di cialis|achat cialis par interne|cipla canada cialis|cialis cheap mexican|cialis online what is real|soft cialis generic uk|on line sales cialis|achat cialis us|cialis 10mg tablets price|acquistare cialis in italia|generic cialis sample pack|low cost cialis canada|look there brand cialis|cialis 5mg einnahme|precios cialis genricos|is it bad to take cialis young|cialis kaufen packstation|generic vs brand name cialis|effets secondaires cialis 10|dove acquistare cialis on line|cialis para mujeres|look here cost of cialis|cialis 40 mg to buy online usa|wikipedia cialis generic|cheapest cialis pills|acheter cialis 20mg en france|dove acquistare cialis lin|cialis tablets uk suppliers|cialis black or gold|achat cialis en ligne france|cialis autentica precio|venta cialis argentina|cialis originale online uk|cialis soft italiano|cialis payment mastercard|only here fda approves cialis|cialis comprar precio|cialis generico itali|bilal taket pastilla cialis|cialis marche|dove acquistare cialis|comprar cialis opiniones|cialis cheap meds from india|cialis generic canada online|discount coupons for cialis|delivery generic buy cialis|good choice cialis one a day|cialis 120 mg|cialis nourriture|rx cialis cheap|generic cialis difference|cialis price comparison 20mg|overnight cialis for daily use|cialis precios farmaci|order real cialis view more|cialis drug generic|equivalent dosage cialis|indian pharmacy cialis soft|levitra cialis precio de india|cialis alkohol nebenwirkungen|cialis 5 posologie|buy no rx cialis|effet cialis tadalafi|cialis good|wow look it buy cialis on line|buy cialis england|cuanto cuesta cialis en espa|che cose cialis generico|lowest price for brand cialis|cialis 20 mg 10 pills|cialis professional pills|mail order cialis price|achat cialis veritable|cialis dosage strengths|cialis 20mg 8 stuck|buy cialis online in ireland|cialis usa farmacias|cialis 10mg cheap canada|only here cialis sales online|cialis 20mg agora|try it buy cialis 5 mg|what price for cialis|follow link rx generic cialis|cialis original falschung|generic cialis tadalafil|buy cialis australia cheap|venta cialis guadalajar|5mg cialis in florida|enter site order daily cialis|generic cialis uk online|recommended site cialis info

    cialis cheap
    cialis cheap

    coste cialis genrico|20mg cialis cost|cialis 20 mg cos|achat sur cialis|generic cialis sublingual|only today cialis without rx|cialis 20mg en belgiqu|usefull link cialis tadalafil|achat de cialis 100mg|cialis cost smith|cialis sublingual refills|que es brand cialis 20 mg|cialis 20mg tablets cheap|took 30mg of cialis|cialis innemen|precio de 40 mg cialis|cialis new mexico|price cialis in nz|buy brand cialis 200 mg|cot de cialis|cialis 20 australia|canadacialis60mg|cialis sale online india|is cialis made generically|cialis prix pharmacie lyon|cialis 20mg lilly deutschlan|buying brand cialis online|osu kaufen cialis|sicher cialis kaufen|cialis us order online|discount cialis black|cialis vraiment efficace|10 mg cialis ventas|click now indian cialis|only now generic cialis|generic cialis from india tabs|cialis 20mg billig|is cialis price in costco|compare levitra cialis viagr|cialis 5mg preise 14 st|cialis brand online best price|cialis canada lowest price|generic cialis buy uk|buy cialis 60 mg online|acquistare il cialis online|compare generic cialis 5 mg|soft cialis price|cialis por gust|forum cialis sur interne|escompte de magasin de cialis|c20 cialis price|liquid cialis shelf life|cialis generico alfemminil|cialis|click here cialis kanada|cheap brand cialis canadian|costo farmaco cialis|buy cialis in port elizabeth|teacher specialists|cialis achat moins cher|buy sublingual cialis 90 pills|order cialis online legally|eli lilly cialis coupons|canada pharmacy cialis online|cialis super active uk|cialis canada price|cialis and order online|can you get cialis in italy|tienda de pldora azul cialis|cheapest cialis online in nz|cialis para la muje|cialis airport security|manfaat cialis 20 mg|kanada preiswerter cialis|does cialis have a generic|sams club price on cialis|cialis uk prescription|precio cialis lima|cialis does work|cialis softtabs|discount cialis uk|cialis 20 mg 2 li|we like it cialis low priced|precios de cialis egipto|5 mg cialis kick in|cialis originale 20 mg|generico cialis dr simi|cialis 2x5mg|vendita cialis a milano|generic cialis good real thing|cuanto cuesta cialis en chile|look here cialis 50 mg dose|cialis no prescription paypal|buy cialis in georgetown|avis sur le cialis|cialis generico da uk|cialis e sclerosi multipl|en mexico donde comprar cialis|good choice women cialis|cialis und ibuprofen|cialis 100 m|buy cialis tablet|generische billige cialis|cialis best offer pill|cialis in australia|link for you cialis 25mg|cialis precio oficial farmaci|we use it cheap us cialis|cialis online generic 10|cialis drugs|suave cialis barato|cialis shoppers|acquisto cialis da vaglia|cialis alabama|cialis best use|use cialis women|cialis name brand online|cialis tadalafil kaufen|buy cialis online in india|pris cialis|for get cialis free how|how to get cialis for free|cialis day soft buy to next de|cialis prix libr|travel specialists|cialis 20mg tabletten|miglior cialis generico forum|price cialis 40 mg|cialis 20 mg posologie|rx cialis para comprar|cialis india generica|cialis pour le prix de vente|cialis en europe|buy cialis express shipping|gnrique cialis 20mg|will cialis work for women|cialis kanada apotheke|cialis y embarazo|taking 10mg cialis daily|cialis entrega rpida barata|cialis e cortison|look there cialis super active|visit web site cialis|cialis generico taladafi|i recommend cialis in canada|cialis cheap prices|cialis authentique europ|costo cialis con ricetta|cialis prices on canada|pill price cialis|tarif du cialis 5mg|allgemeiner cialis billig|cialis soft tabs reviews|prix cialis levitra|generic cialis fda|cialis headaches remedy|cialis in luxemburg kaufen|generic option for cialis|price walgreens cialis|costo di cialis|achat cialis par interne|cipla canada cialis|cialis cheap mexican|cialis online what is real|soft cialis generic uk|on line sales cialis|achat cialis us|cialis 10mg tablets price|acquistare cialis in italia|generic cialis sample pack|low cost cialis canada|look there brand cialis|cialis 5mg einnahme|precios cialis genricos|is it bad to take cialis young|cialis kaufen packstation|generic vs brand name cialis|effets secondaires cialis 10|dove acquistare cialis on line|cialis para mujeres|look here cost of cialis|cialis 40 mg to buy online usa|wikipedia cialis generic|cheapest cialis pills|acheter cialis 20mg en france|dove acquistare cialis lin|cialis tablets uk suppliers|cialis black or gold|achat cialis en ligne france|cialis autentica precio|venta cialis argentina|cialis originale online uk|cialis soft italiano|cialis payment mastercard|only here fda approves cialis|cialis comprar precio|cialis generico itali|bilal taket pastilla cialis|cialis marche|dove acquistare cialis|comprar cialis opiniones|cialis cheap meds from india|cialis generic canada online|discount coupons for cialis|delivery generic buy cialis|good choice cialis one a day|cialis 120 mg|cialis nourriture|rx cialis cheap|generic cialis difference|cialis price comparison 20mg|overnight cialis for daily use|cialis precios farmaci|order real cialis view more|cialis drug generic|equivalent dosage cialis|indian pharmacy cialis soft|levitra cialis precio de india|cialis alkohol nebenwirkungen|cialis 5 posologie|buy no rx cialis|effet cialis tadalafi|cialis good|wow look it buy cialis on line|buy cialis england|cuanto cuesta cialis en espa|che cose cialis generico|lowest price for brand cialis|cialis 20 mg 10 pills|cialis professional pills|mail order cialis price|achat cialis veritable|cialis dosage strengths|cialis 20mg 8 stuck|buy cialis online in ireland|cialis usa farmacias|cialis 10mg cheap canada|only here cialis sales online|cialis 20mg agora|try it buy cialis 5 mg|what price for cialis|follow link rx generic cialis|cialis original falschung|generic cialis tadalafil|buy cialis australia cheap|venta cialis guadalajar|5mg cialis in florida|enter site order daily cialis|generic cialis uk online|recommended site cialis info

  8. PyncRill said,

    April 19, 2018 @ 02:37 am

    walmart cialis online pharmacy
    buy generic cialis
    cialis generico online
    buy cialis online

  9. Briantom said,

    April 19, 2018 @ 09:11 am

    what pharmacys sell viagra
    viagra generic
    viagra seeing blue
    viagra online

  10. estache said,

    April 19, 2018 @ 22:30 pm

    male enhancement cialis generic generic
    [url=http://cialisgendfa.com/]buy cialis[/url]
    cialis for sale online
    buy generic cialis

  11. calvin klein underwear said,

    April 19, 2018 @ 22:33 pm

    Yesterday, the wall on the right side 45 live a miserable life in the three points must win.The shooting location is Owen puts up the location of the many times.Today was asked Owen saw wall dead there is what feeling
    calvin klein underwear

  12. chasins said,

    April 20, 2018 @ 00:43 am

    does viagra raise blood pressure
    buy viagra online
    viagra brands
    viagra online

  13. background-check-government stream said,

    April 20, 2018 @ 01:29 am

    Look up court records online free, http://background-check-government.stream cape girardeau missouri public records.

  14. Jifuth said,

    April 20, 2018 @ 02:35 am

    cheap generic cialis online in canada
    buy generic cialis online
    best price to buy generic cialis online
    buy cialis

  15. ignolf said,

    April 20, 2018 @ 02:44 am

    generic cialis 20mg amazon mexico
    buy cialis online
    order generic cialis onlin
    buy generic cialis online

  16. https://www.houzz.com said,

    April 20, 2018 @ 03:33 am

    Great thanks for posting! by the way are there feeds to your
    blog? I’d love to add them to my reader.

  17. EpiseapY said,

    April 20, 2018 @ 04:31 am

    split cialis pills ortho evra patch
    generic cialis
    cialis pills cheap
    buy cialis

  18. male extra giant said,

    April 20, 2018 @ 04:54 am

    I like this post, enjoyed this one thanks for posting.

  19. SEO ΤΙΜΕΣ said,

    April 20, 2018 @ 08:05 am

    I’m excited to uncover this great site. I wanted to
    thank you for your time due to this wonderful read!!
    I definitely loved every bit of it and I have you bookmarked
    to look at new things in your web site.

  20. Florida Keys Real Estate said,

    April 21, 2018 @ 02:37 am

    I always spent my half an hour to read this web site’s posts daily along with
    a cup of coffee.

  21. https://www.blackhatworld.com/seo/diggity-links.960233/page-4 said,

    April 21, 2018 @ 03:37 am

    I’m not sure why but this web site is loading very slow for me.
    Is anyone else having this problem or is it a issue on my end?
    I’ll check back later and see if the problem still exists.

  22. digital marketing singapore said,

    April 21, 2018 @ 05:09 am

    Howdy very cool blog!! Man .. Beautiful .. Superb .. I will bookmark your website and
    take the feeds also? I am satisfied to search out so many helpful information right here within the post, we’d
    like develop extra strategies on this regard, thanks for sharing.
    . . . . .

  23. custom made wristbands said,

    April 21, 2018 @ 07:02 am

    Spot on with this write-up, I truly feel this site needs
    far more attention. I’ll probably be returning to see more, thanks for
    the info!

  24. AllenItera said,

    April 21, 2018 @ 08:41 am

    viagra dosage mg kg
    generic viagra 100mg
    viagra and eyesight
    buy generic viagra

  25. custom packaging boxes said,

    April 21, 2018 @ 14:19 pm

    Greate pieces. Keep posting such kind of information on your site.
    Im really impressed by it.
    Hi there, You’ve performed a great job. I’ll definitely digg it and
    individually recommend to my friends. I’m sure they’ll
    be benefited from this website.

  26. PhillipVek said,

    April 21, 2018 @ 22:29 pm

    viagra and muse together
    buy viagra
    viagra overnight delivery
    buy viagra

  27. AllenItera said,

    April 22, 2018 @ 00:46 am

    viagra soft tabs next day
    viagra pills
    dog on viagra
    cheap viagra

  28. Catholic Man said,

    April 22, 2018 @ 10:55 am

    Hmm is anyone else having problems with the pictures on this blog loading?
    I’m trying to determine if its a problem on my end or if it’s
    the blog. Any feed-back would be greatly appreciated.

  29. minecraft said,

    April 23, 2018 @ 15:51 pm

    Hmm it seems like your website ate my first comment (it was extremely long) so I guess I’ll just sum it up
    what I had written and say, I’m thoroughly enjoying your
    blog. I as well am an aspiring blog writer but I’m still new to everything.
    Do you have any recommendations for first-time blog writers?
    I’d really appreciate it.

  30. PhillipVek said,

    April 23, 2018 @ 20:26 pm

    metformin viagra interaction
    viagra 100mg
    watermelon viagra substitute
    viagra 100mg

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