diff options
author | Roland McGrath <[email protected]> | 2008-08-25 22:55:17 +0000 |
---|---|---|
committer | Roland McGrath <[email protected]> | 2008-08-25 22:55:17 +0000 |
commit | b4d6f0f8064f2b706ea9035ef0393d8299671390 (patch) | |
tree | 58d3da51253302bc5b8f2198d8462942ff43f464 /libdwfl/dwfl_getmodules.c | |
parent | f729d77881262094d365d33ac51063e25a02e357 (diff) |
Fix up bogon and missing log entries from .pmachata.threads branch.
Diffstat (limited to 'libdwfl/dwfl_getmodules.c')
-rw-r--r-- | libdwfl/dwfl_getmodules.c | 48 |
1 files changed, 41 insertions, 7 deletions
diff --git a/libdwfl/dwfl_getmodules.c b/libdwfl/dwfl_getmodules.c index 45e550a5..f205b899 100644 --- a/libdwfl/dwfl_getmodules.c +++ b/libdwfl/dwfl_getmodules.c @@ -1,5 +1,5 @@ /* Iterate through modules. - Copyright (C) 2005 Red Hat, Inc. + Copyright (C) 2005, 2008 Red Hat, Inc. This file is part of Red Hat elfutils. Red Hat elfutils is free software; you can redistribute it and/or modify @@ -59,15 +59,49 @@ dwfl_getmodules (Dwfl *dwfl, if (dwfl == NULL) return -1; - if ((size_t) offset > dwfl->nmodules) - return -1; + Dwfl_Module *m = dwfl->modulelist; - while ((size_t) offset < dwfl->nmodules) + if (unlikely (dwfl->lookup_module == NULL)) + { + for (ptrdiff_t pos = 0; pos < offset; ++pos) + if (m == NULL) + return -1; + else + m = m->next; + while (m != NULL) + { + ++offset; + if ((*callback) (MODCB_ARGS (m), arg) != DWARF_CB_OK) + return offset; + m = m->next; + } + } + else { - Dwfl_Module *mod = dwfl->modules[offset++]; - if ((*callback) (MODCB_ARGS (mod), arg) != DWARF_CB_OK) - return offset; + if (offset > 0) + { + if ((size_t) offset - 1 == dwfl->lookup_elts) + return 0; + + if (unlikely ((size_t) offset - 1 > dwfl->lookup_elts)) + return -1; + + m = dwfl->lookup_module[offset - 1]; + if (unlikely (m == NULL)) + return -1; + } + + while (m != NULL) + { + int ok = (*callback) (MODCB_ARGS (m), arg); + m = m->next; + if (ok != DWARF_CB_OK) + return (m == NULL + ? (ptrdiff_t) dwfl->lookup_elts + 1 + : m->segment + 1); + } } return 0; } +INTDEF (dwfl_getmodules) |