Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strange for loop in Debugger WebSocketDisasmState::Disasm #18994

Open
GermanAizek opened this issue Apr 4, 2024 · 1 comment
Open

Strange for loop in Debugger WebSocketDisasmState::Disasm #18994

GermanAizek opened this issue Apr 4, 2024 · 1 comment

Comments

@GermanAizek
Copy link
Contributor

GermanAizek commented Apr 4, 2024

@hrydgard,
I am confused by this cycle, unless stop is equal to end, and end is equal to next. It will only be executed once, am I right?

for (end = next; end < stop && end >= next; end = disasm_.getNthNextAddress(end, 1)) {
count++;
}

full code:

// Correct end and calculate count based on it.
// This accounts for macros as one line, although two instructions.
u32 stop = end;
u32 next = start;
count = 0;
if (stop < start) {
for (next = start; next > stop; next = disasm_.getNthNextAddress(next, 1)) {
count++;
}
}
for (end = next; end < stop && end >= next; end = disasm_.getNthNextAddress(end, 1)) {
count++;
}

@Nemoumbra
Copy link
Contributor

Assuming the assignment end = disasm_.getNthNextAddress(end, 1) does not make end less than it used to be, the expression end >= next is always evaluated to true (during the first check it's equal to next, so it also holds).
So what I see is for (end = initial_value; end < stopping_value; end = next_value()). So it depends on what the method getNthNextAddress does. I don't see why it should execute only once.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants