Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Richard Earnshaw <rearnsha@arm.com>
To: DJ Delorie <dj@redhat.com>
Cc: gdb-patches@sources.redhat.com, Richard.Earnshaw@arm.com
Subject: Re: [patch] add trace capabilities to arm sim
Date: Mon, 26 Feb 2001 10:40:00 -0000	[thread overview]
Message-ID: <200102261840.SAA17450@cam-mail2.cambridge.arm.com> (raw)
In-Reply-To: <200102240025.TAA28612@greed.delorie.com>

I haven't seen anyone else comment on this, so I'll stick my nose in ;-)

I can't approve or reject this patch, but:


> 2001-02-23  DJ Delorie  <dj@redhat.com>
> 
> 	* armemu.c (ARMul_Emulate): Add hook for tracing.
> 	* wrapper.c (current_bfd): New, remembers which bfd we're
> 	simulating.
> 	(sim_dis_read): New, helper for tracing.
> 	(remove_useless_symbols): New, helper for tracing.  From objdump.
> 	(compare_symbols): Ditto.
> 	(sim_trace_one_arm_insn): New, trace one instruction using
> 	disassembler.
> 	(sim_trace): Make it do something useful now.
> 	(sim_create_inferior): Save current bfd.
> 	(sim_open): Ditto.
> 	(sim_load): Ditto.
> 	(sim_do_command): Handle the `trace' command.
> 
> 	* wrapper.c (ARMul_Debug): Return insn just in case we're called.
> 

> --- armemu.c	2001/02/24 00:24:39
> *************** ARMul_Emulate26 (register ARMul_State * 
> *** 377,382 ****
> --- 377,383 ----
>         if (instr == 0)
>   	abort ();
>   #endif
> +       sim_trace_one_arm_insn (pc, instr);

This will bump up the cost of simulating each instruction by the overhead 
of this call plus any code within that always gets executed.

Since tracing is going to slow the simulation to a crawl, I think it would 
be better to consider this an "exceptional condition"; that is, put the 
code inside the immediately following test:

>   
>         if (state->Exception)
>   	{			/* Any exceptions */

and then bump state->Exception (which behaves pretty much like a semaphore 
count on the number of extra things to go look at) when tracing needs to 
run.

> + void
> + sim_trace_one_arm_insn(pc, insn)
> + 	      int pc;
> + 	      unsigned int insn;
> + {
> +   static int initted = 0;
> +   static asymbol **symtab = 0;
> +   static int symcount = 0;
> +   static int last_sym = -1;
> +   static struct disassemble_info info;
> +   int storage, sym, bestsym, bestaddr;
> +   int min, max, i, pnl;
> +   static ARMword prevregs[16];
> + 
> +   if (insn == 0)
> +     {
> +       state->Emulate = STOP;

why should executing the (legal) instruction

	andeq	r0, r0, r0

cause the simulation to halt (OK, it's not very useful, but it is a valid 
NOP)?

> +       return;
> +     }
> +   if (current_bfd == 0)
> +     return;
> +   if (!do_tracing)
> +     return;

Shouldn't this be the first thing you check?

>   int
>   sim_trace (sd)
>        SIM_DESC sd ATTRIBUTE_UNUSED;

It is used now... (this is also where you might bump/unbump state->
Exception).

> ! {
> !   do_tracing = 1;
> !   sim_resume(sd, 0, 0);
> !   do_tracing = 0;
>     return 1;
>   }
>   

You'd also need to do it here (but a bit more subtly...

>   sim_do_command (sd, cmd)
>        SIM_DESC sd ATTRIBUTE_UNUSED;
>        char *cmd ATTRIBUTE_UNUSED;
> ! {
> !   if (strcmp(cmd, "trace") == 0)
> !     {
> !       do_tracing = !do_tracing;
> !       if (do_tracing)
> ! 	(*sim_callback->printf_filtered) (sim_callback,
> ! 					  "Tracing on.\n");
> !       else
> ! 	(*sim_callback->printf_filtered) (sim_callback,
> ! 					  "Tracing off.\n");
> !     }
> !   else
> ! 	(*sim_callback->printf_filtered) (sim_callback,
> ! 					  "Unknown command, only `trace' allowed.\n");
>   }
>   
>   

R.


       reply	other threads:[~2001-02-26 10:40 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <200102240025.TAA28612@greed.delorie.com>
2001-02-26 10:40 ` Richard Earnshaw [this message]
2001-02-26 10:57   ` DJ Delorie
2001-02-26 11:02     ` Richard Earnshaw
2001-02-26 11:12       ` DJ Delorie
2001-02-27  1:47         ` Richard Earnshaw
     [not found] <o53dd1w76u.fsf@toenail.toronto.redhat.com>
2001-02-27  6:26 ` Richard Earnshaw
2001-02-27  7:08   ` Andrew Cagney

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=200102261840.SAA17450@cam-mail2.cambridge.arm.com \
    --to=rearnsha@arm.com \
    --cc=Richard.Earnshaw@arm.com \
    --cc=dj@redhat.com \
    --cc=gdb-patches@sources.redhat.com \
    /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