Debugger: sceKernelPrintf improvement, QOL adjustments#17263
Debugger: sceKernelPrintf improvement, QOL adjustments#17263hrydgard merged 1 commit intohrydgard:masterfrom
Conversation
|
Yeah seems likely that printf (varargs) parameters go through regular registers. I do seem to recall that floating point arguments to regular functions can go through fp registers, but didn't check now. |
| stream << f_arg; | ||
| result += stream.str(); | ||
|
|
||
| ++i; | ||
| stream.str(std::string()); // Reset the stream |
There was a problem hiding this comment.
To clarify my previous comment about this, here's what I would have done here:
char temp[64];
snprintf(temp, sizeof(temp), "%f", f_arg);
result += temp;Though, to be fair, yours is better "C++", mine is just reflective of my somewhat excessive obsession with avoiding allocations. Doing that is important when running PPSSPP in debug mode for things that happen a lot, but since this shouldn't be very spammy, doing it the C++ way is fine and I'm not even sure in reality that there's more than one excessive allocation happening here (the stringstream has to allocate a buffer, while my way allocates it on the stack which is cheaper).
|
The raw As for |
|
That's a good point about copy - roundtrippable would be good there. |
|
#17203 (comment) |
Oh, yes, I was wrong: Still, |
|
Of course, we're not done with sceKernelPrintf. I only added the %f flag, but no precision params are available as of now. I guess, this is a PoC.
|
For those curious: the formula is |
Now sceKernelPrintf can print %f floats. Note: it doesn't use the floating registers (if anyone has some evidence of a real PSP game that prepares f0 or something before the call, please do show).

Example with a1 equal to 0x3f8ccccd:
The "Copy Float (32 bit)" menu item has been moved to its own section because I suspect some people might have memorized the layout and thus experience slight inconveniences due to it now being the last element. Well, that's no longer a problem. We may also later add other floating types here.
This commit does not fix the recently added menu item so I decided to do that.

I have also renamed it to have consistent terms across the code:
Lastly, check the notes here: https://en.cppreference.com/w/cpp/io/basic_stringstream/str