Fix ea pattern - #26
Conversation
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
You don't actually have to answer, but I wonder what gets broken. |
No address variable that contains a register or instead of |
|
Things don't seem to add up. Consider Originally it was translated to What would be the expectation for Lcfa_0x028? I get Is it right? What doesn't add up is that I don't see square brackets in compute_address that is being modified here... |
|
Oh right, I did not catch that, sorry. That came from the still-old I now get which looks correct to me. |
| base = int(base, 0) | ||
| addr = base + offset | ||
| addr = ("L0x%0." + str(l) + "x") % addr | ||
| disp = match.group(2) |
There was a problem hiding this comment.
In cases where addresses fall "too far" from the input arguments or CFA, itrace.py will fall back to the original format of L0x1234000. This needs to be handled. Additionally, there is an implicit ambiguity in the function declaration. I mean the ea_pattern=default_ea_pattern part, which doesn't require that the pattern yields two match groups. In other words one needs to be able to handle variable amount of matche groups. Alternatively I wonder if it's possible to solve it with r'L(?:[a-z]\w+_)?(0x\w+)', i.e. with a single-group pattern, and use match.start(1) to split the input to prefix, L, Lcfa_, etc., and the number...
There was a problem hiding this comment.
I think explicitly failing if the if an offset crosses the current stack frame is the best we can do. This should never occur in actually traced code and I don't see a good way to recover the stack base address. Did not read your comment correctly
The original format is already handled by the prefix = ... if base else "L" line.
The ambiguity on what ea_pattern should be was there before as well: It expected at least one group.
I honestly think the best option is to remove the argument entirely and always use default_ea_pattern. But I could also add a comment documenting what kind of match ea_pattern is expected to produce.
There was a problem hiding this comment.
The original format is already handled by the
prefix = ... if base else "L"line.
Right! Sorry about the distraction then. I suppose it could have been more readable... I mean it wasn't clear to me... But on the other hand I'm not in position to claim a connoisseurship here :-) :-) :-)
The ambiguity on what ea_pattern should be was there before as well: It expected at least one group.
My rationale is that it's not reasonable to expect more than one match group, because reference to match.group(>1) is prone to triggerring an exception. Unless of course one handles variable amount of groups explicitly. But it's perfectly reasonable to expect at least one group in if match:...
I honestly think the best option is to remove the argument entirely and always use
default_ea_pattern. But I could also add a comment documenting what kind of matchea_patternis expected to produce.
As for omitting the default_ea_pattern. I would agree, but I'd leave it to the actual maintainers to weigh in.
#21 changed the format of effective address variables. This PR fixes the pattern in
to_zdsl.pysuch that rules containing$1eaand similar apply again.