From: Duane Ellis <duane_ellis@franklin.com>
To: kivik@firstlinux.net
Cc: insight@sources.redhat.com
Subject: Re: Can it calculate instructions
Date: Thu, 06 Feb 2003 20:25:00 -0000 [thread overview]
Message-ID: <200302062025.h16KPeo15899@europa.franklin.com> (raw)
In-Reply-To: <20030206195957.0EA5B3FBE@sitemail.everyone.net> (message from Matts on Thu, 6 Feb 2003 11:59:56 -0800 (PST))
>> 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 );
>> }
>>
>>
next prev parent reply other threads:[~2003-02-06 20:25 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-02-06 20:00 Matts
2003-02-06 20:25 ` Duane Ellis [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200302062025.h16KPeo15899@europa.franklin.com \
--to=duane_ellis@franklin.com \
--cc=insight@sources.redhat.com \
--cc=kivik@firstlinux.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).