This is the mail archive of the gdb@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Watchpoints in multithreaded programs


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






Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]