root-project / cling

The cling C++ interpreter

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

better display struct

Freed-Wu opened this issue · comments

commented
#if 0
gcc -g "$0" -oa && exec ./a "$@"
#endif
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
  FILE *fp = fopen("a.c", "r+");
}

In gdb,

❯ p *fp
$3 = {_flags = 0xfbad2480, _IO_read_ptr = 0x0, _IO_read_end = 0x0, _IO_read_base = 0x0,
  _IO_write_base = 0x0, _IO_write_ptr = 0x0, _IO_write_end = 0x0, _IO_buf_base = 0x0, _IO_buf_end = 0x0,
  _IO_save_base = 0x0, _IO_backup_base = 0x0, _IO_save_end = 0x0, _markers = 0x0,
  _chain = 0x7ffff7ec74c0 <_IO_2_1_stderr_>, _fileno = 0xa, _flags2 = 0x0, _old_offset = 0x0,
  _cur_column = 0x0, _vtable_offset = 0x0, _shortbuf = "", _lock = 0x555555559380,
  _offset = 0xffffffffffffffff, _codecvt = 0x0, _wide_data = 0x555555559390, _freeres_list = 0x0,
  _freeres_buf = 0x0, __pad5 = 0x0, _mode = 0x0, _unused2 = '\000' <repeats 19 times>}
❯ p fp
$4 = (FILE *) 0x5555555592a0

screen-2023-03-29-17-05-46

In cling:

[cling]$ #include <stdio.h>
[cling]$ FILE *fp = fopen("a.c", "r+");
[cling]$ fp
(FILE *) 0x55b016c9e3f0
[cling]$ *fp
(FILE &) @0x55b016c9e3f0

Why not let *fp display like gdb?

Agreed, that would be nice! I'm not sure we (CERN) will have anyone who can work on this - we have different plans, such as rebasing cling on top of clang-repl etc... I.e. we have plans, but not that one :-)

Which means: PRs welcome!