This is the mail archive of the
elfutils-devel@sourceware.org
mailing list for the elfutils project.
Re: dwarf_next_cfi returns -1
On Mon, 2018-06-04 at 16:16 +0000, Sasha Da Rocha Pinheiro wrote:
> We had a case where dwarf_next_cfi returns -1 but the offset does not
> update, as we should expect by the comment:
>
> 330 On errors, returns -1. Some format errors will permit safely
> 331 skipping to the next CFI entry though the current one is
> unusable.
> 332 In that case, *NEXT_OFF will be updated before a -1 return.
> Is there a correct way to deal with it, or just check if the NEXT_OFF
> had changed?
A CFI entry starts with the length of that entry, so dwarf_next_cfi can
often setup the next offset correctly. But if there is anything else
"wrong" with the CFI entry (maybe it has a version or augmentation
string not recognized) then it cannot reliably return the CFI entry. It
is indeed a slightly inconvenient interface, you'll have to check
whether the return value, if it is zero, all is fine, if it is 1 you
reached the end, if it is -1 an error occurred. In that last case, if
you really want to try you can try. *next_off having changed after the
call means it might work (or not).
If you have an example of a "wrong" (or not recognized) CFI that would
be helpful.
Thanks,
Mark