Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9116895
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T04:46:55+00:00 2026-06-17T04:46:55+00:00

I’m using qt-creator as an IDE and frontend for gdb. How can I set

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T04:46:56+00:00Added an answer on June 17, 2026 at 4:46 am

    How can I set a breakpoint at std::cerr

    Your question doesn’t make sense: std::cerr is 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_FILENO file descriptor?”.

    If that’s the case, catch syscall write might be the answer (but the real answer depends on your OS, which you didn’t reveal).

    Update:

    catching syscall write is not an option I believe, because I’m frequently writing to files

    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):

    cat t.cc
    #include <iostream>
    using namespace std;
    
    int main()
    {
       cout << "Hello,";
       cerr << "error 1" << endl;
       cout << " World!" << endl;
       cerr << "error 2" << endl;
    }
    
    gcc -g t.cc
    gdb -q ./a.out
    Reading symbols from /tmp/a.out...done.
    
    (gdb) catch syscall write
    Catchpoint 2 (syscall 'write' [1])
    
    # Make the catchpoint conditional on writing to stderr:
    (gdb) cond 2 $rdi == 2
    
    # By default, "catch syscall" will stop both before and after the actual syscall
    # Ignoring the catchpoint once will skip past the "after" stop.
    (gdb) command 2 
    Type commands for breakpoint(s) 2, one per line.
    End with a line saying just "end".
    >ignore 2 1
    >end
    
    (gdb) r
    Starting program: /tmp/a.out 
    Hello,
    Catchpoint 2 (call to syscall write), 0x00007ffff7383ff0 in __write_nocancel () at ../sysdeps/unix/syscall-template.S:82
    82  ../sysdeps/unix/syscall-template.S: No such file or directory.
    (gdb) x/s $rsi
    0x400a83:   "error 1"    # Good: we caught our first write to std::cerr
    
    (gdb) c
    Continuing.
    error 1
    Catchpoint 2 (call to syscall write), 0x00007ffff7383ff0 in __write_nocancel () at ../sysdeps/unix/syscall-template.S:82
    82  in ../sysdeps/unix/syscall-template.S
    (gdb) x/s $rsi
    0x7ffff76298e3 <_IO_2_1_stderr_+131>:   "\n"  # I didn't know endl gets a separate write syscall.
    (gdb) c
    Continuing.
    
     World!
    
    Catchpoint 2 (call to syscall write), 0x00007ffff7383ff0 in __write_nocancel () at ../sysdeps/unix/syscall-template.S:82
    82  in ../sysdeps/unix/syscall-template.S
    (gdb) x/s $rsi
    0x400a93:   "error 2"
    (gdb) c
    Continuing.
    error 2
    Catchpoint 2 (call to syscall write), 0x00007ffff7383ff0 in __write_nocancel () at ../sysdeps/unix/syscall-template.S:82
    82  in ../sysdeps/unix/syscall-template.S
    (gdb) x/s $rsi
    0x7ffff76298e3 <_IO_2_1_stderr_+131>:   "\n"
    (gdb) c
    Continuing.
    
    [Inferior 1 (process 17291) exited normally]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a jquery bug and I've been looking for hours now, I can't
I am using the SimpleRSS gem to parse a WordPress RSS feed. The only
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
We're building an app, our first using Rails 3, and we're having to build
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I have a text area in my form which accepts all possible characters from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.