+trace_one_insn (SIM_DESC sd, sim_cpu *cpu, const char *filename,
+ int linenum, int idecode, address_word pc, const char *name)
+{
+ if (idecode)
+ trace_printf(sd, cpu, "%s:%-*d 0x%.*lx (decode) %s\n",
+ filename,
+ SIZE_LINE_NUMBER, linenum,
+ SIZE_PC, (long)pc,
+ name);
+
+ else if (!TRACE_LINENUM_P (cpu))
+ trace_printf(sd, cpu, "%s:%-*d 0x%.*lx %s\n",
+ filename,
+ SIZE_LINE_NUMBER, linenum,
+ SIZE_PC, (long)pc,
+ name);
+
+ else
+ {
+ char buf[256];
+
+ buf[0] = 0;
+ if (STATE_TEXT_SECTION (CPU_STATE (cpu))
+ && pc >= STATE_TEXT_START (CPU_STATE (cpu))
+ && pc < STATE_TEXT_END (CPU_STATE (cpu)))
+ {
+ const char *pc_filename = (const char *)0;
+ const char *pc_function = (const char *)0;
+ unsigned int pc_linenum = 0;
+
+ if (bfd_find_nearest_line (STATE_PROG_BFD (CPU_STATE (cpu)),
+ STATE_TEXT_SECTION (CPU_STATE (cpu)),
+ (struct symbol_cache_entry **) 0,
+ pc - STATE_TEXT_START (CPU_STATE (cpu)),
+ &pc_filename, &pc_function, &pc_linenum))
+ {
+ char *p = buf;
+ if (pc_linenum)
+ {
+ sprintf (p, "#%-*d ", SIZE_LINE_NUMBER, pc_linenum);
+ p += strlen (p);
+ }
+ else
+ {
+ sprintf (p, "%-*s ", SIZE_LINE_NUMBER+1, "---");
+ p += SIZE_LINE_NUMBER+2;
+ }
+
+ if (pc_function)
+ {
+ sprintf (p, "%s ", pc_function);
+ 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';
+ }
+ }
+
+ trace_printf (sd, cpu, "0x%.*x %-*.*s %s\n",
+ SIZE_PC, (unsigned) pc,
+ SIZE_LOCATION, SIZE_LOCATION, buf,
+ name);
+ }
+}
+\f
+void