I’m using qt-creator as an IDE and frontend for gdb. How can I set a breakpoint when operator<< is called on std::cerr variable? Is it possible from qt-creator or I will have to run gdb standalone?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Your question doesn’t make sense:
std::cerris a global variable. You can set breakpoints only on functions. You can also set watchpoints on variables, so GDB stops when the variable is modified, but it’s likely not what you want either.What you are probably asking is: “how can I stop when something is written to
STDERR_FILENOfile descriptor?”.If that’s the case,
catch syscall writemight be the answer (but the real answer depends on your OS, which you didn’t reveal).Update:
You can make the syscall catchpoint conditional on writing to
STDERR_FILENO(which is 2 on Linux). Example (this will work on Linux/x86_64, but would need to be adjusted for Linux/ix86):