GDB conditional break on function parameter

前端 未结 3 1364
一生所求
一生所求 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:19

    Assuming x86-64 calling conventions on GNU/Linux platform you could examine %rdi (64-bit) register directly to check function's first parameter:

    b calc if $rdi == 852479
    

    This allows you to break on function calc even if you don't have debugging symbols loaded (thus no code listing, i.e. by list calc).

    Note that this method would fail if function is inlined by optimizing compiler.

提交回复
热议问题