public inbox for insight@sourceware.org
 help / color / mirror / Atom feed
* Can it calculate instructions
@ 2003-02-06 20:00 Matts
  2003-02-06 20:25 ` Duane Ellis
  2003-02-06 20:41 ` Martin M. Hunt
  0 siblings, 2 replies; 6+ messages in thread
From: Matts @ 2003-02-06 20:00 UTC (permalink / raw)
  To: insight

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 ?

I would really need to calculate processor cycles, but I guess that is not possible with insight ?

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

_____________________________________________________________
Want a new web-based email account ? ---> http://www.firstlinux.net

_____________________________________________________________
Select your own custom email address for FREE! Get you@yourchoice.com w/No Ads, 6MB, POP & more! http://www.everyone.net/selectmail?campaign=tag

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Can it calculate instructions
  2003-02-06 20:00 Can it calculate instructions Matts
@ 2003-02-06 20:25 ` Duane Ellis
  2003-02-06 20:31   ` Keith Seitz
  2003-02-06 20:41 ` Martin M. Hunt
  1 sibling, 1 reply; 6+ messages in thread
From: Duane Ellis @ 2003-02-06 20:25 UTC (permalink / raw)
  To: kivik; +Cc: insight



>> 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 );
>> }
>> 
>> 

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Can it calculate instructions
  2003-02-06 20:25 ` Duane Ellis
@ 2003-02-06 20:31   ` Keith Seitz
  2003-02-06 20:48     ` Duane Ellis
  0 siblings, 1 reply; 6+ messages in thread
From: Keith Seitz @ 2003-02-06 20:31 UTC (permalink / raw)
  To: insight; +Cc: kivik

On Thu, 2003-02-06 at 12:25, Duane Ellis wrote:
> >> 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!

Hmm.. Do I smell a plugin?

O:-)
Keith

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Can it calculate instructions
  2003-02-06 20:00 Can it calculate instructions Matts
  2003-02-06 20:25 ` Duane Ellis
@ 2003-02-06 20:41 ` Martin M. Hunt
  1 sibling, 0 replies; 6+ messages in thread
From: Martin M. Hunt @ 2003-02-06 20:41 UTC (permalink / raw)
  To: kivik; +Cc: insight

On Thu, 2003-02-06 at 11:59, Matts wrote:
> 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 ?

Insight can show any function disassembled so you can see how many
instructions there are.  You can do the same with the objdump utility.

Remember you really don't want to try to use a source debugger on highly
optimized code.

> I would really need to calculate processor cycles, but I guess that 
> is not possible with insight ?

There are better ways to do what you want.

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

Counting instructions is easy.  Counting CPU cycles requires a CPU
simulator. However I don't believe the GNU arm simulator does that. Even
with a perfect simulator, real world results can vary greatly due to
memory and cache interactions, etc.  It is usually much easier and more
accurate to just measure the CPU time your function takes on a working
system.

Martin


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Can it calculate instructions
  2003-02-06 20:31   ` Keith Seitz
@ 2003-02-06 20:48     ` Duane Ellis
  2003-02-06 21:15       ` Keith Seitz
  0 siblings, 1 reply; 6+ messages in thread
From: Duane Ellis @ 2003-02-06 20:48 UTC (permalink / raw)
  To: insight


>> Hmm.. Do I smell a plugin?

Actually - there could be lots of plugins for the ARM CPU, think about
a Tcl/Tk window that pops up and lets you look at the contents of the
caches - the co-processor bits and all that sort of stuff.

Who knows lots about plugins?

And that reminds me - I need to embark on some very heavy hackery to
the ARM version of GDB - who out there knows the most about the ARM
stuff in GDB?

I need to add some dma controllers, interrupt controllers, uart and
GPIO, keyboard scanner, nand flash, and all that sort of stuff.

I'd like to have little pop up boxes so you can see the interds of
how the devices are currently configured.

-Duane.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Can it calculate instructions
  2003-02-06 20:48     ` Duane Ellis
@ 2003-02-06 21:15       ` Keith Seitz
  0 siblings, 0 replies; 6+ messages in thread
From: Keith Seitz @ 2003-02-06 21:15 UTC (permalink / raw)
  To: duane_ellis; +Cc: insight

On Thu, 2003-02-06 at 12:48, Duane Ellis wrote:
> >> Hmm.. Do I smell a plugin?
> 
> Actually - there could be lots of plugins for the ARM CPU, think about
> a Tcl/Tk window that pops up and lets you look at the contents of the
> caches - the co-processor bits and all that sort of stuff.
> 
> Who knows lots about plugins?

This list is the best resource.

> And that reminds me - I need to embark on some very heavy hackery to
> the ARM version of GDB - who out there knows the most about the ARM
> stuff in GDB?

The folks on the gdb list, gdb@sources.redhat.com.

Keith


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2003-02-06 21:15 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-02-06 20:00 Can it calculate instructions Matts
2003-02-06 20:25 ` Duane Ellis
2003-02-06 20:31   ` Keith Seitz
2003-02-06 20:48     ` Duane Ellis
2003-02-06 21:15       ` Keith Seitz
2003-02-06 20:41 ` Martin M. Hunt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).