Mirror of the gdb mailing list
 help / color / mirror / Atom feed
* Re: Watchpoints in multithreaded programs
@ 2006-10-03  3:53 Steve Freeland
  2006-10-03  4:07 ` Daniel Jacobowitz
  0 siblings, 1 reply; 5+ messages in thread
From: Steve Freeland @ 2006-10-03  3:53 UTC (permalink / raw)
  To: Daniel Jacobowitz; +Cc: gdb

Is there anything particularly wrong with just setting the watchpoint individually in each of
the threads?  I haven't a clue about portability, but on I've checked on i386 Linux and this
seems to work... at least, it solves my problem.  I can clean this up and make it submittable
as a patch, but first I'd like to know if there's a problem with it conceptually, as I've never
worked with gdb internals before:

struct i386_linux_dr_operation
{
    int regnum;
    unsigned long value;
};

static int i386_linux_dr_set_for_tid(int tid, int regnum, unsigned long value)
{
  int result = 0;
  errno = 0;
  ptrace (PTRACE_POKEUSER, tid,
          offsetof (struct user, u_debugreg[regnum]), value);

  if (errno != 0)
  {
    perror_with_name (_("Couldn't write debug register"));
    result = 1;
  }
  return result;
}

static int i386_linux_perform_dr_operation(struct thread_info *t, void *arg)
{
    struct i386_linux_dr_operation *op = arg;
    return i386_linux_dr_set_for_tid(TIDGET(t->ptid), op->regnum, op->value);
}

static void
i386_linux_dr_set (int regnum, unsigned long value)
{
  int tid = TIDGET (inferior_ptid);
  if (tid == 0)
  {
     i386_linux_dr_set_for_tid(PIDGET(inferior_ptid), regnum, value);
  }
  else
  {
    struct i386_linux_dr_operation op = { regnum, value };
    iterate_over_threads(i386_linux_perform_dr_operation, &op);
  }
}


----- Original Message ----
From: Daniel Jacobowitz <drow@false.org>
To: Steve Freeland <caucasatron@yahoo.ca>
Cc: gdb@sources.redhat.com
Sent: Sunday, October 1, 2006 7:24:43 PM
Subject: Re: Watchpoints in multithreaded programs

On Sun, Oct 01, 2006 at 02:23:27PM -0700, Steve Freeland wrote:
> So... I'm a bit confused.  Is the manual out of date?  Did the
> "watchthreads" patch never make it into mainline builds for some
> reason?

It never did.  Discussion trailed off and we never heard anything else
about it from the submitter.

I recall seeing a few weeks ago that there is an updated version in
the Red Hat SRPMs.  Could any of the list subscribers from Red Hat
comment - is that version fit for submission?

-- 
Daniel Jacobowitz
CodeSourcery






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

* Re: Watchpoints in multithreaded programs
  2006-10-03  3:53 Watchpoints in multithreaded programs Steve Freeland
@ 2006-10-03  4:07 ` Daniel Jacobowitz
  0 siblings, 0 replies; 5+ messages in thread
From: Daniel Jacobowitz @ 2006-10-03  4:07 UTC (permalink / raw)
  To: Steve Freeland; +Cc: gdb

On Mon, Oct 02, 2006 at 08:53:10PM -0700, Steve Freeland wrote:
> Is there anything particularly wrong with just setting the watchpoint
> individually in each of the threads?  I haven't a clue about
> portability, but on I've checked on i386 Linux and this seems to
> work... at least, it solves my problem.  I can clean this up and make
> it submittable as a patch, but first I'd like to know if there's a
> problem with it conceptually, as I've never worked with gdb internals
> before:

It's a little bit trickier than that, because you need to check all the
various status registers afterwards, IIRC.  But that's the basic idea
and the patches I referenced in the Red Hat SRPM add a generic way of
handling this.

-- 
Daniel Jacobowitz
CodeSourcery


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

* Re: Watchpoints in multithreaded programs
  2006-10-01 21:23 Steve Freeland
  2006-10-01 23:24 ` Daniel Jacobowitz
@ 2007-04-25 20:37 ` Jan Kratochvil
  1 sibling, 0 replies; 5+ messages in thread
From: Jan Kratochvil @ 2007-04-25 20:37 UTC (permalink / raw)
  To: Steve Freeland; +Cc: gdb

Hi,

please check the patches
	gdb-6.3-threaded-watchpoints-20041213.patch
	gdb-6.3-threaded-watchpoints2-20050225.patch
in
	http://download.fedora.redhat.com/pub/fedora/linux/core/development/source/SRPMS/gdb-6.6-8.fc7.src.rpm

Going to check there some recent Linux kernels compatibility problems, though.


Regards,
Jan


On Sun, 01 Oct 2006 23:23:27 +0200, Steve Freeland wrote:
> Hello,
> 
> What is the status of gdb's support for watchpoint in multithreaded apps? 
> 
> The manual states here: http://sources.redhat.com/gdb/current/onlinedocs/gdb_6.html#SEC34 that "With the current watchpoint implementation, GDB
> can only watch the value of an expression in a single thread."
> 
> However, there's a thread on gdb-patches here from 2004 that seems to indicate that this
> limitation was in the process of being eliminated: http://sources.redhat.com/ml/gdb-patches/2004-12/msg00256.html
> 
> So... I'm a bit confused.  Is the manual out of date?  Did the "watchthreads" patch never make
> it into mainline builds for some reason?
> 
> Thanks in advance,
> - Steve


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

* Re: Watchpoints in multithreaded programs
  2006-10-01 21:23 Steve Freeland
@ 2006-10-01 23:24 ` Daniel Jacobowitz
  2007-04-25 20:37 ` Jan Kratochvil
  1 sibling, 0 replies; 5+ messages in thread
From: Daniel Jacobowitz @ 2006-10-01 23:24 UTC (permalink / raw)
  To: Steve Freeland; +Cc: gdb

On Sun, Oct 01, 2006 at 02:23:27PM -0700, Steve Freeland wrote:
> So... I'm a bit confused.  Is the manual out of date?  Did the
> "watchthreads" patch never make it into mainline builds for some
> reason?

It never did.  Discussion trailed off and we never heard anything else
about it from the submitter.

I recall seeing a few weeks ago that there is an updated version in
the Red Hat SRPMs.  Could any of the list subscribers from Red Hat
comment - is that version fit for submission?

-- 
Daniel Jacobowitz
CodeSourcery


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

* Watchpoints in multithreaded programs
@ 2006-10-01 21:23 Steve Freeland
  2006-10-01 23:24 ` Daniel Jacobowitz
  2007-04-25 20:37 ` Jan Kratochvil
  0 siblings, 2 replies; 5+ messages in thread
From: Steve Freeland @ 2006-10-01 21:23 UTC (permalink / raw)
  To: gdb; +Cc: caucasatron

Hello,

What is the status of gdb's support for watchpoint in multithreaded apps? 

The manual states here: http://sources.redhat.com/gdb/current/onlinedocs/gdb_6.html#SEC34 that "With the current watchpoint implementation, GDB
can only watch the value of an expression in a single thread."

However, there's a thread on gdb-patches here from 2004 that seems to indicate that this
limitation was in the process of being eliminated: http://sources.redhat.com/ml/gdb-patches/2004-12/msg00256.html

So... I'm a bit confused.  Is the manual out of date?  Did the "watchthreads" patch never make
it into mainline builds for some reason?

Thanks in advance,
- Steve






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

end of thread, other threads:[~2007-04-25 20:37 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-10-03  3:53 Watchpoints in multithreaded programs Steve Freeland
2006-10-03  4:07 ` Daniel Jacobowitz
  -- strict thread matches above, loose matches on Subject: below --
2006-10-01 21:23 Steve Freeland
2006-10-01 23:24 ` Daniel Jacobowitz
2007-04-25 20:37 ` Jan Kratochvil

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