On Fri, 23 Oct 2026 09:25:33 GMT, Long Yang <[email protected]> wrote:

>> Long Yang has updated the pull request with a new target base due to a merge 
>> or a rebase. The pull request now contains nine commits:
>> 
>>  - Merge branch 'master' into fix-8391637
>>  - Enable TestJhsdbJstackMixedWithXComp.java on riscv64 while excluding QEMU 
>> environments
>>  - Enable -fasynchronous-unwind-tables for linux-riscv64
>>  - Add try/catch for memory-read exceptions in getSenderFP
>>  - RISC-V: Use compiler-defined macros for DWARF register selection
>>  - Recover caller return addresses across save helpers
>>  - Use the CIE return-address column instead of the hard-coded RA register
>>  - Add comment
>>  - 8391637: On the RISC-V platform, TestJhsdbJstackMixed has a certain 
>> probability of failure
>
> I have examined how GDB operates; this is not necessarily an authoritative 
> conclusion.
> 
> GDB 18.1 follows this workflow:
> 1. Read the original frame PC using get_frame_pc().
> 2. Choose the lookup address using get_frame_address_in_block():
>   - Ordinary caller return address → PC−1.
>   - Top-frame or signal-restored execution PC → exact PC.
> 3. Select the FDE using that lookup address.
> 4. Interpret the CFI rules up to the same address, using fs->pc <= pc.
> 
> PC−1 is a lookup adjustment; it does not replace the original frame PC.
> 
> 
> 
> get_frame_address_in_block() // gdb/frame.c:2855–2904, see the comments
> ...
>  if ((get_frame_type (next_frame) == NORMAL_FRAME
>       || get_frame_type (next_frame) == TAILCALL_FRAME)
>      && (get_frame_type (this_frame) == NORMAL_FRAME
>          || get_frame_type (this_frame) == TAILCALL_FRAME
>          || get_frame_type (this_frame) == INLINE_FRAME))
>    return pc - 1;
> 
>  return pc;
> ...
> 
> dwarf2_frame_find_fde
> 
> execute_cfa_program
> 
> // The interpreter uses an inclusive comparison (gdb/dwarf2/frame.c:257)
> while (insn_ptr < insn_end && fs->pc <= pc)
> ...
> 
> 
> My RISC-V implementation follows the same principle: exact PCs for 
> top/signal-restored frames, and PC−1 lookup for ordinary native caller frames.

Thanks @yanglong1010 for sharing GDB implementation! I think it makes sense to 
follow this - using "PC - 1" in SA for both amd64 and aarrch64. However I think 
it is better to tackle in another issue.
Could you file it and create PR after this? I'm happy to review it.

-------------

PR Comment: https://git.openjdk.org/jdk/pull/33374#issuecomment-6377732515

Reply via email to