gdb: add target_ops::supports_displaced_step
[deliverable/binutils-gdb.git] / libctf / ctf-lookup.c
index 7ea46a7295b10fc755b0fa040b7585c4180f512c..d95e53706c132419b688925e41638139b779c76e 100644 (file)
@@ -1,5 +1,5 @@
-/* Type lookup.
-   Copyright (C) 2019 Free Software Foundation, Inc.
+/* Symbol, variable and name lookup.
+   Copyright (C) 2019-2020 Free Software Foundation, Inc.
 
    This file is part of libctf.
 
@@ -153,7 +153,7 @@ ctf_lookup_by_name (ctf_file_t *fp, const char *name)
              else
                {
                  free (fp->ctf_tmp_typeslice);
-                 fp->ctf_tmp_typeslice = strndup (p, (size_t) (q - p));
+                 fp->ctf_tmp_typeslice = xstrndup (p, (size_t) (q - p));
                  if (fp->ctf_tmp_typeslice == NULL)
                    {
                      (void) ctf_set_errno (fp, ENOMEM);
@@ -161,8 +161,8 @@ ctf_lookup_by_name (ctf_file_t *fp, const char *name)
                    }
                }
 
-             if ((type = ctf_hash_lookup_type (lp->ctl_hash, fp,
-                                               fp->ctf_tmp_typeslice)) == 0)
+             if ((type = ctf_lookup_by_rawhash (fp, lp->ctl_hash,
+                                                fp->ctf_tmp_typeslice)) == 0)
                {
                  (void) ctf_set_errno (fp, ECTF_NOTYPE);
                  goto err;
@@ -322,13 +322,6 @@ ctf_lookup_by_id (ctf_file_t **fpp, ctf_id_t type)
       return NULL;
     }
 
-  idx = LCTF_TYPE_TO_INDEX (fp, type);
-  if (idx > 0 && (unsigned long) idx <= fp->ctf_typemax)
-    {
-      *fpp = fp;               /* Function returns ending CTF container.  */
-      return (LCTF_INDEX_TO_TYPEPTR (fp, idx));
-    }
-
   /* If this container is writable, check for a dynamic type.  */
 
   if (fp->ctf_flags & LCTF_RDWR)
@@ -340,7 +333,19 @@ ctf_lookup_by_id (ctf_file_t **fpp, ctf_id_t type)
          *fpp = fp;
          return &dtd->dtd_data;
        }
+      (void) ctf_set_errno (*fpp, ECTF_BADID);
+      return NULL;
     }
+
+  /* Check for a type in the static portion.  */
+
+  idx = LCTF_TYPE_TO_INDEX (fp, type);
+  if (idx > 0 && (unsigned long) idx <= fp->ctf_typemax)
+    {
+      *fpp = fp;               /* Function returns ending CTF container.  */
+      return (LCTF_INDEX_TO_TYPEPTR (fp, idx));
+    }
+
   (void) ctf_set_errno (*fpp, ECTF_BADID);
   return NULL;
 }
@@ -412,8 +417,8 @@ ctf_func_args (ctf_file_t * fp, unsigned long symidx, uint32_t argc,
   const uint32_t *dp;
   ctf_funcinfo_t f;
 
-  if (ctf_func_info (fp, symidx, &f) == CTF_ERR)
-    return CTF_ERR;            /* errno is set for us.  */
+  if (ctf_func_info (fp, symidx, &f) < 0)
+    return -1;                 /* errno is set for us.  */
 
   /* The argument data is two uint32_t's past the translation table
      offset: one for the function info, and one for the return type. */
This page took 0.034496 seconds and 4 git commands to generate.