This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [RFA] new command to search memory
- From: Daniel Jacobowitz <drow at false dot org>
- To: Doug Evans <dje at google dot com>
- Cc: gdb-patches at sourceware dot org
- Date: Fri, 2 May 2008 11:33:03 -0400
- Subject: Re: [RFA] new command to search memory
- References: <20080214021915.F3FE51C72F0@localhost> <20080226022335.GB4456@caradoc.them.org> <e394668d0804091337r68a71824qdbf54237119fe5d0@mail.gmail.com>
On Wed, Apr 09, 2008 at 01:37:26PM -0700, Doug Evans wrote:
> If I want to search for 'h', 'e', 'l', 'l', 'o' I won't be able to
> use "hello" because that will now include the trailing nul. Often one
> will want the trailing nul, but it does make searching for substrings
> kinda hard. [For completeness' sake, one could change the definition
> of what "hello" means in this context, and if one wants the trailing
> nul, one has to explicitly specify it, e.g. "hello\0". It's
> C-specific though, and the find command is presumably not supposed to
> know the user is thinking in C - that's the whole point. I don't have
> an opinion either way.]
>
> Any suggestions or preferences for whether and how to make searching
> for substrings not excessively clumsy?
I think that "hello" should be five characters, for this purpose.
There's some support for that in C; it's a valid initializer for
either char[5] or char[6] (C99 6.7.8#15).
Would it help if "hello" reached this point as a TYPE_CODE_STRING
but {'a', 'b', '\0'} was TYPE_CODE_ARRAY, so that we could reliably
detect strings? I don't think it's a big deal since people will
normally leave off the braces for the array here anyway.
--
Daniel Jacobowitz
CodeSourcery