bug-binutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[riscv gdb]When step in a new function,GDB can not get the correct param


From: jing zhang
Subject: [riscv gdb]When step in a new function,GDB can not get the correct parameter values
Date: Tue, 19 Mar 2024 15:21:36 +0800

When using the si (step into) command in GDB to jump into a new function during debugging, the debugger incorrectly retrieves or interprets the parameters of the function. As a result, GDB prints incorrect parameter values, which can sometimes lead to CPU traps due to access to illegal memory addresses.

Here are the details of the problem encountered:

GDB Version: 12.0.50

Platform: RISC-V

The elf which I debug is compiled with -O0 and -gdwarf-2. Steps to Reproduce:

1.Set a software breakpoint at the address 0x800142da.

  1. 2.Run the program until the breakpoint is triggered.
  2. 3.Use the si command to step into the fdt_path_offset_namelen function.
  3. 4.GDB prints the parameters of fdt_path_offset_namelen, which may lead to CPU traps due to incorrect parameter values.

The example:

image.png
For the picture above, I add an software breakpoint on the address of 0x800142da, the run the program until the beakpoint trigged. Then use si command,it will jump into the fdt_path_offset_namelen function. The disassembly of function fdt_path_offset_namelen is :
image.png
The si command of GDB will print the parameters of fdt_path_offset_namelen,it will cause an CPU trap because an  an accessment of an illegal address.  The GDB debug info is as below:
image.png
During this process, GDB calcute the parameters through the dwarf info. The pictures below are the CFA info and  debug info :
image.png

image.png
  I kindly request your help in addressing this problem.

If possible, could you provide guidance on how to troubleshoot and resolve this issue?


reply via email to

[Prev in Thread] Current Thread [Next in Thread]