我想知道现有的GDB对于RISC-V是否支持程序上下文感知的断点?
程序上下文感知断点:我的意思是,当有JAL或JALR指令时,PC会在函数调用时改变。在函数调用==> PC = PC +(当前程序计数器+ 4)的其他情况下,函数返回: PC = PC -(返回地址(ra寄存器值) )。
我已经在我的ubuntu(虚拟机)上安装了fedora(risc-V)。因为它是虚拟机,所以我无法打印PC寄存器值,这就是为什么我不能检查它是否支持程序上下文感知的断点?
我的第二个问题是:如何在我的qemu v虚拟机上打印PC寄存器值?
#include<stdio.h>
int check_prime(int a)
{
int c;
for (c=2;c<a;c++)
{
if (a%c == 0 ) return 0;
if (c == a-1 ) return 1;
}
}
void oddn(int a)
{
printf("oddn --> %d is an odd number \n",a);
if (check_prime(a)) printf("oddn --> %d is a prime number\n",a);
}
int main()
{
int a;
a=7;
if (check_prime(a)) printf("%d is a prime number \n",a);
if (a%2==1) oddn(a);
}这是我试图用GDB断点的程序。

正如您在图片上看到的那样,它会中断两次(这应该只破坏一次,只有)。它还会产生错误:
Error in testing breakpoint condition:
Invalid data type for function to be called发布于 2020-11-05 11:36:09
你要找的东西在这里有记录:
您应该看看$_caller_is、$_caller_matches、$_any_caller_is和$_any_caller_matches。
例如,要检查直接调用方是否是特定函数,我们可以这样做:
break functionD if ($_caller_is ("functionC"))然后main -> functionD不会触发断点,而main -> functionC -> functionD将触发断点。
我列出的方便函数都采用了一个框架偏移量,可以用来指定哪个框架GDB将检查(对于$_caller_is和$_caller_matches),或者限制检查的帧范围(对于$_any_caller_is和$_any_caller_matches)。
https://stackoverflow.com/questions/64638820
复制相似问题