From: Aravinda <aravindakidambi@gmail.com>
To: Stan Shebs <stan@codesourcery.com>,
jan.kratochvil@redhat.com, ppluzhnikov@google.com,
dave.korn.cygwin@googlemail.com
Cc: gdb@sourceware.org
Subject: Re: GDB library to insert and delete watchpoints
Date: Fri, 04 Dec 2009 16:21:00 -0000 [thread overview]
Message-ID: <26eb53620912040820y3340ad2fw78bf770754b26c4c@mail.gmail.com> (raw)
In-Reply-To: <4B18CD92.8000302@codesourcery.com>
Hi,
Thank you for all of your replies and suggestions.
Yah, Im assuming a simple case for now of only debugging a single
thread/process. Also, its actually a little different since Im not
trying to have a separate debugging thread to do this job. I have a
single threaded application that I want to be safe from buffer
overruns all the time, that doesnt have more than 4 levels of nested
loops, so 4 debug register should do just good for this. And Im trying
to do it automatically by instrumenting GCC to add a call (before
array accesses) to a custom library function that inserts a
watchpoint. I wanted to write a C library that manages mirror
registers and occasionally makes a system call/invokes a driver to put
the value in the debug register.
I have never used ptrace before and need to lookup on it, but the code
that I saw was for a parent process modifying the contents of debug
registers for the child. So im assuming I can either call ptrace from
the same process to modify the contents or have to write a driver to
manipulate debug registers.
Thanks,
Aravinda
On Fri, Dec 4, 2009 at 3:51 AM, Stan Shebs <stan@codesourcery.com> wrote:
>
> Aravinda wrote:
>>
>> Hi,
>>
>> Im working on a project that currently requires inserting and deleting
>> watchpoints to monitor buffer overruns. I was looking at the
>> gdb-internals documentation which talks about a gdb library that can
>> be used to do exactly this. But I couldnt find more info on this. Im
>> looking for a ready to use library to be used with a kernel module
>> that allows for modifying the debug registers. kindly point me to any
>> sources if it can be done.
>>
>
> It just so happens that CodeSourcery recently did this for a customer that was using a debugging stub that ran as one of several threads in the application. It does need its own driver to modify the debug registers, and the stub calls it once it has done the bit-twiddling on mirrors of the registers. While it works well enough to have one thread set the debug registers of a different thread in a Linux app, there is some fancy dancing to make this work in nonstop - with all the threads running at once, you can get nasty races all over the place. Unfortunately, this is all CodeSourcery proprietary code and intermingled with the customer's app to boot, so I can't send you a copy.
>
> Stan
>
next prev parent reply other threads:[~2009-12-04 16:21 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <26eb53620911301516x68ccc0edkf64ba2951c8ce3a3@mail.gmail.com>
[not found] ` <26eb53620911301518y13e64bc0g95c6fe3c7b18b0c@mail.gmail.com>
2009-12-01 5:44 ` Paul Pluzhnikov
2009-12-01 18:08 ` Dave Korn
2009-12-01 21:14 ` Jan Kratochvil
2009-12-04 8:51 ` Stan Shebs
2009-12-04 16:21 ` Aravinda [this message]
2009-12-04 17:11 ` Jan Kratochvil
2009-12-07 21:30 ` Aravinda
2009-12-04 16:38 ` Joel Brobecker
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=26eb53620912040820y3340ad2fw78bf770754b26c4c@mail.gmail.com \
--to=aravindakidambi@gmail.com \
--cc=dave.korn.cygwin@googlemail.com \
--cc=gdb@sourceware.org \
--cc=jan.kratochvil@redhat.com \
--cc=ppluzhnikov@google.com \
--cc=stan@codesourcery.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