Linux MIPS Architecture development
 help / color / mirror / Atom feed
* single step in MIPS
@ 2006-09-02 11:45 Nida M
  2006-09-02 16:07 ` Alan Cox
       [not found] ` <000b01c6cea8$7d480fa0$a803a8c0@Ulysses>
  0 siblings, 2 replies; 7+ messages in thread
From: Nida M @ 2006-09-02 11:45 UTC (permalink / raw)
  To: linux-mips

Hi,

I am woking for linux2.6.16 on MIPS platform.
I am tring to implement single stepping on MIPS.
But I found that there is no single step instruction in the MIPS.
I need to implement single stepping for MIPS
Can anybody help me in this..??
Is there any alternative to generate this exception..??



Thanks and Regards
~Nida

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

* Re: single step in MIPS
  2006-09-02 11:45 single step in MIPS Nida M
@ 2006-09-02 16:07 ` Alan Cox
       [not found] ` <000b01c6cea8$7d480fa0$a803a8c0@Ulysses>
  1 sibling, 0 replies; 7+ messages in thread
From: Alan Cox @ 2006-09-02 16:07 UTC (permalink / raw)
  To: Nida M; +Cc: linux-mips

Ar Sad, 2006-09-02 am 17:15 +0530, ysgrifennodd Nida M:
> I am woking for linux2.6.16 on MIPS platform.
> I am tring to implement single stepping on MIPS.
> But I found that there is no single step instruction in the MIPS.

There is no single step instruction feature on most processors. Nor any
need to "implement" single step I suspect

man 2 ptrace
man gdb

The tools exist as standard.

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

* Re: single step in MIPS
       [not found] ` <000b01c6cea8$7d480fa0$a803a8c0@Ulysses>
@ 2006-09-04  4:57   ` Nida M
  2006-09-07  3:54     ` Ralf Baechle
  0 siblings, 1 reply; 7+ messages in thread
From: Nida M @ 2006-09-04  4:57 UTC (permalink / raw)
  To: Kevin D. Kissell; +Cc: linux-mips

On 9/2/06, Kevin D. Kissell <KevinK@mips.com> wrote:
> As Alan indicted, mechanisms for emulating single step
> behavior have long existed for MIPS and Linux.  Newer
> MIPS parts which implement the EJTAG debug system
> do have a single-step mode, but they trap to Debug mode,
> rather than to the kernel - this allows kernel code to be
> single-stepped using an EJTAG probe.  If the system
> allows for it - one needs to have ROM at the right location
> which transfers Debug mode control back to the kernel - it
> is possible to exploit EJTAG debug features from an OS
> kernel. We''ve prototyped this to prove that it works, but
> never went so far as to wire up EJTAG signle-step mode
> to a ptrace or other debug API.  If for some strange reason
> the standard emulation mechanism isn't adequate for you
> (e.g. if your applicaiton is executing out of ROM), you
> do have this as a potential alternative.  But it would not
> be a trivial hack.


Well this is ok ..but I am trying to implement kenel debugger..
something like system tap.
And I have started with kprobe..
where the kernel code execution will be stopped at user specified
address using break, how do i single step that instruction to decode
the instruction and print the registers value..?


~Nida

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

* Re: single step in MIPS
  2006-09-04  4:57   ` Nida M
@ 2006-09-07  3:54     ` Ralf Baechle
  2006-09-07  6:22       ` Nida M
  0 siblings, 1 reply; 7+ messages in thread
From: Ralf Baechle @ 2006-09-07  3:54 UTC (permalink / raw)
  To: Nida M; +Cc: Kevin D. Kissell, linux-mips

On Mon, Sep 04, 2006 at 10:27:12AM +0530, Nida M wrote:

> Well this is ok ..but I am trying to implement kenel debugger..
> something like system tap.
> And I have started with kprobe..
> where the kernel code execution will be stopped at user specified
> address using break, how do i single step that instruction to decode
> the instruction and print the registers value..?

Insert a breakpoint instruction after the instruction you want to single
step. Anything that triggers an exception but typicall a "break 0" would
be used for debuggers.  Branches need special care.  Either they need to
be executed in software or breakpoints at both the branch-taken and the
not-taken address need to be inserted.

Just to make this more entertaining, the kernel is a multithreaed piece
of software, even if you only have a single processor and you do not
necessarily want the singlestepping break point to be taken by each
thread / process, so you want to implement some filtering in the
exception handler.

Executing the instruction that has been replaced with a breakpoint takes
an interesting hack as well.  Copy that instruction to the stackframe,
perform the necessary cacheflushes so the CPU will actually fetch the
right instruction.  Then jump to that instruction.  Obviously that needs
to be followed by a jump to the logical next instruction.

And with all those hints I leave the special case of instructions in
branch delay slots to the you, I'm sure you'll find it trivial ;-)

The FPU emulator in the kernel implements this btw.  Not for single
stepping but for entirely different reasons but you may want to look
at it.

  Ralf

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

* Re: single step in MIPS
  2006-09-07  3:54     ` Ralf Baechle
@ 2006-09-07  6:22       ` Nida M
  2006-09-25  6:19         ` Nida M
  2006-09-25  9:51         ` Nida M
  0 siblings, 2 replies; 7+ messages in thread
From: Nida M @ 2006-09-07  6:22 UTC (permalink / raw)
  To: Ralf Baechle; +Cc: Kevin D. Kissell, linux-mips

> Insert a breakpoint instruction after the instruction you want to single
> step. Anything that triggers an exception but typicall a "break 0" would
> be used for debuggers.  Branches need special care.  Either they need to
> be executed in software or breakpoints at both the branch-taken and the
> not-taken address need to be inserted.

Instead of break 0, can I use  Trap Exception 'Tr'  with the special
case for single step BRK_SSTEPBP (break 5)
E.g : teq rs,rt,code

      which is nothing but :
      bne rs,rt,1f
      nop
      break code

....... ???
> And with all those hints I leave the special case of instructions in
> branch delay slots to the you, I'm sure you'll find it trivial ;-)

Thanks,I think i will do that




~Nida

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

* Re: single step in MIPS
  2006-09-07  6:22       ` Nida M
@ 2006-09-25  6:19         ` Nida M
  2006-09-25  9:51         ` Nida M
  1 sibling, 0 replies; 7+ messages in thread
From: Nida M @ 2006-09-25  6:19 UTC (permalink / raw)
  To: Ralf Baechle; +Cc: Kevin D. Kissell, linux-mips

Hi,


On 9/7/06, Nida M <nidajm@gmail.com> wrote:
> > Insert a breakpoint instruction after the instruction you want to single
> > step. Anything that triggers an exception but typicall a "break 0" would
> > be used for debuggers.  Branches need special care.  Either they need to
> > be executed in software or breakpoints at both the branch-taken and the
> > not-taken address need to be inserted.
>
> Instead of break 0, can I use  Trap Exception 'Tr'  with the special
> case for single step BRK_SSTEPBP (break 5)
> E.g : teq rs,rt,code
>
>       which is nothing but :
>       bne rs,rt,1f
>       nop
>       break code
>
> ....... ???
> > And with all those hints I leave the special case of instructions in
> > branch delay slots to the you, I'm sure you'll find it trivial ;-)
>
> Thanks,I think i will do that
>
>
>
>
> ~Nida
>

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

* Re: single step in MIPS
  2006-09-07  6:22       ` Nida M
  2006-09-25  6:19         ` Nida M
@ 2006-09-25  9:51         ` Nida M
  1 sibling, 0 replies; 7+ messages in thread
From: Nida M @ 2006-09-25  9:51 UTC (permalink / raw)
  To: Ralf Baechle; +Cc: Kevin D. Kissell, linux-mips

Hi,
      I am facing problem in case of branch delay instruction.
      When single stepping is done on a copied page,for an  uncondition jump
      instruction to the given target address ( e.g j, jal ),
      epc jumps to the target address with respect to current address,
      And if I tried to put break point over there....it gives error as
      "CPU 0 Unable to handle kernel paging request at virtual
      address c005eeb8, epc == c005eeb8"


      Can anybody knows...how to solve this problem..?


 ~Nida



On 9/7/06, Nida M <nidajm@gmail.com> wrote:
> > Insert a breakpoint instruction after the instruction you want to single
> > step. Anything that triggers an exception but typicall a "break 0" would
> > be used for debuggers.  Branches need special care.  Either they need to
> > be executed in software or breakpoints at both the branch-taken and the
> > not-taken address need to be inserted.
>
> Instead of break 0, can I use  Trap Exception 'Tr'  with the special
> case for single step BRK_SSTEPBP (break 5)
> E.g : teq rs,rt,code
>
>       which is nothing but :
>       bne rs,rt,1f
>       nop
>       break code
>
> ....... ???
> > And with all those hints I leave the special case of instructions in
> > branch delay slots to the you, I'm sure you'll find it trivial ;-)
>
> Thanks,I think i will do that
>
>
>
>
> ~Nida
>

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

end of thread, other threads:[~2006-09-25  9:51 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-09-02 11:45 single step in MIPS Nida M
2006-09-02 16:07 ` Alan Cox
     [not found] ` <000b01c6cea8$7d480fa0$a803a8c0@Ulysses>
2006-09-04  4:57   ` Nida M
2006-09-07  3:54     ` Ralf Baechle
2006-09-07  6:22       ` Nida M
2006-09-25  6:19         ` Nida M
2006-09-25  9:51         ` Nida M

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox