Re: [Dwarf-discuss] Question on DW_AT_low_pc for "repeated" DW_TAG_subprogram

2024-05-22 Thread Martin via Dwarf-discuss

On 20/05/2024 22:34, David Blaikie via Dwarf-discuss wrote:
On Thu, May 16, 2024 at 1:05 PM Martin via Dwarf-discuss 
> wrote:


On 16/05/2024 21:58, Martin via Dwarf-discuss wrote:

 >
 > If there is code (with debug info) that uses a class/struct that is
 > defined in a unit WITHOUT debug info (or at least a base class is
 > in such a 
 > unit), then IMHO the debugger should be able to show the entire

 > structure, including fields/methods from that unit without debug
info.
 >
 > For that, the declaration of that class can be repeated. But if
the user
 > then wants to call (from the debugger) a function on that (base-)
class,
 > then it needs the DW_AT_low_pc?


Oh, perhaps the easier thing is to address this question directly.

I believe this is done with existing producers and consumers by having 
the DW_AT_linkage_name attached to the function declaration. Hmm, just 
tried with GDB and even if I omit the linkage name, it's able to call 
the function - I guess by using the DWARF it has, and searching the 
mangled names of the symbols, it can demangle them and match them up (or 
create a mangled name from the DWARF to match that up - though that 
might fail in some cases where the DWARF doesn't have enough info to 
produce the matching mangled name) and it knows the return type and can 
decode the bits to render them correctly.


So, there's a couple of options at least.



Many thanks.

That gives indeed a couple of working options.



--
Dwarf-discuss mailing list
Dwarf-discuss@lists.dwarfstd.org
https://lists.dwarfstd.org/mailman/listinfo/dwarf-discuss


[Dwarf-discuss] Question: Clarification for DW_AT_string_length

2024-05-22 Thread Martin via Dwarf-discuss
DW_AT_string_length is described as "that provides the value of the 
length of the string"


Is that the length in characters or bytes?

That matters for e.g. Utf-16 when the DW_TAG_base_type for the char has 
a DW_AT_byte_size of 2 (or more).




Below is from the draft for DWARF-6, but the same info is in earlier 
versions.



5.11 String Type Entries
 The string type entry may also have a DW_AT_string_length attribute whose
 value is either (a) a reference (see Section 2.19) to another debugging 
information
 entry that provides the value of the length of the string, or (b) a location
 description yielding the location where the length of the string is stored in 
the
 program. If the DW_AT_string_length attribute is not present, the size of the
 string is assumed to be the amount of storage that is allocated for the string 
(as
 specified by the DW_AT_byte_size or DW_AT_bit_size attribute)


--
Dwarf-discuss mailing list
Dwarf-discuss@lists.dwarfstd.org
https://lists.dwarfstd.org/mailman/listinfo/dwarf-discuss


[Dwarf-discuss] Proposal: add DW_AT_lower_bound to DW_TAG_string_type

2024-05-22 Thread Martin via Dwarf-discuss



# Proposal to add DW_AT_lower_bound to DW_TAG_string_type

## Background

Pascal normally use 1-based indexes for strings. But it can also 
generate strings with a 0-based index.


Other languages may have varying defaults.

For a debugger to show the result of an expression like
  `MyString[5]`
the start value of the index is needed.


## Proposed Changes

1. Allow DW_AT_lower_bound as an attribute in DW_TAG_string_type.

2. Define a list of language specific defaults (as exists for subrange 
low bounds)


The default for DW_LANG_Pascal83 should be `1`

## References

http://docwiki.embarcadero.com/RADStudio/Athens/en/Zero-based_strings_(Delphi)
Also supported by FreePascal
--
Dwarf-discuss mailing list
Dwarf-discuss@lists.dwarfstd.org
https://lists.dwarfstd.org/mailman/listinfo/dwarf-discuss