Hello WebKittens,

I've added a new debugging helper, `WTF::structDump` to JSC `dataLog` debugging 
helper families[1].
This leverages clang's `__builtin_dump_struct` function[2] and generates 
debugging-friendly struct-dump for *any* struct / class without having any 
special code to these classes.

Use case is, for example,


```
    DFG::Node* node = ...;
    dataLogLn(structDump(*node)); // Or any instances of your classes / structs
```

then, it automatically generates the output like this,

```
    JSC::DFG::Node {
      NodeOrigin origin = *0x10631d800
      NodeType m_op = 59
      unsigned int m_index = 323
      AdjacencyList children = *0x10631d818
      VirtualRegister m_virtualRegister = *0x10631d830
      unsigned int m_refCount = 1
      NodeFlags m_flags = 344069
      SpeculatedType m_prediction = 206158430208
      OpInfoWrapper m_opInfo = *0x10631d848
      OpInfoWrapper m_opInfo2 = *0x10631d850
      union (unnamed) m_misc = {
        Node * replacement = 0x0
        unsigned int epoch = 0
      }
      BasicBlock * owner = 0x1061177b0
    }
```

Currently, only clang supports this builtin. On GCC, we will just use 
pointerDump which dumps a pointer hex value.
There is a feature request bug in GCC[3], and once it gets implemented, we can 
support GCC too.

Happy hacking!

Best regards,
-Yusuke Suzuki

[1]: 
https://github.com/WebKit/WebKit/commit/3c94ba6d70070d52a469c04ece16da7d0edb467b
[2]: https://clang.llvm.org/docs/LanguageExtensions.html#builtin-dump-struct
[3]: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83161
_______________________________________________
webkit-dev mailing list
webkit-dev@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-dev

Reply via email to