Re: [Dwarf-Discuss] Stack tracing and return addresses off by 1

2020-07-31 Thread Tye, Tony via Dwarf-Discuss
To add to what Greg described you may also want to look at section 6.4.4 of the 
DWARF 5 specification that discusses these issues. In particular note the 
non-normative description in the fourth paragraph.

> 6.4.4 Call Frame Calling Address
> 
> *When virtually unwinding frames, consumers frequently wish to obtain the 
> address of the instruction which called a subroutine. This information is not 
> always provided. Typically, however, one of the registers in the virtual 
> unwind table is the Return Address.*
> 
> If a Return Address register is defined in the virtual unwind table, and its 
> rule is  undefined (for example, by DW_CFA_undefined), then there is no 
> return address and no call address, and the virtual unwind of stack 
> activations is complete.
> 
> *In most cases the return address is in the same context as the calling 
> address, but that need not be the case, especially if the producer knows in 
> some way the call never will return. The context of the ’return address’ 
> might be on a different line, in a different lexical block, or past the end 
> of the calling subroutine. If a consumer were to assume that it was in the 
> same context as the calling address, the virtual unwind might fail.*
> 
> *For architectures with constant-length instructions where the return address 
> immediately follows the call instruction, a simple solution is to subtract 
> the length of an instruction from the return address to obtain the calling 
> instruction. For architectures with variable-length instructions (for 
> example, x86), this is not possible. However,  subtracting 1 from the return 
> address, although not guaranteed to provide the exact calling address, 
> generally will produce an address within the same context as the calling 
> address, and that usually is sufficient.*

Thanks,
-Tony Tye
___
Dwarf-Discuss mailing list
Dwarf-Discuss@lists.dwarfstd.org
http://lists.dwarfstd.org/listinfo.cgi/dwarf-discuss-dwarfstd.org


Re: [Dwarf-Discuss] modeling different address spaces

2020-07-31 Thread Tye, Tony via Dwarf-Discuss
A compiler may promote part of a variable to a scratch pad memory address space.

Thanks,
-Tony Tye

-Original Message-
From: Michael Eager

On 7/30/20 5:17 PM, Tye, Tony via Dwarf-Discuss wrote:
> For optimized code involving multiple address spaces it is possible to 
> run into cases where the location of a source language variable 
> requires multiple address spaces. For example, a source variable may 
> be optimized and different pieces may be in different places including 
> memory of multiple address spaces, registers, etc.

Can you explain this more?

DWARF handles the situation where part of a variable is in memory and part in a 
register or in multiple registers.  When would you have a variable which was in 
multiple address spaces?

--
Michael Eager
___
Dwarf-Discuss mailing list
Dwarf-Discuss@lists.dwarfstd.org
http://lists.dwarfstd.org/listinfo.cgi/dwarf-discuss-dwarfstd.org


Re: [Dwarf-Discuss] modeling different address spaces

2020-07-30 Thread Tye, Tony via Dwarf-Discuss
For optimized code involving multiple address spaces it is possible to run into 
cases where the location of a source language variable requires multiple 
address spaces. For example, a source variable may be optimized and different 
pieces may be in different places including memory of multiple address spaces, 
registers, etc. Describing this situation with a DW_AT_address_class on a 
source language variable is not possible as it provides a single address space 
that applies to the variable as a whole. The concept of "address space" is not 
available on the expression stack where a composite location description is 
created.



Instead, making address space a property of memory location descriptions and 
making location descriptions a first-class concept on the expression stack 
solves the problem in a general way and leads to other nice properties.



Thanks,

-Tony

___
Dwarf-Discuss mailing list
Dwarf-Discuss@lists.dwarfstd.org
http://lists.dwarfstd.org/listinfo.cgi/dwarf-discuss-dwarfstd.org