[Gammaray-interest] New plugin idea: Event inspector
Christian Gagneraud
chgans at gmail.com
Fri Sep 15 12:37:44 CEST 2017
On 15 September 2017 at 16:06, Christian Gagneraud <chgans at gmail.com> wrote:
> Hi there,
>
> I'm starting to think seriously about jumping into the gammara world.
>
> What I would like to get/do/contribute is a first class citizen event inspector.
>
> I won't waste your time with lot of words, so basically i would like
> to hook on CustomApplication::notify, CustomObject::event and
> CustomnObject::eventFilter, and store occurrences when some condition
> matches.
context: Linux + x86(_64) + gcc
I just had a look at the Probe, the Injector and the
FunctionOverwriter classes and skimmed quickly through some plugins ,
and there's enough interesting stuff to start playing with this idea.
I've already learned lot of things! ;)
I didn't know that since Qt-5.4, installing hooks was that easy - if
you don't mind depending on qtbase-private.
I was surprise by the "simple" approach taken by GammaRay, I was
expecting heavy use of SO preload instead i found a "simple is
beautiful" approach (simple is always a relative word).
I think it is doable to dynamically wrap CustomApplication::notify, as
you can dynamically build the mangled symbol of the
QApplication::notify overloads, same goes with QObject::Event and
QObject::eventFilter ones: their signatures are well known and
QMetaObject provide the rest, did i miss something?
The only thing that i think would need work is the C++ object
wrapping, as FunctionOverwriter seems to be geared toward C, not C++.
Basically i need access to the C++ "this" [1] and the
FunctionOverwriter's trampoline code in a preloaded SO that doesn't
depend on Qt...
Well, that's the theory. I will then have to find a way for this
preloaded SO to exec custom hooks/handlers. I don't think it should be
that hard but memory allocators, multi-threadings and
auto/self-induced events will certainly make the job harder thought...
Now, given the high-profile of GammaRay developpers, I have the
feeling that you never went this path by choice (ie: not for technical
reasons obviously! ;)), would you accept this sort of hackish stuff in
GammaRay? A pre-loaded SO dedicated to Qt event profiling?
PS: If I ever go further, i will eventually want to get that working
on arm32-linux too.
Thanks,
Chris
[1] https://blog.kummerlaender.eu/article/notes_on_function_interposition_in_cpp/
>
> Meta-data associated with such occurences:
> - entry/exit timestamps
> - nesting level (per thread)
> - sender object (if one and possible to deduce)
> - sender thread
> - receiver object
> - receiver thread
> - event payload
> - filter result
> - ...
>
> The end user should be able to add/remove monitoring conditions,
> maybe simply based on:
> - sender thread
> - receiver object
> - event type
>
> The visualisation would be a tree model (for a given thread), as I am
> particularly interested in nesting and ordering analysis.
>
> I know i'm quite vague, but what do you guys think? Does such a tool
> already exists? Open source or not? Does that sound something that
> could be done with gammaray?
>
> Chris
More information about the Gammaray-interest
mailing list