FS#4834 - Plugin profiling broken.

Attached to Project: Rockbox
Opened by Fredrik Öhrn (ohrn) - Tuesday, 14 March 2006, 23:54 GMT
Task Type Bugs
Status Closed
Assigned To No-one
Operating System All players
Severity Medium
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No


plugin_start() must be declared with NO_PROF_ATTR to prevent it from being instrumented. Right now a plugin will die immediatley with a NULL pointer dereference becasue __cyg_profile_func_enter() gets called before the plugin has a chance to call profile_init().
This task depends upon

Closed by  Brandon Low (lostlogic)
Thursday, 16 March 2006, 17:05 GMT
Reason for closing:  Accepted
Additional comments about closing:  fixed
Comment by Brandon Low (lostlogic) - Wednesday, 15 March 2006, 22:38 GMT
Hmm, praps the profiling functions should be smart enough to not blow up if they are called before prof_start is called instead?

Any interest in looking into that?

Comment by Fredrik Öhrn (ohrn) - Wednesday, 15 March 2006, 23:22 GMT
This can be done by adding "if (!rb_local) return;" to the __cyg_profile_func_enter/exit functions.
Also a new end function is needed:

void profile_end ()
local_rb = NULL;

and plugin_start is required to call it before exiting. This is to make sure we don't get a mismatch where profile_func_enter() is skipped when entering plugin_start() but profile_func_exit() gets called when plugin_start() exits becasue local_rb is still initialized.

The end result is the same as in my suggested patch, profiling is skipped for plugin_start(), this solution is just more roundabout.

Also, profiling codecs have the exact same problem as plugins.
Comment by Brandon Low (lostlogic) - Thursday, 16 March 2006, 17:05 GMT
Will apply, thanks.