Mirror of the gdb mailing list
 help / color / mirror / Atom feed
* 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
* 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

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-01 21:23 Watchpoints in multithreaded programs Steve Freeland
2006-10-01 23:24 ` Daniel Jacobowitz
2007-04-25 20:37 ` Jan Kratochvil
2006-10-03  3:53 Steve Freeland
2006-10-03  4:07 ` Daniel Jacobowitz

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