This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

call tree manipulation and common block subroutines

Hello,

I am using a function pointer table, defined in an independent c file as this:

/* file: sensor_interface.c */

sensor_driver_t code sensor_drivers[Sensor_Drv_MAX] =   {
                                                            {
                                                                &elect_Initialize,
                                                                &elect_Manager,
                                                                &elect_SetPowerState,
                                                                &elect_TestMode
                                                            },
                                                            {
                                                                &av5555_Initialize,
                                                                &av5555_Manager,
                                                                &av5555_SetPowerState,
                                                                &av5555_OpticalTestMode
                                                            }
                                                        };

In another file I am calling these functions via the function pointer, like this:

/* file: main.c */
void CallSensorDriver(unsigned char curr_sensor)
{
   (&sensor_drivers[curr_sensor])->init();
   (&sensor_drivers[curr_sensor])->power(ACTIVE);
}

If I use the optimization level 9 (common block subroutines) I get this call tree: (extract)

CALLSENSORDRIVER/MAIN -----
  +--> ?PR?MAIN

If I use optimization level 8 i get this:

CALLSENSORDRIVER/MAIN -----
  +--> ?CO?SENSOR_INTERFACE

In both cases i get this:

?CO?SENSOR_INTERFACE
  +--> ?PR?ELECT_INITIALIZE?ELECT
  +--> ?PR?ELECT_MANAGER?ELECT
  +--> ?PR?_ELECT_SETPOWERSTATE?ELECT
  +--> ?PR?ELECT_OPTICALTESTMODE?ELECT
  +--> ?PR?AV5555_INITIALIZE?AV5555
  +--> ?PR?AV5555_MANAGER?AV5555
  +--> ?PR?_AV5555_SETPOWERSTATE?AV5555
  +--> ?PR?AV5555_OPTICALTESTMODE?AV5555

Reading the generated assembly code, I see that the segment ?PR?MAIN is generated by the compiler to put all the code that it will reuse when it thinks it is OK to do so. (In this case it is reusing the code to generate the indirect function call)

My question is:
Shouldn't the segment ?PR?MAIN appear in the call tree also?

What about the functions being called indirectly from CallSensorDriver() ? Will the generated overlay be correct?

Your comments are welcome,
Thanks,
Nestor

0