diff --git a/libdw/libdw.map b/libdw/libdw.map
index 6da25561..8f393438 100644
--- a/libdw/libdw.map
+++ b/libdw/libdw.map
@@ -370,4 +370,5 @@ ELFUTILS_0.186 {
 ELFUTILS_0.188 {
   global:
     dwfl_get_debuginfod_client;
+    dwfl_frame_reg;
 } ELFUTILS_0.186;
diff --git a/libdwfl/dwfl_frame_regs.c b/libdwfl/dwfl_frame_regs.c
index 83b1abef..92c4a692 100644
--- a/libdwfl/dwfl_frame_regs.c
+++ b/libdwfl/dwfl_frame_regs.c
@@ -59,3 +59,21 @@ dwfl_thread_state_register_pc (Dwfl_Thread *thread,
Dwarf_Word pc)
   state->pc_state = DWFL_FRAME_STATE_PC_SET;
 }
 INTDEF(dwfl_thread_state_register_pc)
+
+bool
+dwfl_frame_reg (Dwfl_Frame *state, unsigned regno, Dwarf_Word *val)
+{
+  if ((state->regs_set[regno / sizeof (*state->regs_set) / 8]
+       & ((uint64_t) 1U << (regno % (sizeof (*state->regs_set) * 8)))) ==
0)
+    {
+      __libdwfl_seterrno (DWFL_E_INVALID_REGNO);
+      return false;
+    }
+  if (! __libdwfl_frame_reg_get (state, regno, val))
+    {
+      __libdwfl_seterrno (DWFL_E_INVALID_REGISTER);
+      return false;
+    }
+  return true;
+}
+INTDEF(dwfl_frame_reg)
diff --git a/libdwfl/frame_unwind.c b/libdwfl/frame_unwind.c
index 9ac33833..38f5b332 100644
--- a/libdwfl/frame_unwind.c
+++ b/libdwfl/frame_unwind.c
@@ -78,17 +78,6 @@ __libdwfl_frame_reg_set (Dwfl_Frame *state, unsigned
regno, Dwarf_Addr val)
   return true;
 }

-static bool
-state_get_reg (Dwfl_Frame *state, unsigned regno, Dwarf_Addr *val)
-{
-  if (! __libdwfl_frame_reg_get (state, regno, val))
-    {
-      __libdwfl_seterrno (DWFL_E_INVALID_REGISTER);
-      return false;
-    }
-  return true;
-}
-
 static int
 bra_compar (const void *key_voidp, const void *elem_voidp)
 {
@@ -211,7 +200,7 @@ expr_eval (Dwfl_Frame *state, Dwarf_Frame *frame, const
Dwarf_Op *ops,
     }
   break;
  case DW_OP_reg0 ... DW_OP_reg31:
-  if (! state_get_reg (state, op->atom - DW_OP_reg0, &val1)
+  if (! dwfl_frame_reg (state, op->atom - DW_OP_reg0, &val1)
       || ! push (val1))
     {
       free (stack.addrs);
@@ -219,14 +208,14 @@ expr_eval (Dwfl_Frame *state, Dwarf_Frame *frame,
const Dwarf_Op *ops,
     }
   break;
  case DW_OP_regx:
-  if (! state_get_reg (state, op->number, &val1) || ! push (val1))
+  if (! dwfl_frame_reg (state, op->number, &val1) || ! push (val1))
     {
       free (stack.addrs);
       return false;
     }
   break;
  case DW_OP_breg0 ... DW_OP_breg31:
-  if (! state_get_reg (state, op->atom - DW_OP_breg0, &val1))
+  if (! dwfl_frame_reg (state, op->atom - DW_OP_breg0, &val1))
     {
       free (stack.addrs);
       return false;
@@ -239,7 +228,7 @@ expr_eval (Dwfl_Frame *state, Dwarf_Frame *frame, const
Dwarf_Op *ops,
     }
   break;
  case DW_OP_bregx:
-  if (! state_get_reg (state, op->number, &val1))
+  if (! dwfl_frame_reg (state, op->number, &val1))
     {
       free (stack.addrs);
       return false;
@@ -591,7 +580,7 @@ handle_cfi (Dwfl_Frame *state, Dwarf_Addr pc, Dwarf_CFI
*cfi, Dwarf_Addr bias)
   else if (reg_ops == NULL)
     {
       /* REGNO is same-value.  */
-      if (! state_get_reg (state, regno, &regval))
+      if (! dwfl_frame_reg (state, regno, &regval))
  continue;
     }
   else
diff --git a/libdwfl/libdwfl.h b/libdwfl/libdwfl.h
index b323e8fb..aba75afe 100644
--- a/libdwfl/libdwfl.h
+++ b/libdwfl/libdwfl.h
@@ -798,6 +798,10 @@ int dwfl_getthread_frames (Dwfl *dwfl, pid_t tid,
 bool dwfl_frame_pc (Dwfl_Frame *state, Dwarf_Addr *pc, bool *isactivation)
   __nonnull_attribute__ (1, 2);

+/* Return *val (register value) for frame STATE.  */
+bool dwfl_frame_reg (Dwfl_Frame *state, unsigned regno, Dwarf_Word *val)
+  __nonnull_attribute__ (1);
+
 /* Return the internal debuginfod-client connection handle for the DWFL
session.
    When the client connection has not yet been initialized, it will be
done on the
    first call to this function. If elfutils is compiled without support
for debuginfod,
diff --git a/libdwfl/libdwflP.h b/libdwfl/libdwflP.h
index 9f598370..a6d4396a 100644
--- a/libdwfl/libdwflP.h
+++ b/libdwfl/libdwflP.h
@@ -81,6 +81,7 @@ typedef struct Dwfl_Process Dwfl_Process;
   DWFL_ERROR (LIBEBL_BAD, N_("Internal error due to ebl"))      \
   DWFL_ERROR (CORE_MISSING, N_("Missing data in core file"))      \
   DWFL_ERROR (INVALID_REGISTER, N_("Invalid register"))      \
+  DWFL_ERROR (INVALID_REGNO, N_("Invalid register number"))      \
   DWFL_ERROR (PROCESS_MEMORY_READ, N_("Error reading process memory"))
 \
   DWFL_ERROR (PROCESS_NO_ARCH, N_("Couldn't find architecture of any
