This is the mail archive of the insight@sources.redhat.com mailing list for the Insight project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Can it calculate instructions



>> I am considering starting a project for the arm7 or arm9 processor,
>> and I am considering using gcc as compiler and insight as
>> debugger. I have one question on this, is it possible to count
>> instructions with insight ?

Answer: NO and YES.

The answer is: USE THE SOURCE LUKE!

The data is there - but the command to get the data is not present.
There are a number of other things that could be added to the
armulator simulation.

Don't ask me what the N, I, D, whatever cycles are... I don't know you
can "USE THE SOURCE LUKE" and figure that out. I was interested in
instructions too.

The data is not *100%* cycle accurate but it is 'pretty darn close'
for most purposes {Think of wait states, cache line fills, etc - all
depends on the CPU core that you are using and its interfaces both
onchip and off chip} Also note that some CPUs have a harvard arch, and
this effects the cycle counts too... There are too many variables to
make it 100% accurate.

I had to do the exact same thing just this morning. :-> Really!

>> What I need is the possibility to see how many instructions or
>> processor cykles a certain c function takes.

Look in the file ${SOMEWHERE}/sim/arm/wrapper.c - you need to expand
the "sim" command that currently does nothing.  {look for the function
sim_do_command()} and cut/paste the below.

*NOTE* the below has a single problem - if you execute the command
"sim" with no parameters I do not test for this condition and the
program will crash. [You should test the "cmd" variable passed to the
sim_do_command() to see if you got an option or not]

>> static void
>> sim_show_cycles( SIM_DESC sd, char *cmd )
>> {
>>   /* tell us about the cycles */
>>   (*sim_callback->printf_filtered)
>>     (sim_callback,"NumScycles: %d\n", state->NumScycles );
>> 
>>   (*sim_callback->printf_filtered)
>>     (sim_callback,"NumNcycles: %d\n", state->NumNcycles );
>> 
>>   (*sim_callback->printf_filtered)
>>     (sim_callback,"NumIcycles: %d\n", state->NumIcycles );
>> 
>>   (*sim_callback->printf_filtered)
>>     (sim_callback,"NumCcycles: %d\n", state->NumCcycles );
>> 
>>   (*sim_callback->printf_filtered)
>>     (sim_callback,"NumFcycles: %d\n", state->NumFcycles );
>> 
>>   (*sim_callback->printf_filtered)
>>     (sim_callback," NumInstrs: %d\n", state->NumInstrs );
>> }
>> 
>> struct sim_cmd {
>>   const char *cmd;
>>   void (*func)( SIM_DESC sd, char *cmd );
>> };
>> 
>> 
>> 
>> static struct sim_cmd sim_cmd_table[] = {
>> 
>>   { "show_cycles", sim_show_cycles },
>>   /* ADD MORE HERE */
>> 
>>   /* TERMINATE */
>>   { NULL, NULL }
>> };
>> 
>> 
>> void
>> sim_do_command (sd, cmd)
>>      SIM_DESC sd;
>>      char *cmd;
>> {  
>>   int l;
>>   char buf[100];
>>   char *firstword;
>>   struct sim_cmd *p;
>> 
>>   /* is it too big to fit in our buffer? */
>>   l = strlen(cmd);
>>   if( (l+1) >= sizeof(buf) ){
>> 
>>     /* then complian */
>>     (*sim_callback->printf_filtered)
>>       (sim_callback,"Command too long\n");
>>     return;
>>   }
>>   
>>   /* make a private copy so strtok() has work space */
>>   strcpy( buf,cmd);
>> 
>>   /* grab the first word, the command */
>>   firstword = strtok( buf, " \t" );
>>   
>>   /* Look up in the array of commands */
>>   p = &(sim_cmd_table[0]);
>>   while( p->cmd ){
>> 
>> 
>>     /* if match */
>>     if( 0 == strcmp( firstword, p->cmd ) ){
>>       /* call handler func */
>>       (*(p->func))(sd,cmd);
>>       return;
>>     }
>>     /* next command */
>>     p++;
>>   }
>> 
>>   (*sim_callback->printf_filtered)
>>     (sim_callback,
>>      "sorry command: %s not found\n", firstword );
>> }
>> 
>> 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]