aboutsummaryrefslogtreecommitdiff
path: root/sim/v850
diff options
context:
space:
mode:
authorMichael Meissner <gnu@the-meissners.org>1996-09-12 16:06:02 +0000
committerMichael Meissner <gnu@the-meissners.org>1996-09-12 16:06:02 +0000
commit1d00ce83925d1df264a620b861574e8f3cf0835a (patch)
treee0175cc5841763965d45203337b1f37dbbfed5e3 /sim/v850
parent9b280a864b4861885f1b239188b8680d26c83f17 (diff)
downloadgdb-1d00ce83925d1df264a620b861574e8f3cf0835a.zip
gdb-1d00ce83925d1df264a620b861574e8f3cf0835a.tar.gz
gdb-1d00ce83925d1df264a620b861574e8f3cf0835a.tar.bz2
Print line # and function name or filename if they exist for each PC.
Diffstat (limited to 'sim/v850')
-rw-r--r--sim/v850/ChangeLog5
-rw-r--r--sim/v850/simops.c67
2 files changed, 69 insertions, 3 deletions
diff --git a/sim/v850/ChangeLog b/sim/v850/ChangeLog
index a4bffb5..b5ecdd3 100644
--- a/sim/v850/ChangeLog
+++ b/sim/v850/ChangeLog
@@ -1,3 +1,8 @@
+Thu Sep 12 12:03:05 1996 Michael Meissner <meissner@tiktok.cygnus.com>
+
+ * simops.c (trace_input): Use find_nearest_line to print line
+ number, function name or file name of PC.
+
Wed Sep 11 16:44:37 1996 Michael Meissner <meissner@tiktok.cygnus.com>
* simops.c: Add tracing support. Use SEXTxx macros instead of
diff --git a/sim/v850/simops.c b/sim/v850/simops.c
index 215ba56..e8fd489 100644
--- a/sim/v850/simops.c
+++ b/sim/v850/simops.c
@@ -2,6 +2,7 @@
#include "v850_sim.h"
#include "simops.h"
#include "sys/syscall.h"
+#include "bfd.h"
enum op_types {
OP_UNKNOWN,
@@ -32,6 +33,11 @@ enum op_types {
#ifdef DEBUG
static void trace_input PARAMS ((char *name, enum op_types type, int size));
static void trace_output PARAMS ((enum op_types result));
+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 6
@@ -45,23 +51,78 @@ static void trace_output PARAMS ((enum op_types result));
#define SIZE_VALUES 11
#endif
+#ifndef SIZE_LOCATION
+#define SIZE_LOCATION 40
+#endif
+
static void
trace_input (name, type, size)
char *name;
enum op_types type;
int size;
{
- char buf[80];
+ char buf[1024];
+ char *p;
uint32 values[3];
int num_values, i;
char *cond;
+ asection *s;
+ const char *filename;
+ const char *functionname;
+ unsigned int linenumber;
if ((v850_debug & DEBUG_TRACE) == 0)
return;
- (*v850_callback->printf_filtered) (v850_callback,
- "0x%.8x: %-*s",
+ 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;
+ }
+ }
+
+ if (text && PC >= text_start && 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, PC - text_start,
+ &filename, &functionname, &linenumber))
+ {
+ p = buf;
+ if (linenumber)
+ {
+ sprintf (p, "Line %5d ", linenumber);
+ p += strlen (p);
+ }
+
+ if (functionname)
+ {
+ sprintf (p, "Func %s ", functionname);
+ p += strlen (p);
+ }
+ else if (filename)
+ {
+ char *q = (char *) strrchr (filename, '/');
+ sprintf (p, "File %s ", (q) ? q+1 : filename);
+ p += strlen (p);
+ }
+
+ if (*p == ' ')
+ *p = '\0';
+ }
+ }
+
+ (*v850_callback->printf_filtered) (v850_callback, "0x%.8x: %-*.*s %-*s",
(unsigned)PC,
+ SIZE_LOCATION, SIZE_LOCATION, buf,
SIZE_INSTRUCTION, name);
switch (type)