Retrieve address of the elements of a shared pointer?

Shared pointer is not same as pointer. But if a pointer is shared pointer then it’s a pointer. So, how will I differentiate between a pointer and a shared pointer. Also, how will I get the address of the 1st content of the pointers that is shared in a shared pointer. Like, following function is taking both pointer and a shared pointer,

Function name:_ZN4mqtt8callback15message_arrivedESt10shared_ptrIKNS_7messageEE
Pointer type:%"class.mqtt::callback"*
Pointer element type: %"class.mqtt::callback" = type { i32 (...)** }
Pointer type:%"class.std::shared_ptr.12"*
Pointer element type: %"class.std::shared_ptr.12" = type { %"class.std::__shared_ptr.13" }

1st parameter: %"class.mqtt::callback"*
2nd parameter: %"class.std::shared_ptr.12"*

The shared pointer might have multiple instances. How will I get the number of instances of the pointer exists and how will I get the the address of those instances and how to check if it cleans up the memory when the count reaches zero .?

Stepping back a bit, what are you hoping to achieve? What is the transformation or analysis you are ultimately working towards, and why does it require distinguishing between a pointer and a std::shared_ptr in such a way that you need to understand what std::shared_ptr points to?

At the LLVM level, the IR has been working towards removing the concept of pointers having a type that they point to, and the most recent release has made this the default option for compilation. The IR you’re sharing is not in this mode, which means that I worry whatever you’re trying to advance is something that is relying on something that is fundamentally unsound when specified in LLVM IR and reliant on information that is about to be ripped away from the IR with no real replacement.

Thanks for your reply. I am trying to retrieve a string value stored in a shared pointer; these are smart pointers that keep track of how many instances of the pointer exist and only clean up the memory when the count reaches zero. I am able to retrieve the values of a string. But whenever I am trying to retrieve values from a shared pointer, it is reading some garbage. I don’t know if it’s because the shared pointer manages the values at runtime or not. This can be a reason if there is no value then it is reading wrong registers and that’s why it is printing that gibberish.

I am trying to compile MQTT protocol and trying to retrieve it’s values at runtime when the values are sent to the subscriber. Like in the following pic, a message Hello, MQTT is sent to other terminal and it is received under topic my/topic. These two values are stored in a shared pointer. I want to get these 2 values at runtime. In that pic, you also see arg_values: .... that is instrumented at runtime. Now, this is printing some garbage values but it was supposed to print one of those two strings my/topic or, Hello, MQTT.

Here is the full post: How to print a shared pointer value at runtime

@jcranmer is it possible?

@jcranmer bro, did it by using some predefined functions.