GDB: break if variable equal value

前端 未结 4 1819
既然无缘
既然无缘 2020-12-07 10:34

I like to make GDB set a break point when a variable equal some value I set, I tried this example:

#include 
main()
{ 
     int i = 0;
     fo         


        
4条回答
  •  粉色の甜心
    2020-12-07 10:54

    There are hardware and software watchpoints. They are for reading and for writing a variable. You need to consult a tutorial:

    http://www.unknownroad.com/rtfm/gdbtut/gdbwatch.html

    To set a watchpoint, first you need to break the code into a place where the varianle i is present in the environment, and set the watchpoint.

    watch command is used to set a watchpoit for writing, while rwatch for reading, and awatch for reading/writing.

提交回复
热议问题