Re: How to build executables that will dump live backtraces
Carter Schonwald <[email protected]> Wed, 21 Feb 2024 13:56:35 -0500
| Newsgroups | gmane.comp.lang.haskell.glasgow.user |
|---|---|
| Message-ID | <CAHYVw0yF3do7vkMLToooJsjOE3siW_UO4FG3zAAC_XJpiLXjEA@mail.gmail.com> |
--===============0584043889457086784== Content-Type: multipart/alternative; boundary="00000000000077c62a0611e8e35b" --00000000000077c62a0611e8e35b Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Have you looked at https://www.haskell.org/ghc/blog/20200403-dwarf-1.html or other docs online ? On Tue, Feb 20, 2024 at 7:40=E2=80=AFPM Clinton Mead <[email protected]= > wrote: > Hi All > > I've noticed this is a quiet mailing list recently, but I couldn't find a > more appropriate place to ask this question. Please say if there's > somewhere else I should be asking. > > It's my understanding that one can get GHC executables to dump backtraces > of all their running threads to stderr upon receiving SIGQUIT. And the wa= y > to do that is to build with 'libdw' support. > > We have a build system using Nix, and we're unfortunately a bit behind on > GHC 9.2.2 atm, but in anycase, I noticed in a Nix develop shell when I ru= n > `ghc --info | grep libdw` I get: > > ,("RTS expects libdw","NO") > > So I instead added the following to my Haskell package overrides: > > ghc =3D old.ghc.overrideAttrs (oldAttrs: { configureFlags =3D > oldAttrs.configureFlags ++ [ "--with-libdw-includes=3D${pkgs.elfutils.dev= }/include" > "--with-libdw-libraries=3D${pkgs.elfutils.out}/lib" "--enable-dwarf-unwin= d" > ]; buildInputs =3D oldAttrs.buildInputs ++ [pkgs.elfutils]; }); > > I basically copy/pastaed this from > https://github.com/input-output-hk/haskell.nix/blob/master/compiler/ghc/d= efault.nix > > And this seems to work, now when I run `ghc --info` I get: > > ,("RTS expects libdw","YES") > > But despite building with this version of GHC, still when I send `SIGQUIT= ` > to a process built with this version of GHC, I just get the message: > > "This build does not support backtraces." > > Now I have also been building my packages with `-g`, passing > `--enable-debug-info` etc, although it's my understanding that what I've > done just with building GHC with `--enable-dwarf-unwind` _should_ be enou= gh > to get a backtrace upon SIGQUIT, it might just be a poor one if the > debugging symbols aren't added. > > But clearly I've missed something if it's not working. I'm not quite sure > what set of circumstances the message "This build does not support > backtraces" is displayed? Is there a runtime check to see whether the > "libdw" library is actually in the library path, in addition to the > requirement that GHC be built with libdw support? If that's the case, > perhaps as I'm running this on NixOS I need to add something to my > executable's LD_LIBRARY_PATH or something? Or is there some option I need > to give GHC/Cabal to ensure that backtrace support is added to the > executable's runtime as well as making sure I've compiled with GHC that's > compiled with libdw support? Or is there some other runtime RTS option I > need to give to my executable? > > As you can see, I'm completely lost about how to move forward on this, so > any help would be very much appreciated. > > Thanks, > Clinton > _______________________________________________ > Glasgow-haskell-users mailing list > [email protected] > http://mail.haskell.org/cgi-bin/mailman/listinfo/glasgow-haskell-users > --00000000000077c62a0611e8e35b Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable <div dir=3D"auto">Have you looked at=C2=A0<div dir=3D"auto"><a href=3D"http= s://www.haskell.org/ghc/blog/20200403-dwarf-1.html">https://www.haskell.org= /ghc/blog/20200403-dwarf-1.html</a> or other docs online ?</div></div><div>= <br><div class=3D"gmail_quote"><div dir=3D"ltr" class=3D"gmail_attr">On Tue= , Feb 20, 2024 at 7:40=E2=80=AFPM Clinton Mead <<a href=3D"mailto:clinto= [email protected]">[email protected]</a>> wrote:<br></div><blockquote = class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid= ;padding-left:1ex"><div dir=3D"ltr">Hi All<br><br>I've noticed this is = a quiet mailing list recently, but I couldn't find a more appropriate p= lace to ask this question. Please say if there's somewhere else I shoul= d be asking.<br><br>It's my understanding that one can get GHC executab= les to dump backtraces of all their running threads to stderr upon receivin= g SIGQUIT. And the way to do that is to build with 'libdw' support.= <div><br></div><div>We have a build system using Nix, and we're unfortu= nately a bit behind on GHC 9.2.2 atm, but in anycase, I noticed in a Nix de= velop shell when I run `ghc --info | grep libdw` I get:</div><div><br></div= ><div><span style=3D"color:rgb(29,28,29);font-family:Monaco,Menlo,Consolas,= "Courier New",monospace;font-size:12px;font-variant-ligatures:non= e;background-color:rgba(29,28,29,0.04)">,("RTS expects libdw",&qu= ot;NO")</span><br></div><div><br></div><div>So I instead added the fol= lowing to my Haskell package overrides:<br></div><div><br></div><div><span = style=3D"color:rgb(29,28,29);font-family:Monaco,Menlo,Consolas,"Courie= r New",monospace;font-size:12px;font-variant-ligatures:none;background= -color:rgba(29,28,29,0.04)">ghc =3D=20 old.ghc.overrideAttrs (oldAttrs: { configureFlags =3D oldAttrs.configureFlags ++ [ "--with-libdw-includes=3D${<a href=3D"http://pkgs.elfutils.dev= " target=3D"_blank">pkgs.elfutils.dev</a>}/include"=20 "--with-libdw-libraries=3D${pkgs.elfutils.out}/lib"=20 "--enable-dwarf-unwind" ]; buildInputs =3D oldAttrs.buildInputs ++ [pkgs.elfutils]; });</span><br></div><div><br></div><div>I basically copy/pastaed=C2=A0thi= s from <a href=3D"https://github.com/input-output-hk/haskell.nix/blob/maste= r/compiler/ghc/default.nix" target=3D"_blank">https://github.com/input-outp= ut-hk/haskell.nix/blob/master/compiler/ghc/default.nix</a><br><br>And this = seems to work, now when I run `ghc --info` I get:<br><br><span style=3D"col= or:rgb(29,28,29);font-family:Monaco,Menlo,Consolas,"Courier New",= monospace;font-size:12px;font-variant-ligatures:none;background-color:rgba(= 29,28,29,0.04)">,("RTS expects libdw","YES")</span><br>= <br>But despite building with this version of GHC, still when I send `SIGQU= IT` to a process built with this version of GHC, I just get the message:<br= ><br><span style=3D"color:rgb(28,28,28);font-family:"Noto Sans",A= rial,sans-serif;font-size:14px">"This build does not support backtrace= s."</span><br><br>Now I have also been building my packages with `-g`,= passing `--enable-debug-info` etc, although it's my understanding that= what I've done just with building GHC with `--enable-dwarf-unwind` _sh= ould_ be enough to get a backtrace upon SIGQUIT, it might just be a poor on= e if the debugging symbols aren't added.<br><br>But clearly I've mi= ssed something if it's not working. I'm not quite sure what set of = circumstances the message=C2=A0<span style=3D"color:rgb(28,28,28);font-fami= ly:"Noto Sans",Arial,sans-serif;font-size:14px">"This build = does not support backtraces"</span>=C2=A0is displayed? Is there a runt= ime check to see whether the "libdw" library is actually in the l= ibrary path, in addition to the requirement that GHC be built with libdw su= pport? If that's the case, perhaps as I'm running this on NixOS I n= eed to add something to my executable's LD_LIBRARY_PATH or something? O= r is there some option I need to give GHC/Cabal to ensure that backtrace su= pport is added to the executable's runtime as well as making sure I'= ;ve compiled with GHC that's compiled with libdw support? Or is there s= ome other runtime RTS option I need to give to my executable?<br><br>As you= can see, I'm completely lost about how to move forward on this, so any= help would be very much appreciated.<br><br>Thanks,<br>Clinton</div></div> _______________________________________________<br> Glasgow-haskell-users mailing list<br> <a href=3D"mailto:[email protected]" target=3D"_blank">Glas= [email protected]</a><br> <a href=3D"http://mail.haskell.org/cgi-bin/mailman/listinfo/glasgow-haskell= -users" rel=3D"noreferrer" target=3D"_blank">http://mail.haskell.org/cgi-bi= n/mailman/listinfo/glasgow-haskell-users</a><br> </blockquote></div></div> --00000000000077c62a0611e8e35b-- --===============0584043889457086784== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KR2xhc2dvdy1o YXNrZWxsLXVzZXJzIG1haWxpbmcgbGlzdApHbGFzZ293LWhhc2tlbGwtdXNlcnNAaGFza2VsbC5v cmcKaHR0cDovL21haWwuaGFza2VsbC5vcmcvY2dpLWJpbi9tYWlsbWFuL2xpc3RpbmZvL2dsYXNn b3ctaGFza2VsbC11c2Vycwo= --===============0584043889457086784==--