0

I want to hide some functions from the debugger in C++. C# has the [DebuggerHidden] tag. Is there any equivalent feature in C++ to hide functions?

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
Pradeep Kumar
  • 109
  • 1
  • 10
  • 1
    No, there is no such feature in C++ – Mawg says reinstate Monica Sep 23 '19 at 06:22
  • 2
    Remove (`strip`) all debugging information? What is the actual problem you want to solve? – Some programmer dude Sep 23 '19 at 06:22
  • I believe you means Visual C++? I doubt this could be part of the ANSI C++ standard. – Adrian Shum Sep 23 '19 at 06:23
  • 3
    Sounds like an XY problem. What do you really want to do? – MSalters Sep 23 '19 at 07:04
  • I am going to release my Software to client , I want Hide some internal Function from debugger. – Pradeep Kumar Sep 23 '19 at 07:33
  • 1
    Then create a *release* build, without any debug information (and with optimizations enabled). Without debug information there won't be *any* symbols available for the clients. – Some programmer dude Sep 23 '19 at 07:35
  • Client also ask for a debug information.So i need this. – Pradeep Kumar Sep 23 '19 at 07:36
  • 2
    Could you put the specific funtions in a library and compile the lib without debug symbols? – RoQuOTriX Sep 23 '19 at 07:46
  • Are you saying you want to remove, from the PDB(s), symbols for *specific* functions, while still retaining them overall ? And is so, dare I ask what you honestly think you're accomplishing by doing this? Anyone with facilities to wire up the pdb you *do* provide will have no problem wiring up a disassembler to finish the job on their own.Regardless, [`/PDBSTRIPPED`](https://learn.microsoft.com/en-us/cpp/build/reference/pdbstripped-strip-private-symbols?view=vs-2015) *might* be long the line of what you're seeking, though I have reservations you want to go that far. – WhozCraig Sep 23 '19 at 07:50
  • If you completely want to exclude that function from Debug builds you can surround it by a `#ifdef NDEBUG` and `#endif` macro. – nada Sep 23 '19 at 08:23

1 Answers1

0

No, there is no C# [DebuggerHidden] equivalent or even close in C++. And afaik there isn't anything compiler specific either for the major compilers. At least not for specific functions.


Somewhat remotely related (ish) is the upcoming C++20 immediate functions (declared with consteval) which as far as I can tell will not appear in the binary at all, being entirely a compile-time feature. The fact that there will be no debug information is a side-effect and not the purpose of those so take them as you will. The fact that they can be evaluated only with compile-time parameter expressions makes them even less desirable for your demand.

bolov
  • 72,283
  • 15
  • 145
  • 224