]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
libctf, include: debuggability improvements
authorNick Alcock <nick.alcock@oracle.com>
Thu, 24 Apr 2025 13:20:28 +0000 (14:20 +0100)
committerNick Alcock <nick.alcock@oracle.com>
Fri, 25 Apr 2025 17:07:41 +0000 (18:07 +0100)
When --enable-libctf-hash-debugging is on, make ctf_set_errno and
ctf_set_typed_errno into real functions, not inlines, so you can
drop breakpoints on them.  Since we are breaking API, also move
ECTF_NEXT_END to the start of the _CTF_ERRORS array, so you can
check for real (non-ECTF_NEXT_END) errors in breakpooints on those
functions by checking for err > 1000.

include/ctf-api.h
libctf/ctf-api.c
libctf/ctf-inlines.h

index 2554c27546048e680e54fbb9ce919e2e3ff0b683..5ca8e76231f1a03909f1bb6bab350882da63699f 100644 (file)
@@ -183,7 +183,8 @@ typedef struct ctf_snapshot_id
    and _CTF_ITEM to expand as you like, then mention the macro name.
    See the enum after this for an example.  */
 #define _CTF_ERRORS \
-  _CTF_FIRST (ECTF_FMT, "File is not in CTF or ELF format.")   \
+  _CTF_FIRST (ECTF_NEXT_END, "End of iteration.") \
+  _CTF_ITEM (ECTF_FMT, "File is not in CTF or ELF format.") \
   _CTF_ITEM (ECTF_BFDERR, "BFD error.")                                \
   _CTF_ITEM (ECTF_CTFVERS, "CTF dict version is too new for libctf.") \
   _CTF_ITEM (ECTF_BFD_AMBIGUOUS, "Ambiguous BFD target.")      \
@@ -233,7 +234,6 @@ typedef struct ctf_snapshot_id
   _CTF_ITEM (ECTF_NOTYET, "Feature not yet implemented.") \
   _CTF_ITEM (ECTF_INTERNAL, "Internal error: assertion failure.") \
   _CTF_ITEM (ECTF_NONREPRESENTABLE, "Type not representable in CTF.") \
-  _CTF_ITEM (ECTF_NEXT_END, "End of iteration.") \
   _CTF_ITEM (ECTF_NEXT_WRONGFUN, "Wrong iteration function called.") \
   _CTF_ITEM (ECTF_NEXT_WRONGFP, "Iteration entity changed in mid-iterate.") \
   _CTF_ITEM (ECTF_FLAGS, "CTF header contains flags unknown to libctf.") \
index 479dcf6a350151ed529b708a77165fb7f6f2480a..60a53f25fd0b8fb9f5e8e1b4b67740f61ebb5631 100644 (file)
@@ -67,6 +67,26 @@ ctf_set_open_errno (int *errp, int error)
   return NULL;
 }
 
+/* See ctf-inlines.h.  */
+
+#ifdef ENABLE_LIBCTF_HASH_DEBUGGING
+int
+ctf_set_errno (ctf_dict_t *fp, int err)
+{
+  fp->ctf_errno = err;
+  /* Don't rely on CTF_ERR here as it will not properly sign extend on 64-bit
+     Windows ABI.  */
+  return -1;
+}
+
+ctf_id_t
+ctf_set_typed_errno (ctf_dict_t *fp, int err)
+{
+  fp->ctf_errno = err;
+  return CTF_ERR;
+}
+#endif
+
 /* Get and set CTF dict-wide flags.  We are fairly strict about returning
    errors here, to make it easier to determine programmatically which flags are
    valid.  */
index bf4b61e5cea4b72d8d2a400f5cf164bfb8d9dd05..5963fb3d6872ba6c8d810485c76ac453d689dc94 100644 (file)
@@ -90,6 +90,10 @@ ctf_assert_internal (ctf_dict_t *fp, const char *file, size_t line,
   return expr;
 }
 
+/* Un-inline these functions if debugging, so you can drop breakpoints on the
+   setting of any error anywhere by the library.  */
+
+#ifndef ENABLE_LIBCTF_HASH_DEBUGGING
 static inline int
 ctf_set_errno (ctf_dict_t *fp, int err)
 {
@@ -105,7 +109,10 @@ ctf_set_typed_errno (ctf_dict_t *fp, int err)
   fp->ctf_errno = err;
   return CTF_ERR;
 }
-
+#else
+extern int ctf_set_errno (ctf_dict_t *fp, int err);
+extern ctf_id_t ctf_set_typed_errno (ctf_dict_t *fp, int err);
+#endif
 
 #ifdef __cplusplus
 }