Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement gdb query "qGetTLSAddr" #146

Closed
joneschrisg opened this issue Jun 25, 2013 · 9 comments
Closed

Implement gdb query "qGetTLSAddr" #146

joneschrisg opened this issue Jun 25, 2013 · 9 comments

Comments

@joneschrisg
Copy link
Contributor

I'm debugging an issue right now where that query is needed to resolve a symbol. (Why, I dunno, since the symbol isn't TLS, but oh well.) Unfortunately this looks quite tricky to implement. It appears that valgrind punted it.

@joneschrisg joneschrisg added this to the 1.1 milestone Mar 22, 2014
@joneschrisg
Copy link
Contributor Author

Tentatively setting for 1.1 because it's a likely annoyance for devs. Though the valgrind example is encouraging (though may no longer be true).

@joneschrisg joneschrisg removed this from the 1.1 milestone Mar 27, 2014
@joneschrisg
Copy link
Contributor Author

Took a more serious look at doing this. The first thing we'd need to do is implement the thread_db interface for the debug server. This would be a lot of work.

http://timetobleed.com/notes-about-an-odd-esoteric-yet-incredibly-useful-library-libthread_db/

The next step would be to call the right thread_db interface to get the TLS addr per the gdb query. From my reading of the gdb source code, the one we want is td_thr_tls_get_addr().

This is too much work for a 1.1. The workaround for users is to save the TLS addr they're interested in into a local, and then read the local in gdb. (Indeed, I've used this workaround in rr's preload load several times.)

@joneschrisg
Copy link
Contributor Author

Also, part of the interface that thread_db wants is writing process memory. I don't know what the writes are required for, but if we can't use thread_db without it writing to tracee memory, then we're hosed. (Or the project becomes extremely difficult.)

@tromey
Copy link
Contributor

tromey commented Jul 15, 2016

FWIW I'm debugging an implementation of this.

@rocallahan
Copy link
Collaborator

Excellent!

@tromey
Copy link
Contributor

tromey commented Jul 18, 2016

I have it working, but I'm having some trouble getting the test suite to work properly. I'll ask on irc tomorrow or so.

There's one issue I want to raise as well. This work relies on the proc_service.h header. However, glibc doesn't install this header. (You can follow the glibc bug I filed.)

On my current branch I've just copied this header into the rr source tree. This is what gdb does as well (with extra hacks, haha.) But, maybe that's not really what you want, considering that the file has the LGPL on it.

Another option might be to duplicate the needed stuff. There are a few function types and an enum.

@rocallahan
Copy link
Collaborator

What does it mean to honor the LGPL for this file, if (say) someone wanted to ship rr without honoring the LGPL terms for all of rr?

@rocallahan
Copy link
Collaborator

If we're just using this file as the interface to a dynamically linked glibc library, that we're not shipping, then they wouldn't have to do anything to comply with the LGPL? Except they'd have to make available the source for that one file, I suppose.

tromey added a commit to tromey/rr that referenced this issue Jul 18, 2016
Fixes rr-debugger#146.

This adds support for the qGetTLSAddr and qSymbol packets from gdb,
which lets gdb access TLS in a replay.
@tromey
Copy link
Contributor

tromey commented Jul 18, 2016

It seems like a reasonable interpretation to me.

tromey added a commit to tromey/rr that referenced this issue Jul 20, 2016
Fixes rr-debugger#146.

This adds support for the qGetTLSAddr and qSymbol packets from gdb,
which lets gdb access TLS in a replay.
tromey added a commit to tromey/rr that referenced this issue Jul 21, 2016
Fixes rr-debugger#146.

This adds support for the qGetTLSAddr and qSymbol packets from gdb,
which lets gdb access TLS in a replay.
tromey added a commit to tromey/rr that referenced this issue Jul 22, 2016
Fixes rr-debugger#146.

This adds support for the qGetTLSAddr and qSymbol packets from gdb,
which lets gdb access TLS in a replay.
tromey added a commit to tromey/rr that referenced this issue Jul 25, 2016
Fixes rr-debugger#146.

This adds support for the qGetTLSAddr and qSymbol packets from gdb,
which lets gdb access TLS in a replay.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants