GDB conditional break on function parameter

前端 未结 3 1360
一生所求
一生所求 2021-02-19 07:44

I\'m wanting to set a breakpoint on a function parameter if it is greater than a certain value. Dummy code below:

int main(void)
{
    uint64_t num = 123456;
            


        
3条回答
  •  悲哀的现实
    2021-02-19 08:16

    from the gdb prompt:

    break "file.c":100 if (size=852479)
    

    or

    break "file.c":100 if (size>852479)
    

    here i am assuming you want the conditional breakpoint on line 100 and your src file is file.c

    i.e if you want to break on the line that calls calc, then that would be line 100 - modify as appropriate (you would also have to substitute size with other in this instance)

    if you used a line no. that was one of the 1st statements in the calc function then you would stick with size

提交回复
热议问题