QPointers

lets start with QWeakPointer, here our pointer template type is Animal its structure is

├── wp (weakpointer): (QWeakPointer<Animal> *)
├── d 
│   ├── weakref  : as QAtomicInt  
│   └── strongref: as QAtomicInt
└── value: (Animal *)

QWeakpointers in GDB provide two variables.

  • d (data) -> stores the weak and strong references of the pointer.
  • value -> stores the type the pointer points to.

what we need to print is

  • weak reference
  • strong reference
  • the value

no need to worry about the weak and strong ref as QAtomicInt Printer has already been made, the values is then printed out

in the above Animal is the type template we need to print the value then we are done.

The above applies for both QWeak and QShared Pointer but not QAtomicPointer and QPointer

QPointer structure would be

QPointer (QPointer<Animal> *)
├── wp (weakpointer): (QWeakPointer<QObject> *)
│   ├── d
│   │ 	├──  weakref  : as QAtomicInt 
│   │ 	├── trongref: as QAtomicInt 
│   ├── value: (QObject *)

In this case we would get the template name from the parent and pass it to the weak pointer printer, then cast the value from a QObject to the template type, in our case it is Animal

for QAtomicPointer where are able to get the pointer at pointerName._q_value._M_i' and dereference it.

relevant commit

Fix For QFileInfo

  • printer for QfileInfo always crashes because i try to access methods that do not exist yet in the class to solve the problem i found a way to check if the class has been initialized in gdb commit here

  • added some extra variable that may be needed during debugging

the repo can be found here

That’s it for now see you next week