StgStartup: Add DWARF unwinding annotations for stg_stop_thread
AbandonedPublic

Authored by bgamari on Sep 5 2015, 8:50 AM.

Details

Summary

This allows us to collect backtraces all the way back to _start

For instance,

Stack trace:
    set_initial_registers (rts/Libdw.c:272.0)
    dwfl_thread_getframes

    dwfl_getthreads
    dwfl_getthread_frames
    libdw_get_backtrace (rts/Libdw.c:243.0)
    base_GHCziExecutionStack_getStackTrace1_info (libraries/base/GHC/ExecutionStack.hs:43.1)
    base_GHCziExecutionStack_showStackTrace1_info (libraries/base/GHC/ExecutionStack.hs:47.1)
    base_GHCziBase_bindIO1_info (libraries/base/GHC/Base.hs:1085.1)
    base_GHCziBase_thenIO1_info (libraries/base/GHC/Base.hs:1088.1)
    base_GHCziBase_thenIO1_info (libraries/base/GHC/Base.hs:1088.1)
    base_GHCziBase_thenIO1_info (libraries/base/GHC/Base.hs:1088.1)
    base_GHCziBase_thenIO1_info (libraries/base/GHC/Base.hs:1088.1)
    base_GHCziBase_thenIO1_info (libraries/base/GHC/Base.hs:1088.1)
    stg_catch_frame_info (rts/Exception.cmm:370.1)
    stg_stop_thread_info (rts/StgStartup.cmm:42.1)
    scheduleWaitThread (rts/Schedule.c:465.0)
    hs_main (rts/RtsMain.c:65.0)

    __libc_start_main (/tmp/buildd/glibc-2.19/csu/libc-start.c:321.0)
    _start

Depends on D1222

bgamari updated this revision to Diff 4085.Sep 5 2015, 8:50 AM
bgamari retitled this revision from to StgStartup: Add DWARF for stop_thread.
bgamari updated this object.
bgamari edited the test plan for this revision. (Show Details)
bgamari added reviewers: scpmw, simonmar.
bgamari updated this revision to Diff 4086.Sep 5 2015, 9:10 AM
bgamari edited edge metadata.
  • Add comments
bgamari retitled this revision from StgStartup: Add DWARF for stop_thread to StgStartup: Add DWARF unwinding annotations for stg_stop_thread.
bgamari edited edge metadata.
simonmar accepted this revision.Oct 14 2015, 7:31 AM
simonmar edited edge metadata.

Again, we should have a test. Also, I presume this only works for x86_64?

austin accepted this revision.Oct 21 2015, 5:32 PM
austin edited edge metadata.

LGTM

This revision is now accepted and ready to land.Oct 21 2015, 5:32 PM
bgamari planned changes to this revision.Oct 23 2015, 4:32 AM

@simonmar, correct, this only works on x86_64 at the moment. That being said, there's no reason why this can't be easily extended to i386. I just need to work out the offsets.

I'll try to add a test today.

bgamari updated this revision to Diff 4624.Oct 23 2015, 4:43 AM
bgamari edited edge metadata.
  • libdw: testsuite infrastructure
  • StgStartup: Setup unwinding for stg_stop_thread
  • Libdw: Remove special treatment for stg_stop_thread
  • Add test for DWARF unwinding through C stack
This revision is now accepted and ready to land.Oct 23 2015, 4:43 AM

The trouble with this test is that the output will depend upon whether base was built with -g, which will ultimately be user-configurable. The two solutions that come to mind are,

  • Just outright skip the test when -g was not used to build the libraries
  • Add more logic to the test harness to select from several stderr files based upon arbitrary criteria
  • Two tests, one which would would be skipped when -g was used and another which would be skipped when -g was not used.

Yes, I'd say skip the test if -g wasn't used (but ensure that validate enables -g)

bgamari abandoned this revision.Nov 1 2015, 8:22 AM

This was merged as d9f886282c605e5f4b74126b3af8f23771ef03f1

Yes, I'd say skip the test if -g wasn't used (but ensure that validate enables -g)

Unfortunately it turns out that there isn't any easy way to do this as we can't examine GhcLibHcOpts in the testsuite (as we may be running against an externally-provided compiler).