source: trunk/third/gcc/libjava/addr2name.awk @ 16960

Revision 16960, 1022 bytes checked in by ghudson, 23 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r16959, which included commits to RCS files with non-trunk default branches.
  • Property svn:executable set to *
Line 
1#!/bin/awk -f
2
3# Copyright (C) 2000  Free Software Foundation
4
5#    This file is part of libgcj.
6
7# This software is copyrighted work licensed under the terms of the
8# Libgcj License.  Please consult the file "LIBGCJ_LICENSE" for
9# details.
10
11# This script emulates a little of the functionality of addr2line for
12# those systems that don't have it.  The only command line argument is
13# an executable name.  The script reads hexadecimal addresses from
14# stdin and prints the corresponding symbol names to stdout.  The
15# addresses must begin with "0x" and be fully zero filled or this
16# won't work.
17
18BEGIN {
19  object = ARGV[1];
20  ARGV[1] = "";
21
22  while ("nm " object "| sort" | getline) {
23    if ($2 == "t" || $2 == "T") {
24      address[i] = "0x" $1; name[i] = $3;
25      i++;
26    }
27  }
28  syms = i;
29}
30
31{
32  lo = 0;
33  hi = syms - 1;
34
35  while ((hi-1) > lo)
36    {
37      try = int ((hi + lo) / 2);
38      if ($0 < address[try])
39        hi = try;
40      else if ($0 >= address[try])
41        lo = try;
42    }
43  print name[lo] "\n"; fflush();
44}
45
46   
Note: See TracBrowser for help on using the repository browser.