]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
2005-08-07 Roland McGrath <roland@redhat.com>
authorRoland McGrath <roland@redhat.com>
Sun, 7 Aug 2005 21:42:07 +0000 (21:42 +0000)
committerRoland McGrath <roland@redhat.com>
Sun, 7 Aug 2005 21:42:07 +0000 (21:42 +0000)
* dwflmodtest.c: Print function details only if -f flag is given.

tests/ChangeLog
tests/dwflmodtest.c

index 6373df239023376296693e970b7a5e32ff6a5e2d..ee83376fcd4ed926ea87d31500f950dc661c507e 100644 (file)
@@ -1,3 +1,7 @@
+2005-08-07  Roland McGrath  <roland@redhat.com>
+
+       * dwflmodtest.c: Print function details only if -f flag is given.
+
 2005-08-06  Ulrich Drepper  <drepper@redhat.com>
 
        * run-elflint-self.sh: New file.
index 948e971aa6cec9ba42e67d55ccc89bfc476e9a29..e2b7d3cf42107a70c2167842f908e4670c9ecef7 100644 (file)
@@ -66,12 +66,12 @@ print_module (Dwfl_Module *mod __attribute__ ((unused)),
              void **userdata __attribute__ ((unused)),
              const char *name, Dwarf_Addr base,
              Dwarf *dw, Dwarf_Addr bias,
-             void *arg __attribute__ ((unused)))
+             void *arg)
 {
   printf ("module: %30s %08" PRIx64 " %12p %" PRIx64 " (%s)\n",
          name, base, dw, bias, dwfl_errmsg (-1));
 
-  if (dw != NULL)
+  if (dw != NULL && *(const bool *) arg)
     {
       Dwarf_Off off = 0;
       size_t cuhl;
@@ -91,6 +91,34 @@ print_module (Dwfl_Module *mod __attribute__ ((unused)),
   return DWARF_CB_OK;
 }
 
+static bool show_functions;
+
+static const struct argp_option options[] =
+  {
+    { "functions", 'f', NULL, 0, N_("Additional show function names"), 0 },
+    { NULL, 0, NULL, 0, NULL, 0 }
+  };
+
+static error_t
+parse_opt (int key, char *arg __attribute__ ((unused)),
+          struct argp_state *state __attribute__ ((unused)))
+{
+  switch (key)
+    {
+    case ARGP_KEY_INIT:
+      state->child_inputs[0] = state->input;
+      break;
+
+    case 'f':
+      show_functions = true;
+      break;
+
+    default:
+      return ARGP_ERR_UNKNOWN;
+    }
+  return 0;
+}
+
 int
 main (int argc, char **argv)
 {
@@ -101,12 +129,21 @@ main (int argc, char **argv)
   (void) setlocale (LC_ALL, "");
 
   Dwfl *dwfl = NULL;
-  (void) argp_parse (dwfl_standard_argp (), argc, argv, 0, NULL, &dwfl);
+  const struct argp_child argp_children[] =
+    {
+      { .argp = dwfl_standard_argp () },
+      { .argp = NULL }
+    };
+  const struct argp argp =
+    {
+      options, parse_opt, NULL, NULL, argp_children, NULL, NULL
+    };
+  (void) argp_parse (&argp, argc, argv, 0, NULL, &dwfl);
   assert (dwfl != NULL);
 
   ptrdiff_t p = 0;
   do
-    p = dwfl_getdwarf (dwfl, &print_module, NULL, p);
+    p = dwfl_getdwarf (dwfl, &print_module, &show_functions, p);
   while (p > 0);
   if (p < 0)
     error (2, 0, "dwfl_getdwarf: %s", dwfl_errmsg (-1));