Add some support code to GTask and a gtask-bt gdb command
Whenever we invoke the GTask callback we push the current
task to a thread-local variable, and during construction we
pick this up as the "parent" of the task which lets us
construct call chains for GTask invocations.
Additionally, g_task_new is #defined to g_task_new_with_caller
with an additional __builtin_return_address(0) argument, which
gives the caller of the function that created the GTask, which
is typically the interesting user-level code.
We then read this back in a gtask-bt gdb command that prints a
backtrace like:
Thread 5 "gdbus" hit Breakpoint 1, g_task_new_with_caller (source_object=source_object@entry=0x1003e0130, cancellable=cancellable@entry=0x1003bbf00,
callback=callback@entry=0x7fa8d0efa890 <_g_dbus_worker_do_read_cb>, callback_data=callback_data@entry=0x1003e3800, caller=0x7fa8d0ef8a81 <_g_dbus_worker_do_read_unlocked+161>) at gtask.c:743
743 {
(gdb) gtask-bt
#1 GTask 0x7fa8b4004cc0 - _g_dbus_worker_do_read_unlocked (gdbusprivate.c:854)
_g_socket_read_with_control_messages -> _g_dbus_worker_do_read_cb
#2 GTask 0x7fa8b8012200 - _g_dbus_worker_do_read_unlocked (gdbusprivate.c:854)
_g_socket_read_with_control_messages -> _g_dbus_worker_do_read_cb
#3 GTask 0x7fa8b80122f0 - _g_dbus_worker_do_read_unlocked (gdbusprivate.c:854)
_g_socket_read_with_control_messages -> _g_dbus_worker_do_read_cb
#4 GTask 0x7fa8b80123e0 - _g_dbus_worker_do_read_unlocked (gdbusprivate.c:854)
_g_socket_read_with_control_messages -> _g_dbus_worker_do_read_cb
#5 GTask 0x7fa8b80124d0 - _g_dbus_worker_do_read_unlocked (gdbusprivate.c:854)
_g_socket_read_with_control_messages -> _g_dbus_worker_do_read_cb
#6 GTask 0x7fa8b8012020 - _g_dbus_worker_do_read_unlocked (gdbusprivate.c:854)
_g_socket_read_with_control_messages -> _g_dbus_worker_do_read_cb
#7 GTask 0x100c5c690 - _g_dbus_worker_do_read_unlocked (gdbusprivate.c:854)
_g_socket_read_with_control_messages -> _g_dbus_worker_do_read_cb
#8 GTask 0x100988030 - _g_dbus_worker_do_read_unlocked (gdbusprivate.c:854)
_g_socket_read_with_control_messages -> _g_dbus_worker_do_read_cb
#9 GTask 0x1009886c0 - _g_dbus_worker_do_read_unlocked (gdbusprivate.c:854)
_g_socket_read_with_control_messages -> _g_dbus_worker_do_read_cb
#10 GTask 0x1009883f0 - _g_dbus_worker_do_read_unlocked (gdbusprivate.c:854)
_g_socket_read_with_control_messages -> _g_dbus_worker_do_read_cb
#11 GTask 0x1009d1a00 - _g_dbus_worker_do_read_unlocked (gdbusprivate.c:854)
_g_socket_read_with_control_messages -> _g_dbus_worker_do_read_cb
#12 GTask 0x100766930 - _g_dbus_worker_do_read_unlocked (gdbusprivate.c:854)
_g_socket_read_with_control_messages -> _g_dbus_worker_do_read_cb
#13 GTask 0x10072dae0 - _g_dbus_worker_do_read_unlocked (gdbusprivate.c:854)
_g_socket_read_with_control_messages -> _g_dbus_worker_do_read_cb
3 files changed