Seems not relevant to some questions with similar titles.

//some other code std::string s = Lookup->getName().str(); -> break here //some other code 

Note: "Lookup" is clang::DirectoryLookup , "Lookup->getName()" is llvm::StringRef .

When break at the above place, in the "Watch" pane in VS2017, the string variable "s" is initialized successfully and its value can be shown in "Watch" pane.

But when try to show(watch) the expression "Lookup->getName().str()" which is just how "s" is initialized, it says:

Lookup->getName().str() | Function llvm::StringRef::str has no address, possibly due to compiler optimizations. 

the source code of StringRef::str() is:

/// str - Get the contents as an std::string. LLVM_NODISCARD std::string str() const { if (!Data) return std::string(); return std::string(Data, Length); } 

And all the libraries is in debug version. Based on the above fact, there seems to be no reason for this to happen.

Such thing happens in other situations during debuging a Clang Libtooling program and it make debugging very hard.

What is the possible reason and how to solve it?

1

3 Answers

I tried @user15331850 solution and it didn't help, but setting Linker-> Debugging-> Generate Debug Info to "/DEBUG:FULL" seems giving me all variables now.

2

This may be due to optimization option is enabled. You can disable the same by following these steps:

  • Right click on the solution
  • Click on the "properties"
  • From the left pane, click on the "Configuration Properties"
  • Click on "C/C++" from the sub-option
  • Then click on the "optimization" and select "Disabled(/Od)" from the list

That's it. Hope it works for you!!

1

I had this issue. I needed to change the settings for: Linker-> Debugging-> Generate Debug Info from "/DEBUG:FASTLINK" to "/DEBUG".

1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy