Print void* pointer using !DI* information in human readable format

Hi,

Given that the !DI* metadata is available in .ll file, I am wondering
if there is a way to case any void* pointer appropriately according to
the debug information and print the data pointed by the void* pointer
in a human-readable format in C.

I think that lldb should have some facility to do this.

But I am wondering what is the best way to do it in C. Does anybody
know? Is there a library to facilitate this? Thanks.

From: llvm-dev [mailto:llvm-dev-bounces@lists.llvm.org] On Behalf Of Peng
Yu via llvm-dev
Sent: Wednesday, January 30, 2019 10:42 AM
To: llvm-dev
Subject: [llvm-dev] Print void* pointer using !DI* information in human
readable format

Hi,

Given that the !DI* metadata is available in .ll file, I am wondering
if there is a way to case any void* pointer appropriately according to
the debug information and print the data pointed by the void* pointer
in a human-readable format in C.

I think that lldb should have some facility to do this.

You should be able to cast the void* pointer to another pointer type
and then dereference it. I personally am not familiar with lldb syntax
but in gdb it would be something like "p *(other*)pointer"

But I am wondering what is the best way to do it in C. Does anybody
know? Is there a library to facilitate this? Thanks.

Assuming you are writing a debugger or other tool to examine the state
of a running program, LLVM's DebugInfo library might be helpful.
--paulr