summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tests/ChangeLog4
-rw-r--r--tests/dwflmodtest.c45
2 files changed, 45 insertions, 4 deletions
diff --git a/tests/ChangeLog b/tests/ChangeLog
index 6373df23..ee83376f 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,3 +1,7 @@
+2005-08-07 Roland McGrath <[email protected]>
+
+ * dwflmodtest.c: Print function details only if -f flag is given.
+
2005-08-06 Ulrich Drepper <[email protected]>
* run-elflint-self.sh: New file.
diff --git a/tests/dwflmodtest.c b/tests/dwflmodtest.c
index 948e971a..e2b7d3cf 100644
--- a/tests/dwflmodtest.c
+++ b/tests/dwflmodtest.c
@@ -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));