I've encountered something else that I don't understand. This time regarding dwarf.AttrDeclFile and how the value of that field relates to the list of source files in the project
>From what I can understand, the value of AttrDeclFile is an index into an array of filenames. If the number is zero then the indicates that no source file has been specified. The dwarf package allows retrieval of the file list with LineReader.Files() function - the LineReader being created with reference to the current compilation unit. For most ELF/DWARF examples I have, my understanding seems correct. However, in one example I have, the value of AttrDeclFile can exceed the length of the file array returned by LineReader.Files(). An invalid reference in other words. Moreover, for AttrDeclFiles values that are within range of the array, they are most definitely referencing the wrong file. I'm I misunderstanding the relationship between AttrDeclFile and LineReader.Files(), is there some other way of accessing the file array, or has something gone horribly wrong? Regards, Steve. On Monday, February 7, 2022 at 3:50:07 PM UTC stephen.t....@gmail.com wrote: > That does help. > > I was confused because I was seeing InlinedSubroutines linking back to an > abstract Subroutine, but without a corresponding concrete Subroutine. But > according to the document, if all calls to the abstract Subroutine are > inlined the concrete Subroutine is not included in the DWARF data, leaving > only the abstract Subroutine and the InlinedSubroutines. That makes sense. > > Thanks, Steve > > On Monday, February 7, 2022 at 12:29:30 PM UTC th...@google.com wrote: > >> For general information on DWARF and inlining, you might look at this >> design doc: >> >> >> https://github.com/golang/proposal/blob/master/design/22080-dwarf-inlining.md#example >> >> which describes the changes made to the compiler to add DWARF inlining >> support. HTH. >> >> Thanks, Than >> >> >> On Sat, Feb 5, 2022 at 4:44 AM stephen.t....@gmail.com < >> stephen.t....@gmail.com> wrote: >> >>> >>> (This is possibly off-topic) >>> >>> I'm trying to decode the DWARF data in an ELF binary and I'm not sure >>> how to handle functions. >>> >>> I'm using the elf/dwarf package in the Go standard library and >>> successfully using it to identify compile units and source files and also >>> to find line entries for an executed address. >>> >>> What I can't see is how to relate a dwarf.LineEntry to a function (or >>> SubProgram as it is called in DWARF terminology). >>> >>> If the SubProgram TAG has both Low PC and High PC attributes then I can >>> see how it can be done. Where it gets tricky is if a SubProgram has been >>> inlined. >>> >>> What I don't fully understand is how InlinedSubPrograms relate to >>> SubPrograms. >>> >>> I realise that this isn't really a Go question but I'm hoping someone >>> has used the Go standard library in this way and understands how to solve >>> this problem. >>> >>> Thanks. >>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "golang-nuts" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to golang-nuts...@googlegroups.com. >>> To view this discussion on the web visit >>> https://groups.google.com/d/msgid/golang-nuts/6b1b4e4f-e9af-4954-9296-de50b4d548f5n%40googlegroups.com >>> >>> <https://groups.google.com/d/msgid/golang-nuts/6b1b4e4f-e9af-4954-9296-de50b4d548f5n%40googlegroups.com?utm_medium=email&utm_source=footer> >>> . >>> >> -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/f8a44142-ca17-475c-a77e-af70657db5adn%40googlegroups.com.