This is the mail archive of the gdb-patches@sources.redhat.com 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: [RFA]: Modified Watchthreads Patch


> Date: Fri, 10 Dec 2004 18:37:00 -0500
> From: Daniel Jacobowitz <drow@false.org>
> Cc: jjohnstn@redhat.com, gdb-patches@sources.redhat.com
> 
> I waited to review the revised version until you had a chance to
> comment on the continued use of observers.

I still object to the use of observers for a purpose such as this one.
My objections are a bit philosophical, though.

Basically, I think that observers are a last-resort mechanism for
anything that is part of the GDB infrastructure.  It's like hooks or
callbacks--you don't normally expect a program internals to use
callbacks that it provides for higher-level application code.

Put another way, using a mechanism such as observers for internal code
means we leave our internal structure not entirely defined.  We design
the internals, so we ought to know what needs to be done where and
when.  For example, this particular usage of an observer means that we
don't really know in advance that watchpoint insertion needs to be
done for each thread when it is being attached.  Do we really want to
say that we don't know what we are doing in our own program?

Callbacks is something you generally provide for application code that
is not part of the program.  For example, if we ever get to the point
of having libgdb that could be linked into other applications to
create customized debuggers, observers will be an important mechanism
to let libgdb users hook into internal GDB operations without hacking
the code.

In addition, proliferation of observers' use will sooner or later
raise the issue of the order of the observer invocation, since we lack
a machinery for invoking a series of observers in a controlled manner:
we cannot control the order of their invocation and we cannot tell GDB
to stop invoking any additional observers.  The current machinery
assumes that each observer is orthogonal to others in its side
effects; what if this assumption doesn't hold?

> Jeff asked you if a renamed observer was acceptable, and you said
> that it was.

That's because I didn't want to restart a dispute where I was already
told that the party line was that it was okay to use observers for
such puproses (or any puproses, really).

> If there's been a miscommunication, if you still object to this use of
> the observers, please, say so now.  We can discuss alternatives.

Well, the obvious alternative is to call the function that needs to
insert the watchpoints for a thread that has been attached right where
the thread attachment is dealt with.


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