2008-06-04 Marc Khouzam <marc.khouzam@ericsson.com>
[binutils-gdb.git] / gdb / doc / gdb.texinfo
index 636a84b0c4fac9be39484f61e5389970703718d5..21ca9c7664430385f122e30c61f2948d6cbed2f7 100644 (file)
@@ -4127,9 +4127,11 @@ Show whether @value{GDBN} will stop in or step over functions without
 source line debug information.
 
 @kindex finish
+@kindex fin @r{(@code{finish})}
 @item finish
 Continue running until just after function in the selected stack frame
-returns.  Print the returned value (if any).
+returns.  Print the returned value (if any).  This command can be
+abbreviated as @code{fin}.
 
 Contrast this with the @code{return} command (@pxref{Returning,
 ,Returning from a Function}).
@@ -5446,8 +5448,11 @@ Variables}).
 @cindex machine instructions
 @cindex listing machine instructions
 @item disassemble
+@itemx disassemble /m
 This specialized command dumps a range of memory as machine
-instructions.  The default memory range is the function surrounding the
+instructions.  It can also print mixed source+disassembly by specifying
+the @code{/m} modifier.
+The default memory range is the function surrounding the
 program counter of the selected frame.  A single argument to this
 command is a program counter value; @value{GDBN} dumps the function
 surrounding this value.  Two arguments specify a range of addresses
@@ -5471,6 +5476,31 @@ Dump of assembler code from 0x32c4 to 0x32e4:
 End of assembler dump.
 @end smallexample
 
+Here is an example showing mixed source+assembly for Intel x86:
+
+@smallexample
+(@value{GDBP}) disas /m main
+Dump of assembler code for function main:
+5       @{
+0x08048330 <main+0>:    push   %ebp
+0x08048331 <main+1>:    mov    %esp,%ebp
+0x08048333 <main+3>:    sub    $0x8,%esp
+0x08048336 <main+6>:    and    $0xfffffff0,%esp
+0x08048339 <main+9>:    sub    $0x10,%esp
+
+6         printf ("Hello.\n");
+0x0804833c <main+12>:   movl   $0x8048440,(%esp)
+0x08048343 <main+19>:   call   0x8048284 <puts@@plt>
+
+7         return 0;
+8       @}
+0x08048348 <main+24>:   mov    $0x0,%eax
+0x0804834d <main+29>:   leave
+0x0804834e <main+30>:   ret
+
+End of assembler dump.
+@end smallexample
+
 Some architectures have more than one commonly-used set of instruction
 mnemonics or other syntax.
 
@@ -5562,6 +5592,7 @@ Table}.
 * Character Sets::              Debugging programs that use a different
                                 character set than GDB does
 * Caching Remote Data::         Data caching for remote targets
+* Searching Memory::            Searching memory for a sequence of bytes
 @end menu
 
 @node Expressions
@@ -7625,6 +7656,104 @@ state (dirty, bad, ok, etc.).  This command is useful for debugging
 the data cache operation.
 @end table
 
+@node Searching Memory
+@section Search Memory
+@cindex searching memory
+
+Memory can be searched for a particular sequence of bytes with the
+@code{find} command.
+
+@table @code
+@kindex find
+@item find @r{[}/@var{sn}@r{]} @var{start_addr}, +@var{len}, @var{val1} @r{[}, @var{val2}, @dots{}@r{]}
+@itemx find @r{[}/@var{sn}@r{]} @var{start_addr}, @var{end_addr}, @var{val1} @r{[}, @var{val2}, @dots{}@r{]}
+Search memory for the sequence of bytes specified by @var{val1}, @var{val2},
+etc.  The search begins at address @var{start_addr} and continues for either
+@var{len} bytes or through to @var{end_addr} inclusive.
+@end table
+
+@var{s} and @var{n} are optional parameters.
+They may be specified in either order, apart or together.
+
+@table @r
+@item @var{s}, search query size
+The size of each search query value.
+
+@table @code
+@item b
+bytes
+@item h
+halfwords (two bytes)
+@item w
+words (four bytes)
+@item g
+giant words (eight bytes)
+@end table
+
+All values are interpreted in the current language.
+This means, for example, that if the current source language is C/C@t{++}
+then searching for the string ``hello'' includes the trailing '\0'.
+
+If the value size is not specified, it is taken from the
+value's type in the current language.
+This is useful when one wants to specify the search
+pattern as a mixture of types.
+Note that this means, for example, that in the case of C-like languages
+a search for an untyped 0x42 will search for @samp{(int) 0x42}
+which is typically four bytes.
+
+@item @var{n}, maximum number of finds
+The maximum number of matches to print.  The default is to print all finds.
+@end table
+
+You can use strings as search values.  Quote them with double-quotes
+ (@code{"}).
+The string value is copied into the search pattern byte by byte,
+regardless of the endianness of the target and the size specification.
+
+The address of each match found is printed as well as a count of the
+number of matches found.
+
+The address of the last value found is stored in convenience variable
+@samp{$_}.
+A count of the number of matches is stored in @samp{$numfound}.
+
+For example, if stopped at the @code{printf} in this function:
+
+@smallexample
+void
+hello ()
+@{
+  static char hello[] = "hello-hello";
+  static struct @{ char c; short s; int i; @}
+    __attribute__ ((packed)) mixed
+    = @{ 'c', 0x1234, 0x87654321 @};
+  printf ("%s\n", hello);
+@}
+@end smallexample
+
+@noindent
+you get during debugging:
+
+@smallexample
+(gdb) find &hello[0], +sizeof(hello), "hello"
+0x804956d <hello.1620+6>
+1 pattern found
+(gdb) find &hello[0], +sizeof(hello), 'h', 'e', 'l', 'l', 'o'
+0x8049567 <hello.1620>
+0x804956d <hello.1620+6>
+2 patterns found
+(gdb) find /b1 &hello[0], +sizeof(hello), 'h', 0x65, 'l'
+0x8049567 <hello.1620>
+1 pattern found
+(gdb) find &mixed, +sizeof(mixed), (char) 'c', (short) 0x1234, (int) 0x87654321
+0x8049560 <mixed.1625>
+1 pattern found
+(gdb) print $numfound
+$1 = 1
+(gdb) print $_
+$2 = (void *) 0x8049560
+@end smallexample
 
 @node Macros
 @chapter C Preprocessor Macros
@@ -13468,6 +13597,10 @@ are:
 @tab @code{qGetTLSAddr}
 @tab Displaying @code{__thread} variables
 
+@item @code{search-memory}
+@tab @code{qSearch:memory}
+@tab @code{find}
+
 @item @code{supported-packets}
 @tab @code{qSupported}
 @tab Remote communications parameters
@@ -18150,7 +18283,7 @@ additional changes that have occurred.  Those changes can either be a
 consequence of @sc{gdb/mi} commands (e.g., a breakpoint modified) or a result of
 target activity (e.g., target stopped).
 
-The following is the list of possible async records
+The following is the list of possible async records:
 
 @table @code
 
@@ -21760,7 +21893,7 @@ The corresponding @value{GDBN} command is @samp{remote put}.
 @end smallexample
 
 
-@subheading The @code{-target-file-put} Command
+@subheading The @code{-target-file-get} Command
 @findex -target-file-get
 
 @subsubheading Synopsis
@@ -23437,6 +23570,10 @@ switch (@pxref{Mode Options}).
 Control whether to display the execution time for each command.  If
 set to a nonzero value, @value{GDBN} will display how much time it
 took to execute each command, following the command's own output.
+The time is not printed for the commands that run the target, since
+there's no mechanism currently to compute how much time was spend
+by @value{GDBN} and how much time was spend by the program been debugged.
+it's not possibly currently 
 This can also be requested by invoking @value{GDBN} with the
 @option{--statistics} command-line switch (@pxref{Mode Options}).
 
@@ -23950,8 +24087,8 @@ up to the first @samp{;} or @samp{?} (or the end of the packet).
 @item vAttach;@var{pid}
 @cindex @samp{vAttach} packet
 Attach to a new process with the specified process ID.  @var{pid} is a
-hexadecimal integer identifying the process.  If the stub is currently
-controlling a process, it is killed.  The attached process is stopped.
+hexadecimal integer identifying the process.  The attached process is
+stopped.
 
 This packet is only available in extended mode (@pxref{extended mode}).
 
@@ -24065,7 +24202,7 @@ Run the program @var{filename}, passing it each @var{argument} on its
 command line.  The file and arguments are hex-encoded strings.  If
 @var{filename} is an empty string, the stub may use a default program
 (e.g.@: the last program run).  The program is created in the stopped
-state.  If the stub is currently controlling a process, it is killed.
+state.
 
 This packet is only available in extended mode (@pxref{extended mode}).
 
@@ -24574,6 +24711,26 @@ command by a @samp{,}, not a @samp{:}, contrary to the naming
 conventions above.  Please don't use this packet as a model for new
 packets.)
 
+@item qSearch:memory:@var{address};@var{length};@var{search-pattern}
+@cindex searching memory, in remote debugging
+@cindex @samp{qSearch:memory} packet
+@anchor{qSearch memory}
+Search @var{length} bytes at @var{address} for @var{search-pattern}.
+@var{address} and @var{length} are encoded in hex.
+@var{search-pattern} is a sequence of bytes, hex encoded.
+
+Reply:
+@table @samp
+@item 0
+The pattern was not found.
+@item 1,address
+The pattern was found at @var{address}.
+@item E @var{NN}
+A badly formed request or an error was encountered while searching memory.
+@item
+An empty reply indicates that @samp{qSearch:memory} is not recognized.
+@end table
+
 @item qSupported @r{[}:@var{gdbfeature} @r{[};@var{gdbfeature}@r{]}@dots{} @r{]}
 @cindex supported packets, remote query
 @cindex features of the remote protocol