[patch] Don't refer to current architecture when allocating a new one

Andrew Cagney ac131313@cygnus.com
Tue Sep 25 20:43:00 GMT 2001


Hello,

The attached fixes a potentially nasty but some what theoretical bug. 
The code in gdbarch_alloc() was refering to macros such as 
``TARGET_LONG_BIT'' when initializing various fields vis:

	gdbarch->target_long_long_bit = 2*TARGET_LONG_BIT;

Unfortunatly such macros refer to the global ``current_gdbarch'' and 
hence the code picks up the value of TARGET_LONG_BIT from the previous 
and not this new architecture :-(  The obvious fix would be to just not 
use the macros.  Unfortunatly due to the way a non-multi-arch 
configuration works, that isn't possible.

The attached addresses the problem by naming local variable designating 
the new architecture ``curent_gdbarch''.  That way all macros refer to 
that local variable and not the global.

As an asside, people multi-arching targets should be aware of this 
potential problem in their code.  I've a follow on patch to ensure it 
doesn't happen but it is some what prutal.

Andrew


More information about the Gdb-patches mailing list