diff options
author | gdb-2.5.1 <gdb@fsf.org> | 1988-05-02 01:00:00 +0100 |
---|---|---|
committer | Pedro Alves <palves@redhat.com> | 2012-06-03 15:36:30 +0100 |
commit | 632ea0ccc5c4c3f9fc06881bfedfc4b075873941 (patch) | |
tree | 96f152433c41c5f51fe57307b287eb85865a43e2 /gdb/blockframe.c | |
parent | 7b4ac7e1ed2c4616bce56d1760807798be87ac9e (diff) | |
download | ppe42-binutils-632ea0ccc5c4c3f9fc06881bfedfc4b075873941.tar.gz ppe42-binutils-632ea0ccc5c4c3f9fc06881bfedfc4b075873941.zip |
gdb-2.5.1
Diffstat (limited to 'gdb/blockframe.c')
-rw-r--r-- | gdb/blockframe.c | 34 |
1 files changed, 25 insertions, 9 deletions
diff --git a/gdb/blockframe.c b/gdb/blockframe.c index 5ed025c423..b3379009b3 100644 --- a/gdb/blockframe.c +++ b/gdb/blockframe.c @@ -1,6 +1,6 @@ /* Get info from stack frames; convert between frames, blocks, functions and pc values. - Copyright (C) 1986, 1987 Free Software Foundation, Inc. + Copyright (C) 1986, 1987, 1988 Free Software Foundation, Inc. GDB is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY. No author or distributor accepts responsibility to anyone @@ -288,17 +288,33 @@ find_pc_function (pc) int find_pc_misc_function (pc) - CORE_ADDR pc; + register CORE_ADDR pc; { - register int i; + register int lo = 0; + register int hi = misc_function_count-1; + register int new; + register int distance; /* Note that the last thing in the vector is always _etext. */ - for (i = 0; i < misc_function_count; i++) - { - if (pc < misc_function_vector[i].address) - return i - 1; - } - return -1; + + /* trivial reject range test */ + if (pc < misc_function_vector[0].address || + pc > misc_function_vector[hi].address) + return -1; + + do { + new = (lo + hi) >> 1; + distance = misc_function_vector[new].address - pc; + if (distance == 0) + return new; /* an exact match */ + else if (distance > 0) + hi = new; + else + lo = new; + } while (hi-lo != 1); + + /* if here, we had no exact match, so return the lower choice */ + return lo; } /* Return the innermost stack frame executing inside of the specified block, |