1 /* Target-dependent code for Mitsubishi D30V, for GDB.
2 Copyright (C) 1996, 1997 Free Software Foundation, Inc.
4 This file is part of GDB.
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
20 /* Contributed by Martin Hunt, hunt@cygnus.com */
29 #include "gdb_string.h"
36 void d30v_frame_find_saved_regs
PARAMS ((struct frame_info
*fi
,
37 struct frame_saved_regs
*fsr
));
38 static void d30v_pop_dummy_frame
PARAMS ((struct frame_info
*fi
));
39 static void d30v_print_flags
PARAMS ((void));
40 static void print_flags_command
PARAMS ((char *, int));
42 /* Discard from the stack the innermost frame, restoring all saved
48 struct frame_info
*frame
= get_current_frame ();
51 struct frame_saved_regs fsr
;
54 fp
= FRAME_FP (frame
);
57 d30v_pop_dummy_frame(frame
);
61 /* fill out fsr with the address of where each */
62 /* register was stored in the frame */
63 get_frame_saved_regs (frame
, &fsr
);
65 /* now update the current registers with the old values */
66 for (regnum
= A0_REGNUM
; regnum
< A0_REGNUM
+2 ; regnum
++)
70 read_memory (fsr
.regs
[regnum
], raw_buffer
, 8);
71 write_register_bytes (REGISTER_BYTE (regnum
), raw_buffer
, 8);
74 for (regnum
= 0; regnum
< SP_REGNUM
; regnum
++)
78 write_register (regnum
, read_memory_unsigned_integer (fsr
.regs
[regnum
], 2));
81 if (fsr
.regs
[PSW_REGNUM
])
83 write_register (PSW_REGNUM
, read_memory_unsigned_integer (fsr
.regs
[PSW_REGNUM
], 2));
86 write_register (PC_REGNUM
, read_register(13));
87 write_register (SP_REGNUM
, fp
+ frame
->size
);
88 target_store_registers (-1);
89 flush_cached_frames ();
97 if ((op
& 0x7E1F) == 0x6C1F)
101 if ((op
& 0x7E3F) == 0x6E1F)
105 if ((op
& 0x7FE1) == 0x01E1)
117 if ((op
& 0x7E1F) == 0x681E)
121 if ((op
& 0x7E3F) == 0x3A1E)
128 d30v_skip_prologue (pc
)
132 unsigned short op1
, op2
;
133 CORE_ADDR func_addr
, func_end
;
134 struct symtab_and_line sal
;
136 /* XXX -- these need to be updated, the instruction patterns are actually
137 for the d10v, not the d30v. */
138 /* If we have line debugging information, then the end of the */
139 /* prologue should the first assembly instruction of the first source line */
140 if (find_pc_partial_function (pc
, NULL
, &func_addr
, &func_end
))
142 sal
= find_pc_line (func_addr
, 0);
143 if ( sal
.end
&& sal
.end
< func_end
)
147 if (target_read_memory (pc
, (char *)&op
, 4))
148 return pc
; /* Can't access it -- assume no prologue. */
152 op
= (unsigned long)read_memory_integer (pc
, 4);
153 if ((op
& 0xC0000000) == 0xC0000000)
155 /* long instruction */
156 if ( ((op
& 0x3FFF0000) != 0x01FF0000) && /* add3 sp,sp,n */
157 ((op
& 0x3F0F0000) != 0x340F0000) && /* st rn, @(offset,sp) */
158 ((op
& 0x3F1F0000) != 0x350F0000)) /* st2w rn, @(offset,sp) */
163 /* short instructions */
164 if ((op
& 0xC0000000) == 0x80000000)
166 op2
= (op
& 0x3FFF8000) >> 15;
171 op1
= (op
& 0x3FFF8000) >> 15;
174 if (check_prologue(op1
))
176 if (!check_prologue(op2
))
178 /* if the previous opcode was really part of the prologue */
179 /* and not just a NOP, then we want to break after both instructions */
193 /* Given a GDB frame, determine the address of the calling function's frame.
194 This will be used to create a new GDB frame struct, and then
195 INIT_EXTRA_FRAME_INFO and INIT_FRAME_PC will be called for the new frame.
199 d30v_frame_chain (frame
)
200 struct frame_info
*frame
;
202 struct frame_saved_regs fsr
;
204 d30v_frame_find_saved_regs (frame
, &fsr
);
206 if (frame
->return_pc
== IMEM_START
)
209 if (!fsr
.regs
[FP_REGNUM
])
211 if (!fsr
.regs
[SP_REGNUM
] || fsr
.regs
[SP_REGNUM
] == STACK_START
)
214 return fsr
.regs
[SP_REGNUM
];
217 if (!read_memory_unsigned_integer(fsr
.regs
[FP_REGNUM
],2))
220 return read_memory_unsigned_integer(fsr
.regs
[FP_REGNUM
],2)| DMEM_START
;
223 static int next_addr
, uses_frame
;
226 prologue_find_regs (op
, fsr
, addr
)
228 struct frame_saved_regs
*fsr
;
233 /* XXX -- these need to be updated, the instruction patterns are actually
234 for the d10v, not the d30v. */
236 if ((op
& 0x7E1F) == 0x6C1F)
238 n
= (op
& 0x1E0) >> 5;
240 fsr
->regs
[n
] = next_addr
;
245 else if ((op
& 0x7E3F) == 0x6E1F)
247 n
= (op
& 0x1E0) >> 5;
249 fsr
->regs
[n
] = next_addr
;
250 fsr
->regs
[n
+1] = next_addr
+2;
255 if ((op
& 0x7FE1) == 0x01E1)
257 n
= (op
& 0x1E) >> 1;
276 if ((op
& 0x7E1F) == 0x681E)
278 n
= (op
& 0x1E0) >> 5;
279 fsr
->regs
[n
] = next_addr
;
284 if ((op
& 0x7E3F) == 0x3A1E)
286 n
= (op
& 0x1E0) >> 5;
287 fsr
->regs
[n
] = next_addr
;
288 fsr
->regs
[n
+1] = next_addr
+2;
295 /* Put here the code to store, into a struct frame_saved_regs, the
296 addresses of the saved registers of frame described by FRAME_INFO.
297 This includes special registers such as pc and fp saved in special
298 ways in the stack frame. sp is even more special: the address we
299 return for it IS the sp for the next frame. */
300 /* XXX -- these need to be updated, the instruction patterns are actually
301 for the d10v, not the d30v. */
303 d30v_frame_find_saved_regs (fi
, fsr
)
304 struct frame_info
*fi
;
305 struct frame_saved_regs
*fsr
;
309 unsigned short op1
, op2
;
313 memset (fsr
, 0, sizeof (*fsr
));
316 pc
= get_pc_function_start (fi
->pc
);
321 op
= (unsigned long)read_memory_integer (pc
, 4);
322 if ((op
& 0xC0000000) == 0xC0000000)
324 /* long instruction */
325 if ((op
& 0x3FFF0000) == 0x01FF0000)
328 short n
= op
& 0xFFFF;
331 else if ((op
& 0x3F0F0000) == 0x340F0000)
333 /* st rn, @(offset,sp) */
334 short offset
= op
& 0xFFFF;
335 short n
= (op
>> 20) & 0xF;
336 fsr
->regs
[n
] = next_addr
+ offset
;
338 else if ((op
& 0x3F1F0000) == 0x350F0000)
340 /* st2w rn, @(offset,sp) */
341 short offset
= op
& 0xFFFF;
342 short n
= (op
>> 20) & 0xF;
343 fsr
->regs
[n
] = next_addr
+ offset
;
344 fsr
->regs
[n
+1] = next_addr
+ offset
+ 2;
351 /* short instructions */
352 if ((op
& 0xC0000000) == 0x80000000)
354 op2
= (op
& 0x3FFF8000) >> 15;
359 op1
= (op
& 0x3FFF8000) >> 15;
362 if (!prologue_find_regs(op1
,fsr
,pc
) || !prologue_find_regs(op2
,fsr
,pc
))
368 fi
->size
= -next_addr
;
371 fp
= read_register(SP_REGNUM
) | DMEM_START
;
373 for (i
=0; i
<NUM_REGS
-1; i
++)
376 fsr
->regs
[i
] = fp
- (next_addr
- fsr
->regs
[i
]);
379 if (fsr
->regs
[LR_REGNUM
])
380 fi
->return_pc
= ((read_memory_unsigned_integer(fsr
->regs
[LR_REGNUM
],2) - 1) << 2) | IMEM_START
;
382 fi
->return_pc
= ((read_register(LR_REGNUM
) - 1) << 2) | IMEM_START
;
384 /* th SP is not normally (ever?) saved, but check anyway */
385 if (!fsr
->regs
[SP_REGNUM
])
387 /* if the FP was saved, that means the current FP is valid, */
388 /* otherwise, it isn't being used, so we use the SP instead */
390 fsr
->regs
[SP_REGNUM
] = read_register(FP_REGNUM
) + fi
->size
;
393 fsr
->regs
[SP_REGNUM
] = fp
+ fi
->size
;
395 fsr
->regs
[FP_REGNUM
] = 0;
401 d30v_init_extra_frame_info (fromleaf
, fi
)
403 struct frame_info
*fi
;
405 struct frame_saved_regs dummy
;
407 if (fi
->next
&& ((fi
->pc
& 0xffff) == 0))
408 fi
->pc
= fi
->next
->return_pc
;
410 d30v_frame_find_saved_regs (fi
, &dummy
);
413 static void d30v_print_register
PARAMS ((int regnum
, int tabular
));
416 d30v_print_register (regnum
, tabular
)
420 if (regnum
< A0_REGNUM
)
423 printf_filtered ("%08x", read_register (regnum
));
425 printf_filtered ("0x%x %d", read_register (regnum
),
426 read_register (regnum
));
430 char regbuf
[MAX_REGISTER_RAW_SIZE
];
432 read_relative_register_raw_bytes (regnum
, regbuf
);
434 val_print (REGISTER_VIRTUAL_TYPE (regnum
), regbuf
, 0,
435 gdb_stdout
, 'x', 1, 0, Val_pretty_default
);
439 printf_filtered (" ");
440 val_print (REGISTER_VIRTUAL_TYPE (regnum
), regbuf
, 0,
441 gdb_stdout
, 'd', 1, 0, Val_pretty_default
);
449 long psw
= read_register (PSW_REGNUM
);
450 printf_filtered ("flags #1");
451 printf_filtered (" (sm) %d", (psw
& PSW_SM
) != 0);
452 printf_filtered (" (ea) %d", (psw
& PSW_EA
) != 0);
453 printf_filtered (" (db) %d", (psw
& PSW_DB
) != 0);
454 printf_filtered (" (ds) %d", (psw
& PSW_DS
) != 0);
455 printf_filtered (" (ie) %d", (psw
& PSW_IE
) != 0);
456 printf_filtered (" (rp) %d", (psw
& PSW_RP
) != 0);
457 printf_filtered (" (md) %d\n", (psw
& PSW_MD
) != 0);
459 printf_filtered ("flags #2");
460 printf_filtered (" (f0) %d", (psw
& PSW_F0
) != 0);
461 printf_filtered (" (f1) %d", (psw
& PSW_F1
) != 0);
462 printf_filtered (" (f2) %d", (psw
& PSW_F2
) != 0);
463 printf_filtered (" (f3) %d", (psw
& PSW_F3
) != 0);
464 printf_filtered (" (s) %d", (psw
& PSW_S
) != 0);
465 printf_filtered (" (v) %d", (psw
& PSW_V
) != 0);
466 printf_filtered (" (va) %d", (psw
& PSW_VA
) != 0);
467 printf_filtered (" (c) %d\n", (psw
& PSW_C
) != 0);
471 print_flags_command (args
, from_tty
)
479 d30v_do_registers_info (regnum
, fpregs
)
483 long long num1
, num2
;
488 if (reg_names
[0] == NULL
|| reg_names
[0][0] == '\000')
491 printf_filtered ("%s ", reg_names
[regnum
]);
492 d30v_print_register (regnum
, 0);
494 printf_filtered ("\n");
498 /* Have to print all the registers. Format them nicely. */
500 printf_filtered ("PC=");
501 print_address (read_pc (), gdb_stdout
);
503 printf_filtered (" PSW=");
504 d30v_print_register (PSW_REGNUM
, 1);
506 printf_filtered (" BPC=");
507 print_address (read_register (BPC_REGNUM
), gdb_stdout
);
509 printf_filtered (" BPSW=");
510 d30v_print_register (BPSW_REGNUM
, 1);
511 printf_filtered ("\n");
513 printf_filtered ("DPC=");
514 print_address (read_register (DPC_REGNUM
), gdb_stdout
);
516 printf_filtered (" DPSW=");
517 d30v_print_register (DPSW_REGNUM
, 1);
519 printf_filtered (" IBA=");
520 print_address (read_register (IBA_REGNUM
), gdb_stdout
);
521 printf_filtered ("\n");
523 printf_filtered ("RPT_C=");
524 d30v_print_register (RPT_C_REGNUM
, 1);
526 printf_filtered (" RPT_S=");
527 print_address (read_register (RPT_S_REGNUM
), gdb_stdout
);
529 printf_filtered (" RPT_E=");
530 print_address (read_register (RPT_E_REGNUM
), gdb_stdout
);
531 printf_filtered ("\n");
533 printf_filtered ("MOD_S=");
534 print_address (read_register (MOD_S_REGNUM
), gdb_stdout
);
536 printf_filtered (" MOD_E=");
537 print_address (read_register (MOD_E_REGNUM
), gdb_stdout
);
538 printf_filtered ("\n");
540 printf_filtered ("EIT_VB=");
541 print_address (read_register (EIT_VB_REGNUM
), gdb_stdout
);
543 printf_filtered (" INT_S=");
544 d30v_print_register (INT_S_REGNUM
, 1);
546 printf_filtered (" INT_M=");
547 d30v_print_register (INT_M_REGNUM
, 1);
548 printf_filtered ("\n");
551 for (regnum
= 0; regnum
<= 63;)
555 printf_filtered ("R%d-R%d ", regnum
, regnum
+ 7);
557 printf_filtered (" ");
559 printf_filtered (" ");
561 for (i
= 0; i
< 8; i
++)
563 printf_filtered (" ");
564 d30v_print_register (regnum
++, 1);
567 printf_filtered ("\n");
570 printf_filtered ("A0-A1 ");
572 d30v_print_register (A0_REGNUM
, 1);
573 printf_filtered (" ");
574 d30v_print_register (A1_REGNUM
, 1);
575 printf_filtered ("\n");
579 d30v_fix_call_dummy (dummyname
, start_sp
, fun
, nargs
, args
, type
, gcc_p
)
590 char buffer
[MAX_REGISTER_RAW_SIZE
];
591 struct frame_info
*frame
= get_current_frame ();
592 frame
->dummy
= start_sp
;
593 start_sp
|= DMEM_START
;
596 for (regnum
= 0; regnum
< NUM_REGS
; regnum
++)
598 sp
-= REGISTER_RAW_SIZE(regnum
);
599 store_address (buffer
, REGISTER_RAW_SIZE(regnum
), read_register(regnum
));
600 write_memory (sp
, buffer
, REGISTER_RAW_SIZE(regnum
));
602 write_register (SP_REGNUM
, (LONGEST
)(sp
& 0xffff));
603 /* now we need to load LR with the return address */
604 write_register (LR_REGNUM
, (LONGEST
)(d30v_call_dummy_address() & 0xffff) >> 2);
609 d30v_pop_dummy_frame (fi
)
610 struct frame_info
*fi
;
612 CORE_ADDR sp
= fi
->dummy
;
615 for (regnum
= 0; regnum
< NUM_REGS
; regnum
++)
617 sp
-= REGISTER_RAW_SIZE(regnum
);
618 write_register(regnum
, read_memory_unsigned_integer (sp
, REGISTER_RAW_SIZE(regnum
)));
620 flush_cached_frames (); /* needed? */
625 d30v_push_arguments (nargs
, args
, sp
, struct_return
, struct_addr
)
630 CORE_ADDR struct_addr
;
632 int i
, len
, index
=0, regnum
=2;
633 char buffer
[4], *contents
;
637 /* Pass 1. Put all large args on stack */
638 for (i
= 0; i
< nargs
; i
++)
640 value_ptr arg
= args
[i
];
641 struct type
*arg_type
= check_typedef (VALUE_TYPE (arg
));
642 len
= TYPE_LENGTH (arg_type
);
643 contents
= VALUE_CONTENTS(arg
);
644 val
= extract_signed_integer (contents
, len
);
647 /* put on stack and pass pointers */
649 write_memory (sp
, contents
, len
);
656 for (i
= 0; i
< nargs
; i
++)
658 value_ptr arg
= args
[i
];
659 struct type
*arg_type
= check_typedef (VALUE_TYPE (arg
));
660 len
= TYPE_LENGTH (arg_type
);
661 contents
= VALUE_CONTENTS(arg
);
662 val
= extract_signed_integer (contents
, len
);
665 /* use a pointer to previously saved data */
667 write_register (regnum
++, ptrs
[index
++]);
670 /* no more registers available. put it on the stack */
672 store_address (buffer
, 2, ptrs
[index
++]);
673 write_memory (sp
, buffer
, 2);
681 write_register (regnum
++, val
>>16);
682 write_register (regnum
++, val
& 0xffff);
687 store_address (buffer
, len
, val
);
688 write_memory (sp
, buffer
, len
);
696 /* pick an out-of-the-way place to set the return value */
697 /* for an inferior function call. The link register is set to this */
698 /* value and a momentary breakpoint is set there. When the breakpoint */
699 /* is hit, the dummy frame is popped and the previous environment is */
703 d30v_call_dummy_address ()
706 struct minimal_symbol
*sym
;
708 entry
= entry_point_address ();
713 sym
= lookup_minimal_symbol ("_start", NULL
, symfile_objfile
);
715 if (!sym
|| MSYMBOL_TYPE (sym
) != mst_text
)
718 return SYMBOL_VALUE_ADDRESS (sym
);
721 /* Given a return value in `regbuf' with a type `valtype',
722 extract and copy its value into `valbuf'. */
725 d30v_extract_return_value (valtype
, regbuf
, valbuf
)
726 struct type
*valtype
;
727 char regbuf
[REGISTER_BYTES
];
730 memcpy (valbuf
, regbuf
+ REGISTER_BYTE (2), TYPE_LENGTH (valtype
));
733 /* The following code implements access to, and display of, the D30V's
734 instruction trace buffer. The buffer consists of 64K or more
735 4-byte words of data, of which each words includes an 8-bit count,
736 an 8-bit segment number, and a 16-bit instruction address.
738 In theory, the trace buffer is continuously capturing instruction
739 data that the CPU presents on its "debug bus", but in practice, the
740 ROMified GDB stub only enables tracing when it continues or steps
741 the program, and stops tracing when the program stops; so it
742 actually works for GDB to read the buffer counter out of memory and
743 then read each trace word. The counter records where the tracing
744 stops, but there is no record of where it started, so we remember
745 the PC when we resumed and then search backwards in the trace
746 buffer for a word that includes that address. This is not perfect,
747 because you will miss trace data if the resumption PC is the target
748 of a branch. (The value of the buffer counter is semi-random, any
749 trace data from a previous program stop is gone.) */
751 /* The address of the last word recorded in the trace buffer. */
753 #define DBBC_ADDR (0xd80000)
755 /* The base of the trace buffer, at least for the "Board_0". */
757 #define TRACE_BUFFER_BASE (0xf40000)
759 static void trace_command
PARAMS ((char *, int));
761 static void untrace_command
PARAMS ((char *, int));
763 static void trace_info
PARAMS ((char *, int));
765 static void tdisassemble_command
PARAMS ((char *, int));
767 static void display_trace
PARAMS ((int, int));
769 /* True when instruction traces are being collected. */
775 static CORE_ADDR last_pc
;
777 /* True when trace output should be displayed whenever program stops. */
779 static int trace_display
;
781 /* True when trace listing should include source lines. */
783 static int default_trace_show_source
= 1;
785 struct trace_buffer
{
792 trace_command (args
, from_tty
)
796 /* Clear the host-side trace buffer, allocating space if needed. */
798 if (trace_data
.counts
== NULL
)
799 trace_data
.counts
= (short *) xmalloc (65536 * sizeof(short));
800 if (trace_data
.addrs
== NULL
)
801 trace_data
.addrs
= (CORE_ADDR
*) xmalloc (65536 * sizeof(CORE_ADDR
));
805 printf_filtered ("Tracing is now on.\n");
809 untrace_command (args
, from_tty
)
815 printf_filtered ("Tracing is now off.\n");
819 trace_info (args
, from_tty
)
827 printf_filtered ("%d entries in trace buffer:\n", trace_data
.size
);
829 for (i
= 0; i
< trace_data
.size
; ++i
)
831 printf_filtered ("%d: %d instruction%s at 0x%x\n",
832 i
, trace_data
.counts
[i
],
833 (trace_data
.counts
[i
] == 1 ? "" : "s"),
834 trace_data
.addrs
[i
]);
838 printf_filtered ("No entries in trace buffer.\n");
840 printf_filtered ("Tracing is currently %s.\n", (tracing
? "on" : "off"));
843 /* Print the instruction at address MEMADDR in debugged memory,
844 on STREAM. Returns length of the instruction, in bytes. */
847 print_insn (memaddr
, stream
)
851 /* If there's no disassembler, something is very wrong. */
852 if (tm_print_insn
== NULL
)
855 if (TARGET_BYTE_ORDER
== BIG_ENDIAN
)
856 tm_print_insn_info
.endian
= BFD_ENDIAN_BIG
;
858 tm_print_insn_info
.endian
= BFD_ENDIAN_LITTLE
;
859 return (*tm_print_insn
) (memaddr
, &tm_print_insn_info
);
863 d30v_eva_prepare_to_trace ()
868 last_pc
= read_register (PC_REGNUM
);
871 /* Collect trace data from the target board and format it into a form
872 more useful for display. */
875 d30v_eva_get_trace_data ()
877 int count
, i
, j
, oldsize
;
878 int trace_addr
, trace_seg
, trace_cnt
, next_cnt
;
879 unsigned int last_trace
, trace_word
, next_word
;
880 unsigned int *tmpspace
;
885 tmpspace
= xmalloc (65536 * sizeof(unsigned int));
887 last_trace
= read_memory_unsigned_integer (DBBC_ADDR
, 2) << 2;
889 /* Collect buffer contents from the target, stopping when we reach
890 the word recorded when execution resumed. */
893 while (last_trace
> 0)
897 read_memory_unsigned_integer (TRACE_BUFFER_BASE
+ last_trace
, 4);
898 trace_addr
= trace_word
& 0xffff;
900 /* Ignore an apparently nonsensical entry. */
901 if (trace_addr
== 0xffd5)
903 tmpspace
[count
++] = trace_word
;
904 if (trace_addr
== last_pc
)
910 /* Move the data to the host-side trace buffer, adjusting counts to
911 include the last instruction executed and transforming the address
912 into something that GDB likes. */
914 for (i
= 0; i
< count
; ++i
)
916 trace_word
= tmpspace
[i
];
917 next_word
= ((i
== 0) ? 0 : tmpspace
[i
- 1]);
918 trace_addr
= trace_word
& 0xffff;
919 next_cnt
= (next_word
>> 24) & 0xff;
920 j
= trace_data
.size
+ count
- i
- 1;
921 trace_data
.addrs
[j
] = (trace_addr
<< 2) + 0x1000000;
922 trace_data
.counts
[j
] = next_cnt
+ 1;
925 oldsize
= trace_data
.size
;
926 trace_data
.size
+= count
;
931 display_trace (oldsize
, trace_data
.size
);
935 tdisassemble_command (arg
, from_tty
)
946 high
= trace_data
.size
;
948 else if (!(space_index
= (char *) strchr (arg
, ' ')))
950 low
= parse_and_eval_address (arg
);
957 low
= parse_and_eval_address (arg
);
958 high
= parse_and_eval_address (space_index
+ 1);
963 printf_filtered ("Dump of trace from %d to %d:\n", low
, high
);
965 display_trace (low
, high
);
967 printf_filtered ("End of trace dump.\n");
968 gdb_flush (gdb_stdout
);
972 display_trace (low
, high
)
975 int i
, count
, trace_show_source
, first
, suppress
;
976 CORE_ADDR next_address
;
978 trace_show_source
= default_trace_show_source
;
979 if (!have_full_symbols () && !have_partial_symbols())
981 trace_show_source
= 0;
982 printf_filtered ("No symbol table is loaded. Use the \"file\" command.\n");
983 printf_filtered ("Trace will not display any source.\n");
988 for (i
= low
; i
< high
; ++i
)
990 next_address
= trace_data
.addrs
[i
];
991 count
= trace_data
.counts
[i
];
995 if (trace_show_source
)
997 struct symtab_and_line sal
, sal_prev
;
999 sal_prev
= find_pc_line (next_address
- 4, 0);
1000 sal
= find_pc_line (next_address
, 0);
1004 if (first
|| sal
.line
!= sal_prev
.line
)
1005 print_source_lines (sal
.symtab
, sal
.line
, sal
.line
+ 1, 0);
1011 /* FIXME-32x64--assumes sal.pc fits in long. */
1012 printf_filtered ("No source file for address %s.\n",
1013 local_hex_string((unsigned long) sal
.pc
));
1018 print_address (next_address
, gdb_stdout
);
1019 printf_filtered (":");
1020 printf_filtered ("\t");
1022 next_address
= next_address
+ print_insn (next_address
, gdb_stdout
);
1023 printf_filtered ("\n");
1024 gdb_flush (gdb_stdout
);
1029 extern void (*target_resume_hook
) PARAMS ((void));
1030 extern void (*target_wait_loop_hook
) PARAMS ((void));
1033 _initialize_d30v_tdep ()
1035 tm_print_insn
= print_insn_d30v
;
1037 target_resume_hook
= d30v_eva_prepare_to_trace
;
1038 target_wait_loop_hook
= d30v_eva_get_trace_data
;
1040 add_info ("flags", print_flags_command
, "Print d30v flags.");
1042 add_com ("trace", class_support
, trace_command
,
1043 "Enable tracing of instruction execution.");
1045 add_com ("untrace", class_support
, untrace_command
,
1046 "Disable tracing of instruction execution.");
1048 add_com ("tdisassemble", class_vars
, tdisassemble_command
,
1049 "Disassemble the trace buffer.\n\
1050 Two optional arguments specify a range of trace buffer entries\n\
1051 as reported by info trace (NOT addresses!).");
1053 add_info ("trace", trace_info
,
1054 "Display info about the trace data buffer.");
1056 add_show_from_set (add_set_cmd ("tracedisplay", no_class
,
1057 var_integer
, (char *)&trace_display
,
1058 "Set automatic display of trace.\n", &setlist
),
1060 add_show_from_set (add_set_cmd ("tracesource", no_class
,
1061 var_integer
, (char *)&default_trace_show_source
,
1062 "Set display of source code with trace.\n", &setlist
),