hrydgard / ppsspp

A PSP emulator for Android, Windows, Mac and Linux, written in C++. Want to contribute? Join us on Discord at https://discord.gg/5NJB6dD or just send pull requests / issues. For discussion use the forums at forums.ppsspp.org.
https://www.ppsspp.org
Other
11.08k stars 2.16k forks source link

Strange for loop in Debugger WebSocketDisasmState::Disasm #18994

Open GermanAizek opened 5 months ago

GermanAizek commented 5 months ago

@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?

https://github.com/hrydgard/ppsspp/blob/d0afdcd94f1ce5346772b45ab9a45dd62498680d/Core/Debugger/WebSocket/DisasmSubscriber.cpp#L343-L345

full code:

https://github.com/hrydgard/ppsspp/blob/d0afdcd94f1ce5346772b45ab9a45dd62498680d/Core/Debugger/WebSocket/DisasmSubscriber.cpp#L333-L345

Nemoumbra commented 5 months ago

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.