Fix gprof profiling to work with both PBP and PRX executables#347
Merged
fjtrujy merged 2 commits intopspdev:masterfrom Jan 12, 2026
Merged
Fix gprof profiling to work with both PBP and PRX executables#347fjtrujy merged 2 commits intopspdev:masterfrom
fjtrujy merged 2 commits intopspdev:masterfrom
Conversation
Member
|
I've been testing this with OceanPop and it works great when not building a prx, but when I do build a prx I get no output from psp-gprof. |
Member
|
With the samples, it works totally fine for a prx. I'm not sure what the difference is. I tried different levels of -g and removing -O2 from the examples, but that didn't make a difference either. |
Member
|
It seems the only scenario that doesn't work is a prx of a C++ application. I created this super basic example where I can reproduce this: https://github.com/sharkwouter/psp-hello-string/tree/test-gprof Do make sure to use the test-gprof branch. |
The profiling library was storing addresses that didn't match the ELF
symbol table, causing psp-gprof to produce empty output.
Changes:
- Store ELF-compatible addresses in gmon.out instead of offset-based
- Add PRX vs PBP detection using page alignment heuristic:
- PRX: loaded at page-aligned addresses, linked at 0
- PBP: loaded at specific link address (not page-aligned)
- Calculate relocation offset for PRX to convert runtime addresses
back to link-time addresses that match ELF symbols
- Update __mcount() and timer_handler() to use link-time addresses
The fix ensures psp-gprof can correctly match profiling data with
ELF symbols for both standard executables (PBP) and relocatable
modules (PRX).
tmp
Member
Author
|
Fixed! Try again |
sharkwouter
approved these changes
Jan 12, 2026
Member
sharkwouter
left a comment
There was a problem hiding this comment.
Works well with C++ now, thanks!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The profiling library was storing addresses that didn't match the ELF
symbol table, causing psp-gprof to produce empty output.
Changes:
module_startfunction exist and if it is the same than_start, given the case it means it is a PRXThe fix ensures psp-gprof can correctly match profiling data with
ELF symbols for both standard executables (PBP) and relocatable
modules (PRX).