0

I have built google gflags in windows using visual studio 2015. The built is a Debug build (so Program Database (/Zi) is set) and I'm stepping through the gflags_unittest_main.cc. The unit test passes successfully. However, while debugging I can't see the contents of the FLAGS_## variables.

For example, line 1515 of gflags_unittest_main.cc is

FLAGS_changed_bool2 = true;

I can't see the value of FLAGS_changed_bool2 in the watch window. I have tried adding the google:: and gflags:: namespaces in front of FLAGS_changed_bool2 but it just says identifier is undefined. Here it says you can access these flags just as a normal variables.

Why can't I see the values of these variables while debugging? What can I do to see them? maybe some build option?

I'm trying to understand the code of another open source library that uses gflags and has hundreds of FLAGS_ variables. Not being able to see the contents of these variables makes the task more difficult.

martinako
  • 2,690
  • 1
  • 25
  • 44
  • The debugger doesn't know anything about these stoopid macro tricks. Look at the [output of /P](https://msdn.microsoft.com/en-us/library/8z9z0bx6.aspx) to know what the real identifier name looks like. – Hans Passant Nov 09 '15 at 16:00
  • Thanks for the suggestion. I have generated the file gflags_unittest_main.i with the /P option and the example variable I mentioned is still called FLAGS_changed_bool2 – martinako Nov 09 '15 at 16:17

1 Answers1

1

I found a workaround for this. Each of the FLAGS_ variables are created inside namespaces which include a short identifier for the type (see DEFINE_VARIABLE macro in gflags.h). For example, fLI for integer, fLB for bool, fLS for String, etc.

So if I add to the watch window the following:

fLB::FLAGS_changed_bool2  
fLI64::FLAGS_this_is_an_int64_variable

I can see their values.

The DEFINE_VARIABLE macro adds a using statement

using fL##shorttype::FLAGS_##name

after the definition of the variable inside the fL##shorttype, which allows the user code to refer to FLAGS_##name directly. However the Visual Studio debugger ignores this using and needs the namespace for each of these variables. I guess the next question is how to get visual studio to use this using statements, so that I can hover my mouse pointer over the variable a see its value.

martinako
  • 2,690
  • 1
  • 25
  • 44