Roland McGrath | d7f8d0c | 2005-11-17 02:32:03 +0000 | [diff] [blame] | 1 | /* Copyright (C) 2005 Red Hat, Inc. |
Ulrich Drepper | 361df7d | 2006-04-04 21:38:57 +0000 | [diff] [blame] | 2 | This file is part of Red Hat elfutils. |
Roland McGrath | d7f8d0c | 2005-11-17 02:32:03 +0000 | [diff] [blame] | 3 | |
Ulrich Drepper | 361df7d | 2006-04-04 21:38:57 +0000 | [diff] [blame] | 4 | Red Hat elfutils is free software; you can redistribute it and/or modify |
| 5 | it under the terms of the GNU General Public License as published by the |
| 6 | Free Software Foundation; version 2 of the License. |
Roland McGrath | d7f8d0c | 2005-11-17 02:32:03 +0000 | [diff] [blame] | 7 | |
Ulrich Drepper | 361df7d | 2006-04-04 21:38:57 +0000 | [diff] [blame] | 8 | Red Hat elfutils is distributed in the hope that it will be useful, but |
| 9 | WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 11 | General Public License for more details. |
| 12 | |
| 13 | You should have received a copy of the GNU General Public License along |
| 14 | with Red Hat elfutils; if not, write to the Free Software Foundation, |
Ulrich Drepper | 1e9ef50 | 2006-04-04 22:29:06 +0000 | [diff] [blame] | 15 | Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA. |
Ulrich Drepper | 361df7d | 2006-04-04 21:38:57 +0000 | [diff] [blame] | 16 | |
| 17 | Red Hat elfutils is an included package of the Open Invention Network. |
| 18 | An included package of the Open Invention Network is a package for which |
| 19 | Open Invention Network licensees cross-license their patents. No patent |
| 20 | license is granted, either expressly or impliedly, by designation as an |
| 21 | included package. Should you wish to participate in the Open Invention |
| 22 | Network licensing program, please visit www.openinventionnetwork.com |
| 23 | <http://www.openinventionnetwork.com>. */ |
Roland McGrath | d7f8d0c | 2005-11-17 02:32:03 +0000 | [diff] [blame] | 24 | |
| 25 | #ifdef HAVE_CONFIG_H |
| 26 | # include <config.h> |
| 27 | #endif |
| 28 | |
Ulrich Drepper | b08d5a8 | 2005-07-26 05:00:05 +0000 | [diff] [blame] | 29 | #include <fcntl.h> |
Roland McGrath | d7f8d0c | 2005-11-17 02:32:03 +0000 | [diff] [blame] | 30 | #include ELFUTILS_HEADER(dw) |
Ulrich Drepper | b08d5a8 | 2005-07-26 05:00:05 +0000 | [diff] [blame] | 31 | #include <stdio.h> |
| 32 | #include <unistd.h> |
| 33 | |
| 34 | |
| 35 | static int |
Roland McGrath | 6724c90 | 2005-10-28 07:07:19 +0000 | [diff] [blame] | 36 | cb (Dwarf_Die *func, void *arg __attribute__ ((unused))) |
Ulrich Drepper | b08d5a8 | 2005-07-26 05:00:05 +0000 | [diff] [blame] | 37 | { |
Roland McGrath | 6724c90 | 2005-10-28 07:07:19 +0000 | [diff] [blame] | 38 | const char *file = dwarf_decl_file (func); |
Ulrich Drepper | b08d5a8 | 2005-07-26 05:00:05 +0000 | [diff] [blame] | 39 | int line = -1; |
Roland McGrath | 6724c90 | 2005-10-28 07:07:19 +0000 | [diff] [blame] | 40 | dwarf_decl_line (func, &line); |
| 41 | const char *fct = dwarf_diename (func); |
Ulrich Drepper | b08d5a8 | 2005-07-26 05:00:05 +0000 | [diff] [blame] | 42 | |
| 43 | printf ("%s:%d:%s\n", file, line, fct); |
| 44 | |
| 45 | return DWARF_CB_OK; |
| 46 | } |
| 47 | |
| 48 | |
| 49 | int |
| 50 | main (int argc, char *argv[]) |
| 51 | { |
| 52 | for (int i = 1; i < argc; ++i) |
| 53 | { |
| 54 | int fd = open (argv[i], O_RDONLY); |
| 55 | |
| 56 | Dwarf *dbg = dwarf_begin (fd, DWARF_C_READ); |
| 57 | if (dbg != NULL) |
| 58 | { |
| 59 | Dwarf_Off off = 0; |
| 60 | size_t cuhl; |
| 61 | Dwarf_Off noff; |
| 62 | |
| 63 | while (dwarf_nextcu (dbg, off, &noff, &cuhl, NULL, NULL, NULL) == 0) |
| 64 | { |
| 65 | Dwarf_Die die_mem; |
| 66 | Dwarf_Die *die = dwarf_offdie (dbg, off + cuhl, &die_mem); |
| 67 | |
| 68 | (void) dwarf_getfuncs (die, cb, NULL, 0); |
| 69 | |
| 70 | off = noff; |
| 71 | } |
| 72 | |
| 73 | dwarf_end (dbg); |
| 74 | } |
| 75 | |
| 76 | close (fd); |
| 77 | } |
| 78 | } |