summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Kettenis <kettenis@gnu.org>2005-10-29 21:31:45 +0000
committerMark Kettenis <kettenis@gnu.org>2005-10-29 21:31:45 +0000
commite6aacd49dd5862072508b32df27f815293616589 (patch)
tree88a0e226d2c0c49d9a2fcd9632b2b1f5615d92ff
parent6501214445c1d829bd54daf8efc8531782450a29 (diff)
downloadgdb-e6aacd49dd5862072508b32df27f815293616589.tar.gz
* hppa-tdep.h (HPPA_INSN_SIZE): New define.
* hppa-hpux-tdep.c (hppa_hpux_search_pattern) (hppa64_hpux_search_dummy_call_sequence): Rewrite to avoid assumption on sizeof(unsigned).
-rw-r--r--gdb/ChangeLog5
-rw-r--r--gdb/hppa-hpux-tdep.c39
-rw-r--r--gdb/hppa-tdep.h3
3 files changed, 27 insertions, 20 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 4f67d1f5d82..de5d48c48ea 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,10 @@
2005-10-29 Mark Kettenis <kettenis@gnu.org>
+ * hppa-tdep.h (HPPA_INSN_SIZE): New define.
+ * hppa-hpux-tdep.c (hppa_hpux_search_pattern)
+ (hppa64_hpux_search_dummy_call_sequence): Rewrite to avoid
+ assumption on sizeof(unsigned).
+
* inf-ttrace.c (inf_ttrace_wait): Comment out TARGET_WAITKIND_EXEC
code; return TARGET_WAITKIND_STOPPED instead.
diff --git a/gdb/hppa-hpux-tdep.c b/gdb/hppa-hpux-tdep.c
index c0f9a3ab1d6..ed0abf9ee9e 100644
--- a/gdb/hppa-hpux-tdep.c
+++ b/gdb/hppa-hpux-tdep.c
@@ -1,6 +1,6 @@
/* Target-dependent code for HP-UX on PA-RISC.
- Copyright 2002, 2003, 2004 Free Software Foundation, Inc.
+ Copyright 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
This file is part of GDB.
@@ -1309,32 +1309,31 @@ static CORE_ADDR
hppa_hpux_search_pattern (CORE_ADDR start, CORE_ADDR end,
unsigned int *patterns, int count)
{
- unsigned int *buf;
+ int num_insns = (end - start + HPPA_INSN_SIZE) / HPPA_INSN_SIZE;
+ unsigned int *insns;
+ gdb_byte *buf;
int offset, i;
- int region, insns;
- region = end - start + 4;
- insns = region / 4;
- buf = (unsigned int *) alloca (region);
+ buf = alloca (num_insns * HPPA_INSN_SIZE);
+ insns = alloca (num_insns * sizeof (unsigned int));
- read_memory (start, (char *) buf, region);
+ read_memory (start, buf, num_insns * HPPA_INSN_SIZE);
+ for (i = 0; i < num_insns; i++, buf += HPPA_INSN_SIZE)
+ insns[i] = extract_unsigned_integer (buf, HPPA_INSN_SIZE);
- for (i = 0; i < insns; i++)
- buf[i] = extract_unsigned_integer (&buf[i], 4);
-
- for (offset = 0; offset <= insns - count; offset++)
+ for (offset = 0; offset <= num_insns - count; offset++)
{
for (i = 0; i < count; i++)
{
- if ((buf[offset + i] & patterns[i]) != patterns[i])
+ if ((insns[offset + i] & patterns[i]) != patterns[i])
break;
}
if (i == count)
break;
}
-
- if (offset <= insns - count)
- return start + offset * 4;
+
+ if (offset <= num_insns - count)
+ return start + offset * HPPA_INSN_SIZE;
else
return 0;
}
@@ -1472,7 +1471,7 @@ hppa64_hpux_search_dummy_call_sequence (struct gdbarch *gdbarch, CORE_ADDR pc,
{
CORE_ADDR begin, end;
char *name;
- unsigned int insns[2];
+ gdb_byte buf[2 * HPPA_INSN_SIZE];
int offset;
find_pc_partial_function (SYMBOL_VALUE_ADDRESS (msym), &name,
@@ -1481,16 +1480,16 @@ hppa64_hpux_search_dummy_call_sequence (struct gdbarch *gdbarch, CORE_ADDR pc,
if (name == NULL || begin == 0 || end == 0)
continue;
- if (target_read_memory (end - sizeof (insns), (char *)insns, sizeof (insns)) == 0)
+ if (target_read_memory (end - sizeof (buf), buf, sizeof (buf)) == 0)
{
- for (offset = 0; offset < ARRAY_SIZE (insns); offset++)
+ for (offset = 0; offset < sizeof (buf); offset++)
{
unsigned int insn;
- insn = extract_unsigned_integer (&insns[offset], 4);
+ insn = extract_unsigned_integer (buf + offset, HPPA_INSN_SIZE);
if (insn == 0xe840d002) /* bve,n (rp) */
{
- addr = (end - sizeof (insns)) + (offset * 4);
+ addr = (end - sizeof (buf)) + offset;
goto found_pattern;
}
}
diff --git a/gdb/hppa-tdep.h b/gdb/hppa-tdep.h
index 484a2d50439..2e5227b75ba 100644
--- a/gdb/hppa-tdep.h
+++ b/gdb/hppa-tdep.h
@@ -75,6 +75,9 @@ enum hppa_regnum
HPPA_ARG3_REGNUM = 23 /* The fourth argument of a callee. */
};
+/* Instruction size. */
+#define HPPA_INSN_SIZE 4
+
/* Target-dependent structure in gdbarch. */
struct gdbarch_tdep
{