blob: 4fc14880faace7e6aa92b0c95861e824352fd87e [file] [log] [blame]
Ulrich Drepperb08d5a82005-07-26 05:00:05 +00001/* Iterate through modules.
2 Copyright (C) 2005 Red Hat, Inc.
3
4 This program is Open Source software; you can redistribute it and/or
5 modify it under the terms of the Open Software License version 1.0 as
6 published by the Open Source Initiative.
7
8 You should have received a copy of the Open Software License along
9 with this program; if not, you may obtain a copy of the Open Software
10 License version 1.0 from http://www.opensource.org/licenses/osl.php or
11 by writing the Open Source Initiative c/o Lawrence Rosen, Esq.,
12 3001 King Ranch Road, Ukiah, CA 95482. */
13
14#include "libdwflP.h"
15
16ptrdiff_t
17dwfl_getmodules (Dwfl *dwfl,
18 int (*callback) (Dwfl_Module *, void **,
19 const char *, Dwarf_Addr, void *),
20 void *arg,
21 ptrdiff_t offset)
22{
23 if (dwfl == NULL)
24 return -1;
25
26 if ((size_t) offset > dwfl->nmodules)
27 return -1;
28
29 while ((size_t) offset < dwfl->nmodules)
30 {
31 Dwfl_Module *mod = dwfl->modules[offset++];
32 if ((*callback) (MODCB_ARGS (mod), arg) != DWARF_CB_OK)
33 return offset;
34 }
35
36 return 0;
37}