From: Ralf Baechle <ralf@linux-mips.org>
To: Nida M <nidajm@gmail.com>
Cc: "Kevin D. Kissell" <KevinK@mips.com>, linux-mips@linux-mips.org
Subject: Re: single step in MIPS
Date: Thu, 7 Sep 2006 05:54:24 +0200 [thread overview]
Message-ID: <20060907035424.GB17965@linux-mips.org> (raw)
In-Reply-To: <b01966ec0609032157s35d8c0bdx900956f214c5337b@mail.gmail.com>
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
next prev parent reply other threads:[~2006-09-07 3:53 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
2006-09-07 6:22 ` Nida M
2006-09-25 6:19 ` Nida M
2006-09-25 9:51 ` Nida M
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=20060907035424.GB17965@linux-mips.org \
--to=ralf@linux-mips.org \
--cc=KevinK@mips.com \
--cc=linux-mips@linux-mips.org \
--cc=nidajm@gmail.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