Skip to content
This repository was archived by the owner on Jan 29, 2026. It is now read-only.

Improve accessibility in debugging#199

Closed
mingxwa wants to merge 8 commits intomicrosoft:mainfrom
mingxwa:user/mingxwa/debug2
Closed

Improve accessibility in debugging#199
mingxwa wants to merge 8 commits intomicrosoft:mainfrom
mingxwa:user/mingxwa/debug2

Conversation

@mingxwa
Copy link
Contributor

@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 requested review from guominrui and tian-lt November 17, 2024 10:49
@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 subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants