aboutsummaryrefslogtreecommitdiff
path: root/sim
diff options
context:
space:
mode:
authorMichael Meissner <gnu@the-meissners.org>1996-09-18 13:23:31 +0000
committerMichael Meissner <gnu@the-meissners.org>1996-09-18 13:23:31 +0000
commita49a15ade80ed7fa3c08b5faf6bffdb70054760e (patch)
tree91e3e0875c9e64434eb8c71779f090a782603e64 /sim
parent8ebc98911a9133e0bd2a9f841b013593eee5aea3 (diff)
downloadgdb-a49a15ade80ed7fa3c08b5faf6bffdb70054760e.zip
gdb-a49a15ade80ed7fa3c08b5faf6bffdb70054760e.tar.gz
gdb-a49a15ade80ed7fa3c08b5faf6bffdb70054760e.tar.bz2
Make exit/stop return correct exit value; Add line number tracing.
Diffstat (limited to 'sim')
-rw-r--r--sim/d10v/ChangeLog33
-rw-r--r--sim/d10v/Makefile.in3
-rw-r--r--sim/d10v/configure.in14
-rw-r--r--sim/d10v/interp.c17
-rw-r--r--sim/d10v/simops.c113
5 files changed, 154 insertions, 26 deletions
diff --git a/sim/d10v/ChangeLog b/sim/d10v/ChangeLog
index 3f22811..fbf57d8 100644
--- a/sim/d10v/ChangeLog
+++ b/sim/d10v/ChangeLog
@@ -1,3 +1,36 @@
+Wed Sep 18 09:13:25 1996 Michael Meissner <meissner@tiktok.cygnus.com>
+
+ * d10v_sim.h (DEBUG_INSTRUCTION): New debug value to include line
+ numbers and function names in debug trace.
+ (DEBUG): If not defined, set to DEBUG_TRACE, DEBUG_VALUES, and
+ DEBUG_LINE_NUMBER.
+ (SIG_D10V_{STOP,EXIT}): Values to represent the stop instruction
+ and exit system call trap being executed.
+
+ * interp.c (sim_stop_reason): Set exit code correctly for stop
+ instruction and exit system call trap.
+
+ * configure.in (--enable-sim-cflags): Remove trace case.
+ (--enable-sim-debug): New switch to set the debug values.
+ * configure: Regenerate.
+
+ * simops.c (trace_{input,output}_func): Rename from
+ trace_{input,output}.
+ (trace_{input,output}): Call trace_{input,output}_func if
+ d10v_debug is non-zero.
+ (SIZE_INSTRUCTION): Cut down to 8.
+ (SIZE_OPERANDS): Cut down to 18.
+ (SIZE_LOCATION): New value for size of line number, function name
+ field.
+ (init_text_p,text{,_start,_end}): New static variables for
+ printing line number and function name.
+ (sim_bfd): New external that run.c sets.
+ (trace_input_func): Print line number and function name if
+ available and if desired.
+ (OP_4E09): Don't print out DBT message.
+ (OP_5FE0): Set exception field to SIG_D10V_STOP.
+ (OP_5F00): Set exception field to SIG_D10V_EXIT.
+
Sat Sep 14 22:18:43 1996 Michael Meissner <meissner@tiktok.cygnus.com>
* interp.c (do_2_short): If the instruction encodes jump->ins,
diff --git a/sim/d10v/Makefile.in b/sim/d10v/Makefile.in
index 2e6aac5..19972b2 100644
--- a/sim/d10v/Makefile.in
+++ b/sim/d10v/Makefile.in
@@ -61,7 +61,8 @@ CC = @CC@
CC_FOR_BUILD = @CC_FOR_BUILD@
CFLAGS = @CFLAGS@
SIM_CFLAGS = @sim_cflags@
-CONFIG_CFLAGS = @DEFS@ $(SIM_CFLAGS) $(HDEFINES) $(TDEFINES) $(CSEARCH) $(CSWITCHES) -DINSIDE_SIMULATOR
+DEBUG_CFLAGS = @sim_debug@
+CONFIG_CFLAGS = @DEFS@ $(SIM_CFLAGS) $(DEBUG_CFLAGS) $(HDEFINES) $(TDEFINES) $(CSEARCH) $(CSWITCHES) -DINSIDE_SIMULATOR
BUILD_CFLAGS = -g -O $(CSEARCH)
MAKEINFO = makeinfo
RANLIB = @RANLIB@
diff --git a/sim/d10v/configure.in b/sim/d10v/configure.in
index 647255e..cc9c4ad 100644
--- a/sim/d10v/configure.in
+++ b/sim/d10v/configure.in
@@ -23,7 +23,7 @@ AC_ARG_ENABLE(sim-cflags,
[ --enable-sim-cflags=opts Extra CFLAGS for use in building simulator],
[case "${enableval}" in
yes) sim_cflags="-O2";;
- trace) sim_cflags="-O2 -DDEBUG=3";;
+ trace) AC_MSG_ERROR("Please use --enable-sim-debug instead."); sim_cflags="";;
no) sim_cflags="";;
*) sim_cflags=`echo "${enableval}" | sed -e "s/,/ /g"`;;
esac
@@ -31,6 +31,17 @@ if test x"$silent" != x"yes" && test x"$sim_cflags" != x""; then
echo "Setting sim cflags = $sim_cflags" 6>&1
fi],[sim_cflags=""])dnl
+AC_ARG_ENABLE(sim-debug,
+[ --enable-sim-debug=opts Enable debugging flags],
+[case "${enableval}" in
+ yes) sim_debug="-DDEBUG=7";;
+ no) sim_debug="-DDEBUG=0";;
+ *) sim_debug="-DDEBUG='(${enableval})'";;
+esac
+if test x"$silent" != x"yes" && test x"$sim_debug" != x""; then
+ echo "Setting sim debug = $sim_debug" 6>&1
+fi],[sim_cflags=""])dnl
+
AC_SUBST(CC_FOR_BUILD)
AC_SUBST(CFLAGS)
AC_SUBST(HDEFINES)
@@ -38,6 +49,7 @@ AR=${AR-ar}
AC_SUBST(AR)
AC_PROG_RANLIB
AC_SUBST(sim_cflags)
+AC_SUBST(sim_debug)
# Put a plausible default for CC_FOR_BUILD in Makefile.
AC_C_CROSS
diff --git a/sim/d10v/interp.c b/sim/d10v/interp.c
index f035cf0..d34c116 100644
--- a/sim/d10v/interp.c
+++ b/sim/d10v/interp.c
@@ -492,15 +492,22 @@ sim_stop_reason (reason, sigrc)
{
/* (*d10v_callback->printf_filtered) (d10v_callback, "sim_stop_reason: PC=0x%x\n",PC<<2); */
- if (State.exception == SIGQUIT)
+ switch (State.exception)
{
+ case SIG_D10V_STOP: /* stop instruction */
*reason = sim_exited;
- *sigrc = State.exception;
- }
- else
- {
+ *sigrc = 0;
+ break;
+
+ case SIG_D10V_EXIT: /* exit trap */
+ *reason = sim_exited;
+ *sigrc = State.regs[2];
+ break;
+
+ default: /* some signal */
*reason = sim_stopped;
*sigrc = State.exception;
+ break;
}
}
diff --git a/sim/d10v/simops.c b/sim/d10v/simops.c
index 3a889a1..7f8cd09 100644
--- a/sim/d10v/simops.c
+++ b/sim/d10v/simops.c
@@ -7,6 +7,7 @@
#include "d10v_sim.h"
#include "simops.h"
#include "sys/syscall.h"
+#include "bfd.h"
enum op_types {
OP_VOID,
@@ -33,27 +34,41 @@ enum op_types {
};
#ifdef DEBUG
-static void trace_input PARAMS ((char *name,
- enum op_types in1,
- enum op_types in2,
- enum op_types in3));
+static void trace_input_func PARAMS ((char *name,
+ enum op_types in1,
+ enum op_types in2,
+ enum op_types in3));
-static void trace_output PARAMS ((enum op_types result));
+#define trace_input(name, in1, in2, in3) do { if (d10v_debug) trace_input_func (name, in1, in2, in3); } while (0)
+
+static void trace_output_func PARAMS ((enum op_types result));
+
+#define trace_output(result) do { if (d10v_debug) trace_output_func (result); } while (0)
+
+static int init_text_p = 0;
+static asection *text;
+static bfd_vma text_start;
+static bfd_vma text_end;
+extern bfd *sim_bfd;
#ifndef SIZE_INSTRUCTION
-#define SIZE_INSTRUCTION 10
+#define SIZE_INSTRUCTION 8
#endif
#ifndef SIZE_OPERANDS
-#define SIZE_OPERANDS 24
+#define SIZE_OPERANDS 18
#endif
#ifndef SIZE_VALUES
#define SIZE_VALUES 13
#endif
+#ifndef SIZE_LOCATION
+#define SIZE_LOCATION 20
+#endif
+
static void
-trace_input (name, in1, in2, in3)
+trace_input_func (name, in1, in2, in3)
char *name;
enum op_types in1;
enum op_types in2;
@@ -62,10 +77,15 @@ trace_input (name, in1, in2, in3)
char *comma;
enum op_types in[3];
int i;
- char buf[80];
+ char buf[1024];
char *p;
long tmp;
char *type;
+ asection *s;
+ const char *filename;
+ const char *functionname;
+ unsigned int linenumber;
+ bfd_vma byte_pc;
if ((d10v_debug & DEBUG_TRACE) == 0)
return;
@@ -81,10 +101,67 @@ trace_input (name, in1, in2, in3)
case INS_LONG: type = " B"; break;
}
- (*d10v_callback->printf_filtered) (d10v_callback,
- "0x%.6x %s: %-*s",
- (unsigned)PC, type,
- SIZE_INSTRUCTION, name);
+ if ((d10v_debug & DEBUG_LINE_NUMBER) == 0)
+ (*d10v_callback->printf_filtered) (d10v_callback,
+ "0x%.6x %s: %-*s",
+ (unsigned)PC, type,
+ SIZE_INSTRUCTION, name);
+
+ else
+ {
+ buf[0] = '\0';
+ if (!init_text_p)
+ {
+ init_text_p = 1;
+ for (s = sim_bfd->sections; s; s = s->next)
+ if (strcmp (bfd_get_section_name (sim_bfd, s), ".text") == 0)
+ {
+ text = s;
+ text_start = bfd_get_section_vma (sim_bfd, s);
+ text_end = text_start + bfd_section_size (sim_bfd, s);
+ break;
+ }
+ }
+
+ byte_pc = (bfd_vma)PC << 2;
+ if (text && byte_pc >= text_start && byte_pc < text_end)
+ {
+ filename = (const char *)0;
+ functionname = (const char *)0;
+ linenumber = 0;
+ if (bfd_find_nearest_line (sim_bfd, text, (struct symbol_cache_entry **)0, byte_pc - text_start,
+ &filename, &functionname, &linenumber))
+ {
+ p = buf;
+ if (linenumber)
+ {
+ sprintf (p, "#%-4d ", linenumber);
+ p += strlen (p);
+ }
+
+ if (functionname)
+ {
+ sprintf (p, "%s ", functionname);
+ p += strlen (p);
+ }
+ else if (filename)
+ {
+ char *q = (char *) strrchr (filename, '/');
+ sprintf (p, "%s ", (q) ? q+1 : filename);
+ p += strlen (p);
+ }
+
+ if (*p == ' ')
+ *p = '\0';
+ }
+ }
+
+ (*d10v_callback->printf_filtered) (d10v_callback,
+ "0x%.6x %s: %-*.*s %-*s",
+ (unsigned)PC, type,
+ SIZE_LOCATION, SIZE_LOCATION, buf,
+ SIZE_INSTRUCTION, name);
+ }
in[0] = in1;
in[1] = in2;
@@ -286,7 +363,7 @@ trace_input (name, in1, in2, in3)
}
static void
-trace_output (result)
+trace_output_func (result)
enum op_types result;
{
if ((d10v_debug & (DEBUG_TRACE | DEBUG_VALUES)) == (DEBUG_TRACE | DEBUG_VALUES))
@@ -865,7 +942,7 @@ OP_4E09 ()
void
OP_5F20 ()
{
- d10v_callback->printf_filtered(d10v_callback, "***** DBT ***** PC=%x\n",PC);
+ /* d10v_callback->printf_filtered(d10v_callback, "***** DBT ***** PC=%x\n",PC); */
State.exception = SIGTRAP;
}
@@ -2233,7 +2310,7 @@ void
OP_5FE0 ()
{
trace_input ("stop", OP_VOID, OP_VOID, OP_VOID);
- State.exception = SIGQUIT;
+ State.exception = SIG_D10V_STOP;
trace_output (OP_VOID);
}
@@ -2545,9 +2622,7 @@ OP_5F00 ()
RETVAL = d10v_callback->open (d10v_callback, MEMPTR (PARM1), PARM2);
break;
case SYS_exit:
- /* EXIT - caller can look in PARM1 to work out the
- reason */
- State.exception = SIGQUIT;
+ State.exception = SIG_D10V_EXIT;
break;
case SYS_stat: