Debugging with GDB Manual HP WDB v6.3 (5900-2180, August 2012)
Example 1 Sample Output for the find command
$ cat example.c
#include <stdio.h>
#include <stdlib.h>
int main()
{
char *str;
str = (char *) malloc (15);
strcpy(str,"hihi-hikh");
return 0;
}
(gdb) find &str[0], &str[15], "hi"
0x400123e0
0x400123e2
0x400123e5
3 patterns found.
(gdb) find/2 &str[0], &str[15], "hi"
0x400123e0
0x400123e2
2 patterns found.
(gdb) find/2b &str[0], &str[15], 0x68
0x400123e0
0x400123e2
2 patterns found.
(gdb) find/2b &str[0], +10, 0x68
0x400123e0
0x400123e2
2 patterns found.
(gdb) find/2b &str[0], +10, 0x68, 0x69
0x400123e0
0x400123e2
2 patterns found.
(gdb) find &str[0], &str[15], "hi", "hi"
0x400123e0
1 pattern found.
The following examples provide sample usages of the different parameters in the find command:
• Using the start address (start-address), end address (end-address), and patterns
(expr1, expr2)
(gdb) find &a[0], &a[10], "el",'l'
2 patterns found.
where:
&a[0] Specifies the start address of the memory address range.
&a[10] Specifies the end address of the memory address range.
“el”, 'l' Specifies the pattern.
• Using the start address (start-address), length (+length) parameter, and a pattern
(expr1)
find &str[0], +11, "hihi"
&str[0] Specifies the starting address.
+11 Specifies the length of the memory address range, starting from &str[0].
152 HP-UX Configuration-Specific Information