-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
implement sysclib_sprintf #19097
implement sysclib_sprintf #19097
Conversation
Core/HLE/sceKernelInterrupt.cpp
Outdated
int arg_idx = 0; | ||
int fmt_len = 0; | ||
|
||
for(const char *c = Memory::GetCharPointerUnchecked(fmt); *c != '\0'; c++){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please at least roughly follow PPSSPP's general code style throughout. You're close, but we write for(
as for (
, and ) and { are separated by a space (last part of the line).
Core/HLE/sceKernelInterrupt.cpp
Outdated
// going by https://cplusplus.com/reference/cstdio/printf/#compatibility | ||
// no idea what the kernel module really supports as of writing this | ||
|
||
if(*c == '%'){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This if chain would be better written as a switch.
Core/HLE/sceKernelInterrupt.cpp
Outdated
ERROR_LOG(SCEKERNEL, "Fmt: %s", Memory::GetCharPointerUnchecked(fmt)); | ||
ERROR_LOG(SCEKERNEL, "PSP arg reg dump: 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really still want to ERROR_LOG these? Doesn't seem like errors to me, more like the normal execution path.
Core/HLE/sceKernelInterrupt.cpp
Outdated
if (Memory::IsValidAddress(dst) && Memory::IsValidAddress(fmt)) { | ||
// TODO: Properly use the format string with more parameters. | ||
return sprintf((char *)Memory::GetPointerUnchecked(dst), "%s", Memory::GetCharPointerUnchecked(fmt)); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be better to flip the logic of the if and early-out, instead of indenting the entire function.
Core/HLE/sceKernelInterrupt.cpp
Outdated
for(int i = 0;i < 24; i+=8){ | ||
u32 base = psp_stack_pointer + i * 4; | ||
ERROR_LOG(SCEKERNEL, "PSP stack dump: 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This stack dumping should surely not occur on every call. Comment out or something.
Core/HLE/sceKernelInterrupt.cpp
Outdated
read_cnt++; | ||
} | ||
/* | ||
// windows compiler don't like this |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For good reason, dynamic stack allocation is not a good idea.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, you're right, I supposed I should not be too trusty with snprintf's return value being always
Much, much better! Hm, I think the debug logging should maybe be VERBOSE, but I'll go ahead and merge and possibly adjust after. |
It gets through https://github.com/Kethen/psp-string-test/ with the following result