gnustep-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Debugging on Linux with non-fragile ABI?


From: David Chisnall
Subject: Re: Debugging on Linux with non-fragile ABI?
Date: Mon, 18 Nov 2019 15:15:34 +0000
User-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101 Thunderbird/68.2.2

On 18/11/2019 11:04, Richard Frith-Macdonald wrote:
Interesting.  I'd very much like to see support for nonfragile objects in 
debuggers.
How could this work for core dumps?  Is it even possible to examine instance 
variables in core dumps when the nonfragile ABI is used?

If someone wants to do the integration work, I don't see why not. Non-fragile IVar layouts are described here:

https://github.com/gnustep/libobjc2/blob/108d4e19c0ed5443419279ab9998bc93da7d3f19/ABIDoc/abi.tex#L282

In summary, the offset is stored in a variable with the name:

__objc_ivar_offset_{class name}.{ivar name}.{type encoding}

There are a few complexities from the non-fragile model. In particular, consider two classes, A and B, where B is a subclass of A. The non-fragile ABI allows A and B to both define an ivar v. There will; however, be only one:

__objc_ivar_offset_A.v.{something}

And only one:

__objc_ivar_offset_B.v.{something}

Starting from an object pointer and looking for an ivar called v, you first need to check that the low {1,3} bits (for {32,64}-bit platforms) are 0. If they are not, then you need to look in the SmallObjectClasses array to find the class. This is an array of class pointers, indexed by the low bits. If the low bits are 0, then this is a pointer[1].

If it is a small object, then you don't have any ivars, but you can call methods on it that will handle data stored in the top bits.

If it is not a small object, you can follow the class pointer and look at its name field. You can then look for any globals matching the pattern:

__objc_ivar_offset_{class name}.v.{anything}.

If you find one, then you can add this offset to the object pointer and get the ivar. If you don't, then follow the super-class pointer and try again.

If the prompt has an explicit cast to a superclass in it then you can start at the expected class. If you want to build a list of all classes in the system then walk all of the sections for each module that contain classes.

David

[1] For now. The Apple runtime steals the top 16 bits to store the refcount and I'd like to do that at some point as well, which should reduce object sizes.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]