|
From: <rk...@us...> - 2007-04-19 18:49:10
|
Revision: 210
http://ipcop.svn.sourceforge.net/ipcop/?rev=210&view=rev
Author: rkerr
Date: 2007-04-19 11:48:27 -0700 (Thu, 19 Apr 2007)
Log Message:
-----------
The gdb patches and lfs/gdb are really useful to have around when you've got
a bug to track down
Added Paths:
-----------
ipcop/trunk/src/patches/gdb-6.3-scanmem.patch
ipcop/trunk/src/patches/gdb-bfd-malloc-wrap.patch
Removed Paths:
-------------
ipcop/trunk/src/patches/REMOVE/gdb-6.3-scanmem.patch
ipcop/trunk/src/patches/REMOVE/gdb-bfd-malloc-wrap.patch
Deleted: ipcop/trunk/src/patches/REMOVE/gdb-6.3-scanmem.patch
===================================================================
--- ipcop/trunk/src/patches/REMOVE/gdb-6.3-scanmem.patch 2007-04-19 18:23:20 UTC (rev 209)
+++ ipcop/trunk/src/patches/REMOVE/gdb-6.3-scanmem.patch 2007-04-19 18:48:27 UTC (rev 210)
@@ -1,238 +0,0 @@
-diff -Nrup gdb-6.3.orig/gdb/printcmd.c gdb-6.3/gdb/printcmd.c
---- gdb-6.3.orig/gdb/printcmd.c 2004-09-11 06:24:50.000000000 -0400
-+++ gdb-6.3/gdb/printcmd.c 2004-11-27 19:48:18.000000000 -0500
-@@ -940,6 +940,195 @@ print_command (char *exp, int from_tty)
- print_command_1 (exp, 0, 1);
- }
-
-+static void
-+scanmem_command(char *exp, int from_tty)
-+{
-+ struct expression *expr;
-+ struct value *val;
-+ struct format_data fmt;
-+ CORE_ADDR addr;
-+ unsigned char *data;
-+ unsigned char *size;
-+ unsigned char *pattern;
-+ unsigned char typ;
-+ unsigned char typc;
-+ unsigned char my_buf[4];
-+ unsigned int nfetch;
-+ unsigned int len = 10;
-+ unsigned int memsize;
-+ unsigned int i;
-+ int typi;
-+ int errcode;
-+
-+ if (exp && *exp) {
-+ struct type *type;
-+ char *str_num = NULL;
-+ char *string_to_seek = NULL;
-+ char *tmp = strdup(exp);
-+ char *c;
-+
-+ c = tmp;
-+ if (*c == ' ')
-+ while (*c && *c == ' ')
-+ c++;
-+
-+ while (*c && *c != ' ')
-+ c++;
-+
-+ *c = '\0';
-+ c++;
-+
-+ while (*c && *c == ' ')
-+ c++;
-+
-+ size = c;
-+
-+ while (*c && *c != ' ')
-+ c++;
-+
-+ *c = '\0';
-+ c++;
-+
-+ while (*c && *c == ' ')
-+ c++;
-+
-+ typ = *c;
-+ c++;
-+
-+ *c = '\0';
-+ c++;
-+
-+ while (*c && *c == ' ')
-+ c++;
-+ pattern = c;
-+
-+ printf_filtered(">>addr %s: size %s: type:%c pattern:%s<< \n",
-+ tmp, size, typ, pattern);
-+
-+ expr = parse_expression(tmp);
-+ val = evaluate_expression(expr);
-+
-+ if (TYPE_CODE(VALUE_TYPE(val)) == TYPE_CODE_REF)
-+ val = value_ind(val);
-+
-+ if (TYPE_CODE(VALUE_TYPE(val)) == TYPE_CODE_FUNC
-+ && VALUE_LVAL(val) == lval_memory)
-+ addr = VALUE_ADDRESS(val);
-+ else
-+ addr = value_as_address(val);
-+
-+ len = atoi(size);
-+ data = xmalloc(len);
-+ nfetch = partial_memory_read(addr, data, len, &errcode);
-+
-+ if (nfetch != len)
-+ printf_filtered("we can read only %i bytes\n", nfetch);
-+
-+ switch (typ) {
-+ case 's':
-+ memsize = strlen(pattern);
-+ if (nfetch < memsize) {
-+ printf_filtered
-+ ("we read only %i bytes and we seek for a pattern of %i bytes\n",
-+ nfetch, memsize);
-+ free(data);
-+ free(tmp);
-+ return;
-+ }
-+ for (i = 0; i <= (nfetch - memsize); i++, addr++) {
-+ if (memcmp(data + i, pattern, memsize) == 0) {
-+ printf_filtered("pattern match at ");
-+ print_address_numeric((addr), 1, gdb_stdout);
-+ printf_filtered("\n");
-+ }
-+ }
-+ break;
-+ case 'i':
-+ memsize = sizeof(int);
-+ typi = atoi(pattern);
-+
-+ if (nfetch < memsize) {
-+ printf_filtered
-+ ("we read only %i bytes and we seek for a pattern of %i bytes\n",
-+ nfetch, memsize);
-+ free(data);
-+ free(tmp);
-+ return;
-+ }
-+ for (i = 0; i <= (nfetch - memsize); i++, addr++) {
-+ int *pint;
-+ pint = (unsigned char *) (data + i);
-+ if (*pint == typi) {
-+ printf_filtered("pattern match at ");
-+ print_address_numeric((addr), 1, gdb_stdout);
-+ printf_filtered("\n");
-+ }
-+ }
-+ break;
-+ case 'a':
-+ memsize = sizeof(unsigned long);
-+ if (sscanf(pattern, "0x%x", &i) == 0) {
-+ printf_filtered("cant convert to hexa %s\n", pattern);
-+ break;
-+ }
-+ my_buf[0] = (unsigned char) ((i & 0x000000FF));
-+ my_buf[1] = (unsigned char) ((i & 0x0000FF00) >> 8);
-+ my_buf[2] = (unsigned char) ((i & 0x00FF0000) >> 16);
-+ my_buf[3] = (unsigned char) ((i & 0xFF000000) >> 24);
-+ if (nfetch < memsize) {
-+ printf_filtered
-+ ("we read only %i bytes and we seek for a pattern of %i bytes\n",
-+ nfetch, memsize);
-+ free(data);
-+ free(tmp);
-+ return;
-+ }
-+ for (i = 0; i <= (nfetch - memsize); i++, addr++) {
-+ if (memcmp((data + i), my_buf, memsize) == 0) {
-+ printf_filtered("pattern match at ");
-+ print_address_numeric((addr), 1, gdb_stdout);
-+ printf_filtered("\n");
-+ }
-+ }
-+ break;
-+ case 'b':
-+ case 'c':
-+ memsize = sizeof(char);
-+ if (typ == 'c')
-+ typc = *pattern;
-+ else {
-+ if (strncmp("0x", pattern, 2) == 0) {
-+ sscanf(pattern, "0x%02x", &typc);
-+ } else
-+ typc = (unsigned char)atoi(pattern);
-+ }
-+ printf_filtered(">>>%0x2\n", (int) typc);
-+ if (nfetch < memsize) {
-+ printf_filtered
-+ ("we read only %i bytes and we seek for a pattern of %i bytes\n",
-+ nfetch, memsize);
-+ free(data);
-+ free(tmp);
-+ return;
-+ }
-+ for (i = 0; i <= (nfetch - memsize); i++, addr++) {
-+ if (*(data + i) == typc) {
-+ printf_filtered("pattern match at ");
-+ print_address_numeric((addr), 1, gdb_stdout);
-+ printf_filtered("\n");
-+ }
-+ }
-+ break;
-+ default:
-+ printf_filtered("'%c' is not a valid type\n", typ);
-+ break;
-+ }
-+ free(data);
-+ free(tmp);
-+ return;
-+ }
-+}
-+
- /* Same as print, except in epoch, it gets its own window */
- static void
- inspect_command (char *exp, int from_tty)
-@@ -2138,6 +2327,17 @@ EXP may be preceded with /FMT, where FMT
- but no count or size letter (see \"x\" command).", NULL));
- set_cmd_completer (c, location_completer);
- add_com_alias ("p", "print", class_vars, 1);
-+ c =
-+ add_com ("scanmem", class_vars, scanmem_command,
-+ "scanmem <addr> <num> <type> <string>\n"
-+ "example: scanmem $esp 100 a 0x8048434\n"
-+ " scan for this addr into the stack\n\n"
-+ " scanmem 0x08048434 100 s fsck\n"
-+ " seek for a string\n"
-+ " scanmem 0x8048434 100 b 0x75\n"
-+ " scan for the char 0x75\n"
-+ " a = address c = char b = byte i = int s = string\n"
-+ "\n"); /* ant...@zo... */
-
- c = add_com ("inspect", class_vars, inspect_command,
- "Same as \"print\" command, except that if you are running in the epoch\n\
-diff -Nrup gdb-6.3.orig/gdb/valprint.c gdb-6.3/gdb/valprint.c
---- gdb-6.3.orig/gdb/valprint.c 2004-09-12 12:13:04.000000000 -0400
-+++ gdb-6.3/gdb/valprint.c 2004-11-27 19:23:54.000000000 -0500
-@@ -39,7 +39,7 @@
-
- /* Prototypes for local functions */
-
--static int partial_memory_read (CORE_ADDR memaddr, char *myaddr,
-+int partial_memory_read (CORE_ADDR memaddr, char *myaddr,
- int len, int *errnoptr);
-
- static void show_print (char *, int);
-@@ -837,7 +837,7 @@ val_print_array_elements (struct type *t
- /* FIXME: cagney/1999-10-14: Only used by val_print_string. Can this
- function be eliminated. */
-
--static int
-+int
- partial_memory_read (CORE_ADDR memaddr, char *myaddr, int len, int *errnoptr)
- {
- int nread; /* Number of bytes actually read. */
Deleted: ipcop/trunk/src/patches/REMOVE/gdb-bfd-malloc-wrap.patch
===================================================================
--- ipcop/trunk/src/patches/REMOVE/gdb-bfd-malloc-wrap.patch 2007-04-19 18:23:20 UTC (rev 209)
+++ ipcop/trunk/src/patches/REMOVE/gdb-bfd-malloc-wrap.patch 2007-04-19 18:48:27 UTC (rev 210)
@@ -1,23 +0,0 @@
---- bfd/elfcode.h.orig 2005-05-04 19:34:52.000000000 -0400
-+++ bfd/elfcode.h 2005-05-04 19:37:35.000000000 -0400
-@@ -640,6 +640,9 @@
- Elf_Internal_Shdr *shdrp;
- unsigned int num_sec;
-
-+ if (sizeof(*i_shdrp)*i_ehdrp->e_shnum/sizeof(*i_shdrp)!=i_ehdrp->e_shnum)
-+ goto got_no_match;
-+
- amt = sizeof (*i_shdrp) * i_ehdrp->e_shnum;
- i_shdrp = bfd_alloc (abfd, amt);
- if (!i_shdrp)
-@@ -647,6 +650,10 @@
- num_sec = i_ehdrp->e_shnum;
- if (num_sec > SHN_LORESERVE)
- num_sec += SHN_HIRESERVE + 1 - SHN_LORESERVE;
-+
-+ if (sizeof (i_shdrp) * num_sec/sizeof (i_shdrp) != num_sec)
-+ goto got_no_match;
-+
- elf_numsections (abfd) = num_sec;
- amt = sizeof (i_shdrp) * num_sec;
- elf_elfsections (abfd) = bfd_alloc (abfd, amt);
Copied: ipcop/trunk/src/patches/gdb-6.3-scanmem.patch (from rev 204, ipcop/trunk/src/patches/REMOVE/gdb-6.3-scanmem.patch)
===================================================================
--- ipcop/trunk/src/patches/gdb-6.3-scanmem.patch (rev 0)
+++ ipcop/trunk/src/patches/gdb-6.3-scanmem.patch 2007-04-19 18:48:27 UTC (rev 210)
@@ -0,0 +1,238 @@
+diff -Nrup gdb-6.3.orig/gdb/printcmd.c gdb-6.3/gdb/printcmd.c
+--- gdb-6.3.orig/gdb/printcmd.c 2004-09-11 06:24:50.000000000 -0400
++++ gdb-6.3/gdb/printcmd.c 2004-11-27 19:48:18.000000000 -0500
+@@ -940,6 +940,195 @@ print_command (char *exp, int from_tty)
+ print_command_1 (exp, 0, 1);
+ }
+
++static void
++scanmem_command(char *exp, int from_tty)
++{
++ struct expression *expr;
++ struct value *val;
++ struct format_data fmt;
++ CORE_ADDR addr;
++ unsigned char *data;
++ unsigned char *size;
++ unsigned char *pattern;
++ unsigned char typ;
++ unsigned char typc;
++ unsigned char my_buf[4];
++ unsigned int nfetch;
++ unsigned int len = 10;
++ unsigned int memsize;
++ unsigned int i;
++ int typi;
++ int errcode;
++
++ if (exp && *exp) {
++ struct type *type;
++ char *str_num = NULL;
++ char *string_to_seek = NULL;
++ char *tmp = strdup(exp);
++ char *c;
++
++ c = tmp;
++ if (*c == ' ')
++ while (*c && *c == ' ')
++ c++;
++
++ while (*c && *c != ' ')
++ c++;
++
++ *c = '\0';
++ c++;
++
++ while (*c && *c == ' ')
++ c++;
++
++ size = c;
++
++ while (*c && *c != ' ')
++ c++;
++
++ *c = '\0';
++ c++;
++
++ while (*c && *c == ' ')
++ c++;
++
++ typ = *c;
++ c++;
++
++ *c = '\0';
++ c++;
++
++ while (*c && *c == ' ')
++ c++;
++ pattern = c;
++
++ printf_filtered(">>addr %s: size %s: type:%c pattern:%s<< \n",
++ tmp, size, typ, pattern);
++
++ expr = parse_expression(tmp);
++ val = evaluate_expression(expr);
++
++ if (TYPE_CODE(VALUE_TYPE(val)) == TYPE_CODE_REF)
++ val = value_ind(val);
++
++ if (TYPE_CODE(VALUE_TYPE(val)) == TYPE_CODE_FUNC
++ && VALUE_LVAL(val) == lval_memory)
++ addr = VALUE_ADDRESS(val);
++ else
++ addr = value_as_address(val);
++
++ len = atoi(size);
++ data = xmalloc(len);
++ nfetch = partial_memory_read(addr, data, len, &errcode);
++
++ if (nfetch != len)
++ printf_filtered("we can read only %i bytes\n", nfetch);
++
++ switch (typ) {
++ case 's':
++ memsize = strlen(pattern);
++ if (nfetch < memsize) {
++ printf_filtered
++ ("we read only %i bytes and we seek for a pattern of %i bytes\n",
++ nfetch, memsize);
++ free(data);
++ free(tmp);
++ return;
++ }
++ for (i = 0; i <= (nfetch - memsize); i++, addr++) {
++ if (memcmp(data + i, pattern, memsize) == 0) {
++ printf_filtered("pattern match at ");
++ print_address_numeric((addr), 1, gdb_stdout);
++ printf_filtered("\n");
++ }
++ }
++ break;
++ case 'i':
++ memsize = sizeof(int);
++ typi = atoi(pattern);
++
++ if (nfetch < memsize) {
++ printf_filtered
++ ("we read only %i bytes and we seek for a pattern of %i bytes\n",
++ nfetch, memsize);
++ free(data);
++ free(tmp);
++ return;
++ }
++ for (i = 0; i <= (nfetch - memsize); i++, addr++) {
++ int *pint;
++ pint = (unsigned char *) (data + i);
++ if (*pint == typi) {
++ printf_filtered("pattern match at ");
++ print_address_numeric((addr), 1, gdb_stdout);
++ printf_filtered("\n");
++ }
++ }
++ break;
++ case 'a':
++ memsize = sizeof(unsigned long);
++ if (sscanf(pattern, "0x%x", &i) == 0) {
++ printf_filtered("cant convert to hexa %s\n", pattern);
++ break;
++ }
++ my_buf[0] = (unsigned char) ((i & 0x000000FF));
++ my_buf[1] = (unsigned char) ((i & 0x0000FF00) >> 8);
++ my_buf[2] = (unsigned char) ((i & 0x00FF0000) >> 16);
++ my_buf[3] = (unsigned char) ((i & 0xFF000000) >> 24);
++ if (nfetch < memsize) {
++ printf_filtered
++ ("we read only %i bytes and we seek for a pattern of %i bytes\n",
++ nfetch, memsize);
++ free(data);
++ free(tmp);
++ return;
++ }
++ for (i = 0; i <= (nfetch - memsize); i++, addr++) {
++ if (memcmp((data + i), my_buf, memsize) == 0) {
++ printf_filtered("pattern match at ");
++ print_address_numeric((addr), 1, gdb_stdout);
++ printf_filtered("\n");
++ }
++ }
++ break;
++ case 'b':
++ case 'c':
++ memsize = sizeof(char);
++ if (typ == 'c')
++ typc = *pattern;
++ else {
++ if (strncmp("0x", pattern, 2) == 0) {
++ sscanf(pattern, "0x%02x", &typc);
++ } else
++ typc = (unsigned char)atoi(pattern);
++ }
++ printf_filtered(">>>%0x2\n", (int) typc);
++ if (nfetch < memsize) {
++ printf_filtered
++ ("we read only %i bytes and we seek for a pattern of %i bytes\n",
++ nfetch, memsize);
++ free(data);
++ free(tmp);
++ return;
++ }
++ for (i = 0; i <= (nfetch - memsize); i++, addr++) {
++ if (*(data + i) == typc) {
++ printf_filtered("pattern match at ");
++ print_address_numeric((addr), 1, gdb_stdout);
++ printf_filtered("\n");
++ }
++ }
++ break;
++ default:
++ printf_filtered("'%c' is not a valid type\n", typ);
++ break;
++ }
++ free(data);
++ free(tmp);
++ return;
++ }
++}
++
+ /* Same as print, except in epoch, it gets its own window */
+ static void
+ inspect_command (char *exp, int from_tty)
+@@ -2138,6 +2327,17 @@ EXP may be preceded with /FMT, where FMT
+ but no count or size letter (see \"x\" command).", NULL));
+ set_cmd_completer (c, location_completer);
+ add_com_alias ("p", "print", class_vars, 1);
++ c =
++ add_com ("scanmem", class_vars, scanmem_command,
++ "scanmem <addr> <num> <type> <string>\n"
++ "example: scanmem $esp 100 a 0x8048434\n"
++ " scan for this addr into the stack\n\n"
++ " scanmem 0x08048434 100 s fsck\n"
++ " seek for a string\n"
++ " scanmem 0x8048434 100 b 0x75\n"
++ " scan for the char 0x75\n"
++ " a = address c = char b = byte i = int s = string\n"
++ "\n"); /* ant...@zo... */
+
+ c = add_com ("inspect", class_vars, inspect_command,
+ "Same as \"print\" command, except that if you are running in the epoch\n\
+diff -Nrup gdb-6.3.orig/gdb/valprint.c gdb-6.3/gdb/valprint.c
+--- gdb-6.3.orig/gdb/valprint.c 2004-09-12 12:13:04.000000000 -0400
++++ gdb-6.3/gdb/valprint.c 2004-11-27 19:23:54.000000000 -0500
+@@ -39,7 +39,7 @@
+
+ /* Prototypes for local functions */
+
+-static int partial_memory_read (CORE_ADDR memaddr, char *myaddr,
++int partial_memory_read (CORE_ADDR memaddr, char *myaddr,
+ int len, int *errnoptr);
+
+ static void show_print (char *, int);
+@@ -837,7 +837,7 @@ val_print_array_elements (struct type *t
+ /* FIXME: cagney/1999-10-14: Only used by val_print_string. Can this
+ function be eliminated. */
+
+-static int
++int
+ partial_memory_read (CORE_ADDR memaddr, char *myaddr, int len, int *errnoptr)
+ {
+ int nread; /* Number of bytes actually read. */
Copied: ipcop/trunk/src/patches/gdb-bfd-malloc-wrap.patch (from rev 204, ipcop/trunk/src/patches/REMOVE/gdb-bfd-malloc-wrap.patch)
===================================================================
--- ipcop/trunk/src/patches/gdb-bfd-malloc-wrap.patch (rev 0)
+++ ipcop/trunk/src/patches/gdb-bfd-malloc-wrap.patch 2007-04-19 18:48:27 UTC (rev 210)
@@ -0,0 +1,23 @@
+--- bfd/elfcode.h.orig 2005-05-04 19:34:52.000000000 -0400
++++ bfd/elfcode.h 2005-05-04 19:37:35.000000000 -0400
+@@ -640,6 +640,9 @@
+ Elf_Internal_Shdr *shdrp;
+ unsigned int num_sec;
+
++ if (sizeof(*i_shdrp)*i_ehdrp->e_shnum/sizeof(*i_shdrp)!=i_ehdrp->e_shnum)
++ goto got_no_match;
++
+ amt = sizeof (*i_shdrp) * i_ehdrp->e_shnum;
+ i_shdrp = bfd_alloc (abfd, amt);
+ if (!i_shdrp)
+@@ -647,6 +650,10 @@
+ num_sec = i_ehdrp->e_shnum;
+ if (num_sec > SHN_LORESERVE)
+ num_sec += SHN_HIRESERVE + 1 - SHN_LORESERVE;
++
++ if (sizeof (i_shdrp) * num_sec/sizeof (i_shdrp) != num_sec)
++ goto got_no_match;
++
+ elf_numsections (abfd) = num_sec;
+ amt = sizeof (i_shdrp) * num_sec;
+ elf_elfsections (abfd) = bfd_alloc (abfd, amt);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|