danni/gobject-list — pull request #8 by Lekensteyn (2014-11-20 15:52:17+00:00)
Title: Trace callstack

(based on PR #7, branch https://github.com/Lekensteyn/gobject-list/tree/fix-libunwind)

Useful to debug reference count leaks where a lot objects are still
held just because a single object was not released elsewhere...

Totally not optimized and slows down a lot, but it gets the job done.

I used this to track down a very annoying reference count leak in UPower
which slows made it harder to analyze real issues.

Uncolored example for a very simple program which calls just `g_cancellable_new()` and fails to unref it:
```
$ GOBJECT_LIST_DISPLAY=all LD_PRELOAD=./libgobject-list.so ./a.out
++ Created object 0x212b610, GCancellable
#0 g_object_new + [0x00000161]
#1 main + [0x00000014]
#2 __libc_start_main + [0x000000f0]
#3 _start + [0x00000029]
Error getting frame: unspecified (general) error (1)
Leak!

Still Alive:
- 0x212b610, GCancellable: 1 refs
1 objects

References:
#1
# GCancellable (+1/-0 = 1)
| # _start (+1/-0 = 1)
| | # __libc_start_main (+1/-0 = 1)
| | | # main (+1/-0 = 1)
| | | | # g_object_new (+1/-0 = 1)
```

I opened this PR in the hope it is useful to others.