10

I am using the pimpl idiom to hide the implementation details of an interface so that I can have some measure of ABI protection. I'm not that well versed on the ins and outs of MS...using Linux for most of my development career.

I'm unable to view the insides of the pimpl from the debugger inspection window. My types expand only so far as the raw pointer to impl (it uses a smart pointer). I've tried exporting the symbols, but that doesn't seem to work. I suppose the symbols I'm actually trying to view are not being imported or something.

How do I remedy this? Can visualizers call functions perhaps?

Edit -- perhaps I confused people with the export thing.

I'm trying this:

object.h:

struct EXPORT object {
    struct EXPORT impl;
    impl * pimpl;
};

object.cpp

struct EXPORT object::impl {
    char member;
};

The only way I can think to solve the problem is to put the impls in headers that are included in debug versions of the library. Hoping for a better solution.

Edward Strange
  • 38,861
  • 7
  • 65
  • 123

1 Answers1

0

I could not replicate it with this setup:

CMakeLists.txt

cmake_minimum_required(VERSION 3.8.0)

project(test)
set(DLL_SRCS thing.cpp)
set(DLL_HDRS thing.h)
add_library(Thing SHARED ${DLL_SRCS} ${DLL_HDRS})

set(Headers_dir ${CMAKE_CURRENT_BINARY_DIR}/dll_public_headers)
configure_file(${DLL_HDRS} ${Headers_dir} COPYONLY)

set(APP_SRCS main.cpp)

add_executable(App ${APP_SRCS})

target_link_libraries(APP Thing)
include_directories(${Headers_dir})

thing.h

#pragma once

struct thing
{
private:
  struct Private;
public:
  thing();
  Private * impl
};

thing.cpp

#include "thing.h"

struct thing::Private
{
  char member;
}

thing::thing()
{
  impl = new Private;
  impl->member = 'a';
}

main.cpp

#include "thing.h"

int main(int argc, char * argv[])
{
  thing thing_from_dll;
  return 0;
}

If you don't get it working, I would urge you to provide a similar mcve. I'm not that anal about this, so don't worry. I will still help you.

This worked on visual studio 2017. I placed a breakpoint on return 0 and could see that member had the value of 'a'.

The only thing I can think that might be missing from your setup are the source files for the debugger. Maybe it can load your debugging database, but doesn't actually find the files where you have defined what your private implementation is. Look here for more details on that.

0xbaadf00d
  • 2,353
  • 1
  • 17
  • 44