From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1835 invoked by alias); 25 Jun 2010 06:50:18 -0000 Received: (qmail 1791 invoked by uid 22791); 25 Jun 2010 06:50:14 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: sourceware.org Received: from mail-pz0-f41.google.com (HELO mail-pz0-f41.google.com) (209.85.210.41) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 25 Jun 2010 06:50:08 +0000 Received: by pzk30 with SMTP id 30so879294pzk.0 for ; Thu, 24 Jun 2010 23:50:07 -0700 (PDT) Received: by 10.142.247.33 with SMTP id u33mr284029wfh.44.1277448607239; Thu, 24 Jun 2010 23:50:07 -0700 (PDT) MIME-Version: 1.0 Received: by 10.143.32.8 with HTTP; Thu, 24 Jun 2010 23:49:47 -0700 (PDT) In-Reply-To: References: <20100528075105.GA3138@host0.dyn.jankratochvil.net> From: Hui Zhu Date: Fri, 25 Jun 2010 06:50:00 -0000 Message-ID: Subject: Re: [HELP] GDB general way to quickly find a addr in a list of addrs To: tromey@redhat.com Cc: Jan Kratochvil , gdb@sourceware.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2010-06/txt/msg00122.txt.bz2 On Wed, Jun 9, 2010 at 05:06, Tom Tromey wrote: >>>>>> "Jan" =3D=3D Jan Kratochvil 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 numbe= rs? > > 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. > =A0 unsigned VEC_T_lower_bound (VEC(T) *v, const T val, > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 int (*lesstha= n) (const T, const T)); // Integer > =A0 unsigned VEC_T_lower_bound (VEC(T) *v, const T val, > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 int (*lesstha= n) (const T, const T)); // Pointer > =A0 unsigned VEC_T_lower_bound (VEC(T) *v, const T *val, > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 int (*lesstha= n) (const T*, const T*)); // Object > > =A0 Find the first position in which VAL could be inserted without > =A0 changing the ordering of V. =A0LESSTHAN is a function that returns > =A0 true if the first argument is strictly less than the second. =A0*/ > > #define VEC_lower_bound(T,V,O,LT) =A0 =A0\ > =A0 ... > Thanks Tom. Hui