如何在Windbg中为参数值设置条件断点

问题描述 投票:0回答:2

我具有这样的功能:

int fn(int a, int b)
{
    int x, y;
    x = a + 5;
    y = a - b;
    return x / y;
}

[我需要在Windbg中设置一个条件断点,最好是在int x, y;等于5时在a(第18行)的那一行设置。

bp `main.c:18` ".if (a==5) {} .else {gc}"

我也尝试过

bp `main.c:18` ".if (a!=5) {gc} .else {}"但这给了我一个语法错误。这是怎么回事?

我具有这样的功能:int fn(int a,int b){int x,y; x = a + 5; y = a-b;返回x / y; }而且我需要在Windbg中设置一个条件断点,理想情况下是使用...

c windbg
2个回答
1
投票

您需要使用poi运算符,否则在调试器a中是变量a的地址。


0
投票
#include <stdio.h>
int fn(int a, int b) {
    int x, y;
    x = a + 5;
    y = a - b;
    return x / y;
}
int  main(void) {
    int res =0;
    for (int i = 10; i< 25; i++) {
     res = fn(i,5);
     printf("%d\n",res);
    }
    return res;
}
© www.soinside.com 2019 - 2024. All rights reserved.