This is the mail archive of the
gdb@sourceware.org
mailing list for the GDB project.
Re: [HELP] GDB general way to quickly find a addr in a list of addrs
- From: Tom Tromey <tromey at redhat dot com>
- To: Jan Kratochvil <jan dot kratochvil at redhat dot com>
- Cc: Hui Zhu <teawater at gmail dot com>, gdb at sourceware dot org
- Date: Tue, 08 Jun 2010 15:06:18 -0600
- Subject: Re: [HELP] GDB general way to quickly find a addr in a list of addrs
- References: <AANLkTim19pXojeqD1r6SWR5_aGBJiFM7-OR54XJizBvc@mail.gmail.com> <20100528075105.GA3138@host0.dyn.jankratochvil.net>
- Reply-to: tromey at redhat dot com
>>>>> "Jan" == Jan Kratochvil <jan.kratochvil@redhat.com> writes:
>> On Fri, 28 May 2010 04:19:59 +0200, Hui Zhu wrote:
>> Does GDB have a general way to quickly find a number in a list of numbers?
Jan> addrmap.[ch] for API or the `find' command for CLI.
VEC also has a binary search built-in, under a funny name:
/* Find the first index in the vector not less than the object.
unsigned VEC_T_lower_bound (VEC(T) *v, const T val,
int (*lessthan) (const T, const T)); // Integer
unsigned VEC_T_lower_bound (VEC(T) *v, const T val,
int (*lessthan) (const T, const T)); // Pointer
unsigned VEC_T_lower_bound (VEC(T) *v, const T *val,
int (*lessthan) (const T*, const T*)); // Object
Find the first position in which VAL could be inserted without
changing the ordering of V. LESSTHAN is a function that returns
true if the first argument is strictly less than the second. */
#define VEC_lower_bound(T,V,O,LT) \
...
Tom