fix: walk down type ref debug info when matching symbols#60
fix: walk down type ref debug info when matching symbols#60DanielT merged 3 commits intoDanielT:masterfrom
Conversation
|
Generally I've tried to avoid having extra match arms for the TypeRef cases all over the code. The way to do this is the api This call is missing in the match arm for the array. Rather than your fix, I would prefer to add In symbol.rs, line 328 That way |
|
by the way - I'm not surprised this bug remained hidden until now. Representing the array type with a reference is very rare for DWARF2 debug data, and I think I only ever saw that case once when I added the code whose comment you quoted above. |
|
here, we are using PDB for the virtual ECUs, thanks for the support. I will make the changes you mentioned. |
|
one more question, if I make the change you mentioned, is it going to work with nested TypeRef? should the get_reference eventually recursively walk down the TypeRef? |
Signed-off-by: Louis Caron <caron_louis@yahoo.fr>
| dbgdata.types.insert( | ||
| 86308, | ||
| TypeInfo { | ||
| name: Some("structtype".to_string()), | ||
| unit_idx: 0, | ||
| datatype: DbgDataType::TypeRef(86352, 2), | ||
| dbginfo_offset: 86308, | ||
| }, | ||
| ); |
There was a problem hiding this comment.
data type 86308 is unused in this test case, so it should be removed
src/symbol.rs
Outdated
| size: 20, | ||
| dim: vec![10], | ||
| stride:2, | ||
| arraytype: Box::new(structtype), |
There was a problem hiding this comment.
alternatively, perhaps you meant to use the TypeRef here.
It seems to me that referring directly to the structtype means the test does not exercise the case where the array element type is a TypeRef.
It's not clear to me what code path you're trying to exercise?
DanielT
left a comment
There was a problem hiding this comment.
Your code change is fine.
The test needs a bit of work.
I saw CI raised a lint error regarding code that you didn't touch - you can ignore that, I'll fix it separately.
|
actually, i can explain. I created the types that are created by the parsing of the PDB file. and for a long time i hesitated between resolving the typeref during the parsing or during the symbol type lookup. in the end i chose the symbol type lookup and it made sense regarding your suggestion. but the pdb parsing still does some kind of typeref dereferencing since the intermediate typeref is not referenced by the array type (which i could not figure out why and this is initially why i thought it should be done during the parsing). well you know everything know, but since i am not the owner, i will do what you tell me to. |
|
My concern with the test is that I'll eventually need to understand what it does and why it does that. At that time I will probably no longer remember the details of this PR. I've written unfocused tests myself, and they're a pain - when a bad test breaks it might not be clear if the code or the test should be fixed. |
|
I will remove the extra typeref creation from the current pr, and I will make a new PR with a full new test for the typeref recurring.but for this, could you confirm that in the pdb with two nested typeref I should end up with two nested typer f in the parsed debugging data? |
59821fd to
b92421c
Compare
Signed-off-by: Louis Caron <caron_louis@yahoo.fr>
Signed-off-by: Louis Caron <caron_louis@yahoo.fr>
|
I followed your advice... maybe too much ;-). I started by creating a minimal test exhibiting the issue (with one typeref), but it was not failing the test because actually the find type works find but returns a typeref as the typeinfo of the result. I figured that this was not really what you wanted (you want an actual type), so i added the test to check the returned type and since i was at it, i modified the test to add a second typeref level (as pdb parsing could do it), and i had to modify the get_reference to iterate as long as it matches typerefs |
|
Looks good. Thanks for the fix! |
|
thanks for you for all the work you've put in the tool |
I am encountering an issue when updating the A2L file with addresses from a PDB file. The main error reported is:
Remaining portion "X" of "Y" could not be matchedAfter inspecting both the A2L and PDB files, I confirmed that the required information is present, so I started investigating a possible fix. I implemented a change in the symbol search walk mechanism, but I am not fully confident about this implementation because it may impact the debug information parsed from the ELF file, where you had previously added the following comment:
I was wondering whether the type reference in the ELF debug information has the same semantics as the type reference inferred during PDB parsing.
PS: Even after this change, the tool still reports some errors, although the PDB and A2L files appear to be correct. I will likely push additional changes, but I wanted to check with you first to make sure I am not heading in the wrong direction with this initial fix.
PS2: i have just added a unit test for this case