Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve accessibility in debugging #199

Closed
wants to merge 8 commits into from

Conversation

mingxwa
Copy link
Collaborator

@mingxwa mingxwa commented Nov 17, 2024

Motivation

Member functions of proxy cannot be called from a debugger, making it difficult to debug with a value of proxy from client code.

Changes

  • Added a helper type details::symbol_guard to guide symbol generation in a debug build (when NODEBUG is not defined).
  • Enabled symbol generation for proxy::operator-> and proxy::operator*.
  • Enabled symbol generation for all the pre-defined dispatch types and macros that generates member functions, including operator_dispatch, conversion_dispatch, PRO_DEF_MEM_DISPATCH, PRO_DEF_FREE_AS_MEM_DISPATCH and the dispatch type generated for basic_facade_builder::add_facade<F, true>.
  • Refactored the implementation of proxy accordingly to ensure template instantiation happens at the right spots.
  • Moved some types out of an anonymous namespace in unit tests to avoid generating warnings of unused variables in a debug build.
  • Removed some warning suppressions in unit tests accordingly.

Verification

Build the following code with MSVC in debug mode (without using the value of proxy in the code):

#include <string>

#include "proxy.h"

PRO_DEF_FREE_AS_MEM_DISPATCH(MemToString, std::to_string, ToString);

struct Stringable : pro::facade_builder
  ::add_convention<MemToString, std::string() const>
  ::build {};

int main() {
  int v = 123;
  pro::proxy<Stringable> p = &v;
}

Set a breakpoint at the end of main and inspect the value of p in the debugger. The debugger invokes the correct function for me.

image

@mingxwa mingxwa closed this Nov 18, 2024
@mingxwa mingxwa mentioned this pull request Nov 18, 2024
@mingxwa mingxwa deleted the user/mingxwa/debug2 branch November 22, 2024 06:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants