Skip to content

add qml tracing (and move preamble printing to python helper)

Harald Sitter requested to merge work/qmltrace into master

qml tracing is a bit tricky because we first need to get to the address of the engine and then run that through a static debug function from qt. the function then generates gdb/mi output.

this is challenging in a number of ways: a) getting to the address is exceptionally different with just our CLI interfacing capabilities b) we don't have gdb/mi support c) we also have no notion of extra output

to deal with problem a) the existing preamble handling has been changed and is now run through a python module that the preamble cmdline sources. this gives both a neater cmdline and more dynamic abilities as we can now leverage the full power of gdb's python integration. the downside is of course that the preamble only works if gdb has python support - something we can hopefully assume as a given in 2021.

to deal with b) I was musing on interfacing with gdb/mi directly. but honestly, the library options are a bit meh and completely refactoring how we interface with gdb is a bit out of scope anyway (also exceptionally unattractive considering some community members want drkonqi to support other debuggers, complicating matters further). so, instead this is taking a middle-of-the-road approach. if pygdbmi is available it will route the trace output from qt through its parser to then do somewhat pretty printing of the trace, otherwise it will dump the raw response string as it sports a somewhat readable format anyway. this allows this feature to practically get by without extra dependency and the code cost is negligible.

c) is effectively dealt with by extending the preamble system. we essentially rely on the fact that gdb output parsing is fairly strict and will ignore lines it can't do anything with. this allows us to print any amount of crap so long as it doesn't look like a gdb line. the disadvantage is that the preamble is at the top but the most relevant thread is usually at the bottom.

to enable this feature the debugger templating has been extended. Exec, BatchCommand and PreambleCommand are now run through a macro expander that injects a debugger specific datadir derived from xdg_data_dirs. this allows us to source the preamble.py from the correct path at runtime.

Edited by Harald Sitter

Merge request reports