Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Add work around a bug in lldb on a core dump #1327

Merged
merged 1 commit into from
Aug 4, 2015

Conversation

mikem8361
Copy link

The lldb bug is that the system ids (TIDs) are wrong. They are the same as the thread indexes.

First find the managed thread os id is:

(lldb) sos Threads
Lock
ID OSID ThreadOBJ State GC Mode GC Alloc Context Domain Count Apt Exception
1 1 3787 00000000006547F8 20220 Preemptive 00007FFFCC0145D0:00007FFFCC015FD0 00000000006357F8 0 Ukn
6 2 3790 0000000000678FB8 21220 Preemptive 0000000000000000:0000000000000000 00000000006357F8 0 Ukn (Finalizer)

(lldb) thread list
Process 0 stopped

  • thread Merge changes from TFS #1: tid = 0x0000, 0x00007f01fe64d267 libc.so.6__GI_raise(sig=6) + 55 at raise.c:55, name = 'corerun', stop reason = signal SIGABRT thread #2: tid = 0x0001, 0x00007f01fe7138dd libc.so.6, stop reason = signal SIGABRT thread #3: tid = 0x0002, 0x00007f01fd27dda0 libpthread.so.0__pthread_cond_wait + 192, stop reason = signal SIGABRT
    thread Changes to Miscellaneous test project and runtest #4: tid = 0x0003, 0x00007f01fd27e149 libpthread.so.0`__pthread_cond_timedwait + 297, stop reason = signal SIGABRT
    thread Fix build breaks in GC sample project #5: tid = 0x0004, 0x00007f01fe70f28d libc.so.6, stop reason = signal SIGABRT
    thread Add build status badge #6: tid = 0x0005, 0x00007f01fe70f49d libc.so.6, stop reason = signal SIGABRT

Then use the new command "setsostid" to set the current thread using the "OSID" from above:
(lldb) setsostid 3790 6
Set sos thread os id to 0x3790 which maps to lldb thread index 6

Now ClrStack should dump that managed thread:
(lldb) sos ClrStack

To undo the effect of this command:
(lldb) setsostid

Also added "setclrpath" command that allows the path that sos/dac/dbi are loaded from to be changes instead of using the coreclr path. This may be needed if loading a core dump and the debugger binaries are in a different directory that what the dump has for coreclr's path.

…p where the system ids (TIDs) are wrong.

First find the managed thread os id is:

(lldb) sos Threads
                                                                                                                                                           Lock
       ID OSID ThreadOBJ           State GC Mode     GC Alloc Context                  Domain           Count Apt Exception
   1    1 3787 00000000006547F8    20220 Preemptive  00007FFFCC0145D0:00007FFFCC015FD0 00000000006357F8 0     Ukn
   6    2 3790 0000000000678FB8    21220 Preemptive  0000000000000000:0000000000000000 00000000006357F8 0     Ukn (Finalizer)

(lldb) thread list
Process 0 stopped
* thread #1: tid = 0x0000, 0x00007f01fe64d267 libc.so.6`__GI_raise(sig=6) + 55 at raise.c:55, name = 'corerun', stop reason = signal SIGABRT
  thread #2: tid = 0x0001, 0x00007f01fe7138dd libc.so.6, stop reason = signal SIGABRT
  thread #3: tid = 0x0002, 0x00007f01fd27dda0 libpthread.so.0`__pthread_cond_wait + 192, stop reason = signal SIGABRT
  thread #4: tid = 0x0003, 0x00007f01fd27e149 libpthread.so.0`__pthread_cond_timedwait + 297, stop reason = signal SIGABRT
  thread #5: tid = 0x0004, 0x00007f01fe70f28d libc.so.6, stop reason = signal SIGABRT
  thread dotnet#6: tid = 0x0005, 0x00007f01fe70f49d libc.so.6, stop reason = signal SIGABRT

Then use the new command "setsostid" to set the current thread using the "OSID" from above:
(lldb) setsostid 3790 6
Set sos thread os id to 0x3790 which maps to lldb thread index 6

Now ClrStack should dump that managed thread:
(lldb) sos ClrStack

To undo the affect of this command:
(lldb) setsostid

Added setclrpath command that allows the path that sos/dac/dbi are loaded from to be changes instead of using
the coreclr path. This may be needed if loading a core dump and the debugger binaries are in a different directory
that what the dump has for coreclr's path.
@mikem8361
Copy link
Author

@adityamandaleeka and @sergiy-k could you review?

@@ -14019,4 +14019,4 @@ Help(PDEBUG_CLIENT Client, PCSTR Args)
return S_OK;
}

#endif // !FEATURE_PAL
#endif // FEATURE_PAL
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not necessarily something to address in this PR, but it looks like there's some hairy #ifdef nesting going on in this file. It took me a while to find the matching #ifndef FEATURE_PAL (I think it's the one at line 12660).

The other issue with it is that there is some inconsistency with what the comments next to the endif's say when they're closing an #ifndef. If there's #ifndef FOO, sometimes the endif is #endif // FOO and elsewhere it's #endif // !FOO. This makes those comments almost useless since you end up having to scroll up to figure out what's going on anyway.

Again, this doesn't need to be fixed in this PR, but I think it would be good to standardize that and also detangle some of the nesting in this file.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it is a big mess. I’ll try to clean this up in the future.

From: Aditya Mandaleeka [mailto:notifications@github.com]
Sent: Monday, August 3, 2015 12:15 PM
To: dotnet/coreclr coreclr@noreply.github.com
Cc: Mike McLaughlin mikem@microsoft.com
Subject: Re: [coreclr] Add work around a bug in lldb on a core dump (#1327)

In src/ToolBox/SOS/Strike/strike.cpphttps://github.com//pull/1327#discussion_r36120010:

@@ -14019,4 +14019,4 @@ Help(PDEBUG_CLIENT Client, PCSTR Args)

 return S_OK;

}

-#endif // !FEATURE_PAL

+#endif // FEATURE_PAL

Not necessarily something to address in this PR, but it looks like there's some hairy #ifdef nesting going on in this file. It took me a while to find the matching #ifndef FEATURE_PAL (I think it's the one at line 12660).

The other issue with it is that there is some inconsistency with what the comments next to the endif's say when they're closing an #ifndef. If there's #ifndef FOO, sometimes the endif is #endif // FOO and elsewhere it's #endif // !FOO. This makes those comments almost useless since you end up having to scroll up to figure out what's going on anyway.

Again, this doesn't need to be fixed in this PR, but I think it would be good to standardize that and also detangle some of the nesting in this file.


Reply to this email directly or view it on GitHubhttps://github.com//pull/1327/files#r36120010.

@mikem8361
Copy link
Author

@dotnet-bot test this please

1 similar comment
@mmitche
Copy link
Member

mmitche commented Aug 4, 2015

@dotnet-bot test this please

mikem8361 pushed a commit that referenced this pull request Aug 4, 2015
Add work around a bug in lldb on a core dump
@mikem8361 mikem8361 merged commit 9fd41c5 into dotnet:master Aug 4, 2015
@mikem8361 mikem8361 deleted the settid branch August 4, 2015 19:06
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants