# PrintSelf() for use in debugger

**URL:** https://discourse.itk.org/t/printself-for-use-in-debugger/432
**Category:** Engineering
**Created:** [November 18, 2017, 3:13pm UTC](https://discourse.itk.org/t/printself-for-use-in-debugger/432 "2017-11-18T15:13:29Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![ihnorton](https://discourse.itk.org/user_avatar/discourse.itk.org/ihnorton/32/47_2.png) [@ihnorton](https://discourse.itk.org/u/ihnorton)
#### Post date: [November 18, 2017, 3:13pm UTC](https://discourse.itk.org/t/printself-for-use-in-debugger/432/1 "2017-11-18T15:13:29Z")

</div>

Please consider adding an overload to `::PrintSelf()` which defaults to one of the standard output streams and does not require an ostream reference. As far as I can tell [[1](https://stackoverflow.com/a/20458626/508431), [2](https://stackoverflow.com/questions/20387942/evaluating-an-expression-with-overloaded-operators-in-c-lldb)], the current signature

```
PrintSelf (std::ostream &os, Indent indent) const

```

cannot be called from a debugger because it is not possible to get a reference to any std ostream (at least not in lldb, which is de facto the only debugger these days on macOS). In some situations, the debugger’s pretty-printer is not sufficient (or sometimes broken due to failed lookup of elided symbols).

If this is acceptable, I could make the appropriate MR.

---

<div class="post-metadata">

### Author: ![matt.mccormick](https://discourse.itk.org/user_avatar/discourse.itk.org/matt.mccormick/32/7_2.png) [@matt.mccormick](https://discourse.itk.org/u/matt.mccormick)
#### Post date: [November 20, 2017, 4:18pm UTC](https://discourse.itk.org/t/printself-for-use-in-debugger/432/2 "2017-11-20T16:18:25Z")

</div>

Hi Isaiah,

A patch to add a default for `std::cout` would be welcome. However, it should probably go on [`Print()`](https://itk.org/Doxygen/html/classitk_1_1LightObject.html#abb0e07472c48d5a2033ac69ed519a338) instead of `PrintSelf()` because this is the public method intended to be called on an instance to display its state.

Thanks,  
Matt

---

<div class="post-metadata">

### Author: ![blowekamp](https://discourse.itk.org/user_avatar/discourse.itk.org/blowekamp/32/79_2.png) [@blowekamp](https://discourse.itk.org/u/blowekamp)
#### Post date: [November 20, 2017, 4:24pm UTC](https://discourse.itk.org/t/printself-for-use-in-debugger/432/3 "2017-11-20T16:24:30Z")

</div>

For your debugger does having an overloaded operator\<\< help?

You could add something like:

> namespace itk  
> {
> 
> ostream& operator\<\<(ostream& os, const LightObject &obj ) ;
> 
> }
