blob: b14e4092adeb047dd6e6b201db4f37ba4ee80da8 [file] [log] [blame]
Brad Bishop286d45c2018-10-02 15:21:57 -04001From 26e124f0d78233b1d976bd4b787f6a7866bcb7e7 Mon Sep 17 00:00:00 2001
2From: nagaraju <nmekala@xilix.com>
3Date: Wed, 4 Jan 2012 16:59:33 +0530
4Subject: [PATCH 04/16] [Patch, microblaze]: Communicate in larger blocks with
5 the target
6
7Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
8Upstream-Status: Pending
9---
10 gdb/microblaze-tdep.c | 25 ++++++++++++++++++++++---
11 1 file changed, 22 insertions(+), 3 deletions(-)
12
13diff --git a/gdb/microblaze-tdep.c b/gdb/microblaze-tdep.c
14index 36cf1ca..76e87b3 100644
15--- a/gdb/microblaze-tdep.c
16+++ b/gdb/microblaze-tdep.c
17@@ -242,6 +242,10 @@ microblaze_analyze_prologue (struct gdbarch *gdbarch, CORE_ADDR pc,
18 int flags = 0;
19 int save_hidden_pointer_found = 0;
20 int non_stack_instruction_found = 0;
21+ int n_insns;
22+ unsigned long *insn_block;
23+ gdb_byte *buf_block;
24+ int ti, tj;
25
26 /* Find the start of this function. */
27 find_pc_partial_function (pc, &name, &func_addr, &func_end);
28@@ -281,9 +285,23 @@ microblaze_analyze_prologue (struct gdbarch *gdbarch, CORE_ADDR pc,
29 name, paddress (gdbarch, func_addr),
30 paddress (gdbarch, stop));
31
32+/* Do a block read to minimize the transaction with the Debug Agent */
33+ n_insns = (stop == func_addr) ? 1 : ((stop - func_addr) / INST_WORD_SIZE);
34+ insn_block = (unsigned long *)calloc(n_insns, sizeof(unsigned long));
35+ buf_block = (gdb_byte *)calloc(n_insns * INST_WORD_SIZE, sizeof(gdb_byte));
36+
37+ target_read_memory (func_addr, buf_block, n_insns * INST_WORD_SIZE );
38+
39+ for(ti = 0; ti < n_insns; ti++){
40+ insn_block[ti] = 0;
41+ for( tj = ti * INST_WORD_SIZE; tj < (ti + 1) * INST_WORD_SIZE; tj++ )
42+ insn_block[ti] = (insn_block[ti] << 8) | buf_block[tj];
43+ }
44+
45 for (addr = func_addr; addr < stop; addr += INST_WORD_SIZE)
46 {
47- insn = microblaze_fetch_instruction (addr);
48+ //insn = microblaze_fetch_instruction (addr);
49+ insn = insn_block[(addr - func_addr) / INST_WORD_SIZE];
50 op = microblaze_decode_insn (insn, &rd, &ra, &rb, &imm);
51 microblaze_debug ("%s %08lx\n", paddress (gdbarch, pc), insn);
52
53@@ -409,8 +427,9 @@ microblaze_analyze_prologue (struct gdbarch *gdbarch, CORE_ADDR pc,
54 part of the prologue. */
55 if (save_hidden_pointer_found)
56 prologue_end_addr -= INST_WORD_SIZE;
57-
58- return prologue_end_addr;
59+ free(insn_block);
60+ free(buf_block);
61+ return prologue_end_addr;
62 }
63
64 static CORE_ADDR
65--
661.9.0
67