[HELP] GDB general way to quickly find a addr in a list of addrs

Tom Tromey tromey@redhat.com
Tue Jun 8 21:06:00 GMT 2010


>>>>> "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



More information about the Gdb mailing list