dpc
Debug program counter
- Address
0x7B1- Group
- Debug CSRs (0x7A0 to 0x7BF)
- Privilege
DRW(privileged spec CSR listing, Debug Mode Registers)- Access
- read/write; lowest privilege Debug mode only
- Address range
- Debug-mode-only CSRs
- Name in riscv-unified-db
- Debug PC Register
Privileged spec: Debug program counter
Description
Upon entry to debug mode, dpc is updated with the virtual address of the next instruction to be executed.
Executing the Program Buffer may cause the value of dpc to become UNSPECIFIED. If that is the case, it must be possible to read/write dpc using an abstract command with postexec not set. The debugger must attempt to save dpc between halting and executing a Program Buffer, and then restore dpc before leaving Debug Mode.
If the Access Register abstract command supports reading dpc while the hart is running, then the value read should be the address of a recently executed instruction.
If the Access Register abstract command supports writing dpc while the hart is running, then the executing program should jump to the written address shortly after the write occurs.
The writability of dpc follows the same rules as mepc as defined in the Privileged Spec. In particular, dpc must be able to hold all valid virtual addresses and the writability of the low bits depends on IALIGN.
When resuming, the hart’s PC is updated to the virtual address stored in dpc. A debugger may write dpc to change where the hart resumes.
This CSR is read/write.
From riscv-unified-db, reformatted.
Fields
| Field | Bits | Type | Description |
|---|---|---|---|
DPC | RV32 31-0 / RV64 63-0 | RW | Debug PC Value |
Fields from riscv-unified-db; field types computed by IDL functions there are not shown.
Specification and related pages
- The RISC-V Instruction Set Manual, Volume II: CSR listing (src/priv/csrs.adoc)
- riscv-opcodes csrs.csv
- riscv-unified-db: spec/std/isa/csr/dpc.yaml
- csrrw, csrrs, csrrc (Zicsr instructions that access CSRs)