This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: RFC: change needs_frame_tls_address


> For this we get a warning from value_static_field, then things go
> downhill and we hit an internal_error.  From the PR:

(...)

> After tracing through the TLS code for a bit, I have concluded that TLS
> does not really need a frame, at least not in the gdb sense.  Instead, I
> think it only needs registers -- a funny sort of distinction to make,
> but nevertheless...

Given that if you have registers, you always have a frame, I don't
think that's a good check.

>     (gdb) p A::num
>     $1 = 1
>     (gdb) kill
>     Kill the program being debugged? (y or n) y
>     (gdb) p A::num
>     Cannot access memory at address 0xb7fdb6d8

Is that useful?  It seems to be trying to print a bogus
address.  Actually, I'm surprised you even got that memory error
instead of "Cannot find thread-local variables on this target", which
is what I get on x86-64 (both -m64/-m32) with your change applied.
Clearly gdb didn't try reading any register, otherwise, you would see
some other error.  Do you have other changes in your tree perhaps?

> If it is not acceptable, I would appreciate some enlightenment as to
> what other approach I should take.

The warning seems bogus to me:

> (gdb) print A::num
> warning: static field's value depends on the current frame - bad debug info?
> findvar.c:427: internal-error: read_var_value: Assertion `frame' failed.
> A problem internal to GDB has been detected,
> further debugging may prove unreliable.
> Quit this debugging session? (y or n) 

I think we should throw an error instead, just like what you get when
you try to print a non class static global TLS variable:

 __thread int global_num = 1;

Both cases are the same in the user's perpective, so should behave
equal.  Trying to print `global_num' with no process/core throws an
error in value_of_variable.  I guess we should make value_static_field
use value_of_variable instead of read_var_value directly too (or a factored
out variant that doesn't throw if read_var_value returns NULL).

-- 
Pedro Alves


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]