Add tracing of booleans and addresses.

This commit is contained in:
Andrew Cagney 1998-02-23 16:43:34 +00:00
parent 5af9fc5f50
commit 0325f2dc89
3 changed files with 189 additions and 22 deletions

View file

@ -1,3 +1,13 @@
Tue Feb 24 00:29:57 1998 Andrew Cagney <cagney@b1.cygnus.com>
* sim-trace.c (print_data): case trace_fmt_fp missing break. Use
sim_fpu to safely print fp_word values.
(print_data): Add trace_fmt_bool and trace_fmt_addr.
(trace_result_bool1, trace_result_addr1): New functions.
(trace_input_bool1, trace_input_addr1): New functions.
* sim-trace.h (TRACE_FPU_*): Define.
Mon Feb 23 13:24:54 1998 Andrew Cagney <cagney@b1.cygnus.com>
* sim-fpu.h (enum sim_fpu_class): Add sim_fpu_class_denorm.

View file

@ -384,6 +384,8 @@ typedef enum {
trace_fmt_fp,
trace_fmt_fpu,
trace_fmt_string,
trace_fmt_bool,
trace_fmt_addr,
trace_fmt_instruction_incomplete,
} data_fmt;
@ -428,28 +430,46 @@ print_data (SIM_DESC sd,
trace_printf (sd, cpu, " (instruction incomplete)");
break;
case trace_fmt_word:
switch (size)
{
case sizeof (unsigned_word):
trace_printf (sd, cpu, " 0x%08lx", (long) * (unsigned_word*) data);
break;
default:
abort ();
}
break;
case trace_fmt_addr:
{
switch (size)
{
case sizeof (unsigned32):
trace_printf (sd, cpu, " 0x%08lx", (long) * (unsigned32*) data);
break;
case sizeof (unsigned64):
trace_printf (sd, cpu, " 0x%08lx", (long) * (unsigned64*) data);
break;
default:
abort ();
}
break;
}
case trace_fmt_bool:
{
SIM_ASSERT (size == sizeof (int));
trace_printf (sd, cpu, " %-8s",
(* (int*) data) ? "true" : "false");
break;
}
case trace_fmt_fp:
switch (size)
{
/* FIXME: Assumes sizeof float == 4; sizeof double == 8 */
case 4:
trace_printf (sd, cpu, " %8g", * (float*) data);
break;
case 8:
trace_printf (sd, cpu, " %8g", * (double*) data);
break;
default:
abort ();
}
{
sim_fpu fp;
switch (size)
{
/* FIXME: Assumes sizeof float == 4; sizeof double == 8 */
case 4:
sim_fpu_32to (&fp, * (unsigned32*) data);
break;
case 8:
sim_fpu_64to (&fp, * (unsigned32*) data);
break;
default:
abort ();
}
trace_printf (sd, cpu, " %8g", sim_fpu_2d (&fp));
break;
}
case trace_fmt_fpu:
/* FIXME: At present sim_fpu data is stored as a double */
trace_printf (sd, cpu, " %8g", * (double*) data);
@ -700,6 +720,28 @@ trace_input_word3 (SIM_DESC sd,
save_data (sd, data, trace_fmt_word, sizeof (unsigned_word), &d2);
}
void
trace_input_bool1 (SIM_DESC sd,
sim_cpu *cpu,
int trace_idx,
int d0)
{
TRACE_DATA *data = CPU_TRACE_DATA (cpu);
TRACE_IDX (data) = trace_idx;
save_data (sd, data, trace_fmt_bool, sizeof (d0), &d0);
}
void
trace_input_addr1 (SIM_DESC sd,
sim_cpu *cpu,
int trace_idx,
address_word d0)
{
TRACE_DATA *data = CPU_TRACE_DATA (cpu);
TRACE_IDX (data) = trace_idx;
save_data (sd, data, trace_fmt_addr, sizeof (d0), &d0);
}
void
trace_input_fp1 (SIM_DESC sd,
sim_cpu *cpu,
@ -803,6 +845,38 @@ trace_result_word1 (SIM_DESC sd,
trace_results (sd, cpu, trace_idx, last_input);
}
void
trace_result_bool1 (SIM_DESC sd,
sim_cpu *cpu,
int trace_idx,
int r0)
{
TRACE_DATA *data = CPU_TRACE_DATA (cpu);
int last_input;
/* Append any results to the end of the inputs */
last_input = TRACE_INPUT_IDX (data);
save_data (sd, data, trace_fmt_bool, sizeof (r0), &r0);
trace_results (sd, cpu, trace_idx, last_input);
}
void
trace_result_addr1 (SIM_DESC sd,
sim_cpu *cpu,
int trace_idx,
address_word r0)
{
TRACE_DATA *data = CPU_TRACE_DATA (cpu);
int last_input;
/* Append any results to the end of the inputs */
last_input = TRACE_INPUT_IDX (data);
save_data (sd, data, trace_fmt_addr, sizeof (r0), &r0);
trace_results (sd, cpu, trace_idx, last_input);
}
void
trace_result_fp1 (SIM_DESC sd,
sim_cpu *cpu,

View file

@ -1,5 +1,5 @@
/* Simulator tracing/debugging support.
Copyright (C) 1997 Free Software Foundation, Inc.
Copyright (C) 1997, 1998 Free Software Foundation, Inc.
Contributed by Cygnus Support.
This file is part of GDB, the GNU debugger.
@ -77,6 +77,16 @@ enum {
#ifndef MAX_TRACE_VALUES
#define MAX_TRACE_VALUES 32
#endif
/* The -t option only prints useful values. It's easy to type and shouldn't
splat on the screen everything under the sun making nothing easy to
find. */
#define TRACE_USEFUL_MASK \
((1 << TRACE_INSN_IDX) \
| (1 << TRACE_LINENUM_IDX) \
| (1 << TRACE_MEMORY_IDX) \
| (1 << TRACE_MODEL_IDX) \
| (1 << TRACE_EVENTS_IDX))
/* Masks so WITH_TRACE can have symbolic values.
The case choice here is on purpose. The lowercase parts are args to
@ -228,15 +238,18 @@ extern void trace_generic PARAMS ((SIM_DESC sd,
extern void trace_input0 PARAMS ((SIM_DESC sd,
sim_cpu *cpu,
int trace_idx));
extern void trace_input_word1 PARAMS ((SIM_DESC sd,
sim_cpu *cpu,
int trace_idx,
unsigned_word d0));
extern void trace_input_word2 PARAMS ((SIM_DESC sd,
sim_cpu *cpu,
int trace_idx,
unsigned_word d0,
unsigned_word d1));
extern void trace_input_word3 PARAMS ((SIM_DESC sd,
sim_cpu *cpu,
int trace_idx,
@ -244,6 +257,11 @@ extern void trace_input_word3 PARAMS ((SIM_DESC sd,
unsigned_word d1,
unsigned_word d2));
extern void trace_input_bool1 PARAMS ((SIM_DESC sd,
sim_cpu *cpu,
int trace_idx,
int d0));
extern void trace_input_fp1 PARAMS ((SIM_DESC sd,
sim_cpu *cpu,
int trace_idx,
@ -287,6 +305,16 @@ extern void trace_result_word1 PARAMS ((SIM_DESC sd,
int trace_idx,
unsigned_word r0));
extern void trace_result_bool1 PARAMS ((SIM_DESC sd,
sim_cpu *cpu,
int trace_idx,
int r0));
extern void trace_result_addr1 PARAMS ((SIM_DESC sd,
sim_cpu *cpu,
int trace_idx,
address_word r0));
extern void trace_result_fp1 PARAMS ((SIM_DESC sd,
sim_cpu *cpu,
int trace_idx,
@ -312,6 +340,7 @@ extern void trace_result_word1_string1 PARAMS ((SIM_DESC sd,
/* Macro's for tracing ALU instructions */
#define TRACE_ALU_INPUT0() \
do { \
if (TRACE_ALU_P (CPU)) \
@ -342,6 +371,60 @@ do { \
trace_result_word1 (SD, CPU, TRACE_ALU_IDX, (R0)); \
} while (0)
/* Macro's for tracing FPU instructions */
#define TRACE_FPU_INPUT0() \
do { \
if (TRACE_FPU_P (CPU)) \
trace_input0 (SD, CPU, TRACE_FPU_IDX); \
} while (0)
#define TRACE_FPU_INPUT1(V0) \
do { \
if (TRACE_FPU_P (CPU)) \
trace_input_fp1 (SD, CPU, TRACE_FPU_IDX, (V0)); \
} while (0)
#define TRACE_FPU_INPUT2(V0,V1) \
do { \
if (TRACE_FPU_P (CPU)) \
trace_input_fp2 (SD, CPU, TRACE_FPU_IDX, (V0), (V1)); \
} while (0)
#define TRACE_FPU_INPUT3(V0,V1,V2) \
do { \
if (TRACE_FPU_P (CPU)) \
trace_input_fp3 (SD, CPU, TRACE_FPU_IDX, (V0), (V1), (V2)); \
} while (0)
#define TRACE_FPU_RESULT(R0) \
do { \
if (TRACE_FPU_P (CPU)) \
trace_result_fp1 (SD, CPU, TRACE_FPU_IDX, (R0)); \
} while (0)
#define TRACE_FPU_RESULT_BOOL(R0) \
do { \
if (TRACE_FPU_P (CPU)) \
trace_result_bool1 (SD, CPU, TRACE_FPU_IDX, (R0)); \
} while (0)
/* Macros for tracing branches */
#define TRACE_BRANCH_INPUT(COND) \
do { \
if (TRACE_BRANCH_P (CPU)) \
trace_input_bool1 (SD, CPU, TRACE_BRANCH_IDX, (COND)); \
} while (0)
#define TRACE_BRANCH_RESULT(DEST) \
do { \
if (TRACE_BRANCH_P (CPU)) \
trace_result_addr1 (SD, CPU, TRACE_BRANCH_IDX, (DEST)); \
} while (0)
/* The function trace_one_insn has been replaced by trace_generic */
extern void trace_one_insn PARAMS ((SIM_DESC sd,