if (ch == 0) break;
ch = getc(fp);
};
+ if (i%2) ch=getc(fp);
hdr.name = &buf[0];
fread(&hdr.fmtno, sizeof(hdr.fmtno), 1, fp);
}
\f
-struct dbghdr {
+struct st_dbghdr {
int sync;
short rev;
int crc;
short os;
short cpu;
};
+#define SYNC (int)0xefbefeca
#define SWAP_DBGHDR(hdrp, abfd) \
{ \
};
static struct internal_symstruct symbol;
static struct internal_symstruct *symbuf = &symbol;
-static char strbuf[256];
+static char strbuf[4096];
+static struct st_dbghdr dbghdr;
+static short cmplrid;
+
+#define VER_PRE_ULTRAC ((short)4)
+#define VER_ULTRAC ((short)5)
static int
fill_sym (dbg_file, abfd)
bfd *abfd;
{
short id;
-short si;
+short si, nmask;
long li;
int ii;
+char *p;
int nbytes = fread(&si, sizeof(si), 1, dbg_file);
if (nbytes == 0)
case N_SYM_CMPLR:
fread(&si, sizeof(si), 1, dbg_file);
symbuf->n_desc = bfd_get_16(abfd, (unsigned char *)&si);
+ cmplrid = symbuf->n_desc & 0xff;
break;
case N_SYM_SLINE:
fread(&li, sizeof(li), 1, dbg_file);
strbuf[si++] = (char) ii;
} while (ii != 0 || si % 2 != 0);
symbuf->n_strx = strbuf;
+ p = (char *) strchr (strbuf, ':');
+ if (!p) break;
+ if ((p[1] == 'F' || p[1] == 'f') && cmplrid == VER_PRE_ULTRAC)
+ {
+ fread(&si, sizeof(si), 1, dbg_file);
+ nmask = bfd_get_16(abfd, (unsigned char *)&si);
+ for (ii=0; ii<nmask; ii++)
+ fread(&si, sizeof(si), 1, dbg_file);
+ }
break;
case N_SYM_LBRAC:
fread(&li, sizeof(li), 1, dbg_file);
struct cleanup *back_to;
bfd *abfd;
FILE *fp;
- struct dbghdr hdr;
/* End of the text segment of the executable file. */
static CORE_ADDR end_of_text_addr;
abfd = objfile->obfd;
fp = objfile->auxf2;
- fread(&hdr.sync, sizeof(hdr.sync), 1, fp);
- fread(&hdr.rev, sizeof(hdr.rev), 1, fp);
- fread(&hdr.crc, sizeof(hdr.crc), 1, fp);
- fread(&hdr.os, sizeof(hdr.os), 1, fp);
- fread(&hdr.cpu, sizeof(hdr.cpu), 1, fp);
- SWAP_DBGHDR(&hdr, abfd);
+ fread(&dbghdr.sync, sizeof(dbghdr.sync), 1, fp);
+ fread(&dbghdr.rev, sizeof(dbghdr.rev), 1, fp);
+ fread(&dbghdr.crc, sizeof(dbghdr.crc), 1, fp);
+ fread(&dbghdr.os, sizeof(dbghdr.os), 1, fp);
+ fread(&dbghdr.cpu, sizeof(dbghdr.cpu), 1, fp);
+ SWAP_DBGHDR(&dbghdr, abfd);
symnum = 0;
while(1)
case 'p':
case 'l':
+ case 's':
continue;
case ':':
case N_SYM_LBRAC:
/* On most machines, the block addresses are relative to the
N_SO, the linker did not relocate them (sigh). */
- valu += last_source_start_addr;
+ valu += ANOFFSET (section_offsets, SECT_OFF_TEXT);
new = push_context (desc, valu);
break;
case N_SYM_RBRAC:
- valu += last_source_start_addr;
+ valu += ANOFFSET (section_offsets, SECT_OFF_TEXT);
new = pop_context();
#if !defined (OS9K_VARIABLES_INSIDE_BLOCK)
one line-number -- core-address correspondence.
Enter it in the line list for this symbol table. */
/* Relocate for dynamic loading and for ELF acc fn-relative syms. */
- valu += last_source_start_addr;
+ valu += ANOFFSET (section_offsets, SECT_OFF_TEXT);
record_line (current_subfile, (int)name, valu);
break;
/* FIXME: Replace with sr_get_debug (). */
#define LOG_FILE "monitor.log"
-#if defined (LOG_FILE)
FILE *log_file;
-#endif
+static int monitor_log = 0;
static int timeout = 5;
static int is_trace_mode = 0;
if (sr_get_debug())
putchar(c & 0x7f);
-#ifdef LOG_FILE
- if (isascii (c))
+ if (monitor_log && isascii(c))
putc(c & 0x7f, log_file);
-#endif
if (c >= 0)
return c & 0x7f;
expect_prompt(discard)
int discard;
{
-#if defined (LOG_FILE)
+ if (monitor_log)
/* This is a convenient place to do this. The idea is to do it often
enough that we never lose much data if we terminate abnormally. */
- fflush(log_file);
-#endif
+ fflush(log_file);
+
if (is_trace_mode) {
expect("trace", discard);
is_trace_mode = 0;
int entry_pt;
/* Nonzero value indicates that a process really is running. */
- inferior_pid = 42;
+ inferior_pid = 9000;
if (args && *args)
error("Can't pass arguments to remote ROMBUG process");
entry_pt = (int) bfd_get_start_address (exec_bfd);
-#ifdef LOG_FILE
- fputs ("\nIn Create_inferior()", log_file);
-#endif
+ if (monitor_log)
+ fputs ("\nIn Create_inferior()", log_file);
+
/* The "process" (board) is already stopped awaiting our commands, and
the program is already downloaded. We just set its PC and go. */
/* Open a connection to a remote debugger.
NAME is the filename used for communication. */
-static int baudrate = 9600;
static char dev_name[100];
static void
if (monitor_desc == NULL)
perror_with_name(dev_name);
- /* The baud rate was specified when GDB was started. ***
+ /* if baud rate is set by 'set remotebaud' */
if (SERIAL_SETBAUDRATE (monitor_desc, sr_get_baud_rate()))
{
SERIAL_CLOSE (monitor_desc);
perror_with_name ("RomBug");
}
- */
SERIAL_RAW(monitor_desc);
+
rombug_is_open = 1;
-#if defined (LOG_FILE)
log_file = fopen (LOG_FILE, "w");
if (log_file == NULL)
perror_with_name (LOG_FILE);
-#endif
push_monitor (&rombug_cmds);
-
printf_monitor("\r"); /* CR wakes up monitor */
expect_prompt(1);
dev_name);
attach_flag = 1;
+ inferior_pid = 9000;
rombug_fetch_registers();
}
rombug_is_open = 0;
}
-#if defined (LOG_FILE)
if (log_file) {
if (ferror(log_file))
fprintf(stderr, "Error writing log file.\n");
fprintf(stderr, "Error closing log file.\n");
log_file = 0;
}
-#endif
}
int
if (attach_flag) {
printf_monitor (GO_CMD);
attach_flag = 0;
+ inferior_pid = 0;
}
pop_target(); /* calls rombug_close to do the real work */
if (from_tty)
int pid, step;
enum target_signal sig;
{
-#ifdef LOG_FILE
- fprintf (log_file, "\nIn Resume (step=%d, sig=%d)\n", step, sig);
-#endif
+ if (monitor_log)
+ fprintf (log_file, "\nIn Resume (step=%d, sig=%d)\n", step, sig);
if (step)
{
CORE_ADDR addr, pc;
struct obj_section *obj_sec;
-#ifdef LOG_FILE
- fputs ("\nIn wait ()", log_file);
-#endif
+ if (monitor_log)
+ fputs ("\nIn wait ()", log_file);
status->kind = TARGET_WAITKIND_EXITED;
status->value.integer = 0;
rombug_fetch_registers();
pc = read_register(PC_REGNUM);
addr = read_register(DATABASE_REG);
-
obj_sec = find_pc_section (pc);
if (obj_sec != NULL)
- new_symfile_objfile (obj_sec->objfile, 1, 0);
-
- offs = ((struct section_offsets *)
+ {
+ if (obj_sec->objfile != symfile_objfile)
+ new_symfile_objfile(obj_sec->objfile, 1, 0);
+ offs = ((struct section_offsets *)
alloca (sizeof (struct section_offsets)
+ (symfile_objfile->num_sections * sizeof (offs->offsets))));
- memcpy (offs, symfile_objfile->section_offsets,
+ memcpy (offs, symfile_objfile->section_offsets,
(sizeof (struct section_offsets) +
(symfile_objfile->num_sections * sizeof (offs->offsets))));
- ANOFFSET (offs, SECT_OFF_DATA) = addr;
- ANOFFSET (offs, SECT_OFF_BSS) = addr;
-
- /* Because we only set offsets for DATA and BSS sections, and the other
- offsets are unchanged from ->section_offsets, the other sections won't
- get relocated. */
- objfile_relocate (symfile_objfile, offs);
+ ANOFFSET (offs, SECT_OFF_DATA) = addr;
+ ANOFFSET (offs, SECT_OFF_BSS) = addr;
+ objfile_relocate(symfile_objfile, offs);
+ }
return 0;
}
int val, j;
unsigned char b;
-#ifdef LOG_FILE
- fprintf (log_file, "\nIn Fetch Register (reg=%s)\n", get_reg_name (regno));
- fflush (log_file);
-#endif
+ if (monitor_log) {
+ fprintf (log_file, "\nIn Fetch Register (reg=%s)\n", get_reg_name (regno));
+ fflush (log_file);
+ }
if (regno < 0)
{
{
char *name;
-#ifdef LOG_FILE
- fprintf (log_file, "\nIn Store_register (regno=%d)\n", regno);
-#endif
+ if (monitor_log)
+ fprintf (log_file, "\nIn Store_register (regno=%d)\n", regno);
+
if (regno == -1)
rombug_store_registers ();
else
rombug_files_info ()
{
printf ("\tAttached to %s at %d baud.\n",
- dev_name, baudrate);
+ dev_name, sr_get_baud_rate());
}
/* Copy LEN bytes of data from debugger memory at MYADDR
int i;
char buf[10];
-#ifdef LOG_FILE
- fprintf (log_file, "\nIn Write_inferior_memory (memaddr=%x, len=%d)\n", memaddr, len);
-#endif
- printf_monitor (MEM_SET_CMD, memaddr + i);
+ if (monitor_log)
+ fprintf (log_file, "\nIn Write_inferior_memory (memaddr=%x, len=%d)\n", memaddr, len);
+
+ printf_monitor (MEM_SET_CMD, memaddr);
for (i = 0; i < len; i++)
{
expect (CMD_DELIM, 1);
- printf_monitor ("%x", myaddr[i]);
+ printf_monitor ("%x \r", myaddr[i]);
if (sr_get_debug())
printf ("\nSet 0x%x to 0x%x\n", memaddr + i, myaddr[i]);
}
+ expect (CMD_DELIM, 1);
if (CMD_END)
printf_monitor (CMD_END);
expect_prompt (1);
/* Number of bytes to read in this pass. */
int len_this_pass;
-#ifdef LOG_FILE
- fprintf (log_file, "\nIn Read_inferior_memory (memaddr=%x, len=%d)\n", memaddr, len);
-#endif
+ if (monitor_log)
+ fprintf (log_file, "\nIn Read_inferior_memory (memaddr=%x, len=%d)\n", memaddr, len);
/* Note that this code works correctly if startaddr is just less
than UINT_MAX (well, really CORE_ADDR_MAX if there was such a
{
int i;
-#ifdef LOG_FILE
- fprintf (log_file, "\nIn Insert_breakpoint (addr=%x)\n", addr);
-#endif
+ if (monitor_log)
+ fprintf (log_file, "\nIn Insert_breakpoint (addr=%x)\n", addr);
+
for (i = 0; i <= MAX_MONITOR_BREAKPOINTS; i++)
if (breakaddr[i] == 0)
{
{
int i;
-#ifdef LOG_FILE
- fprintf (log_file, "\nIn Remove_breakpoint (addr=%x)\n", addr);
-#endif
+ if (monitor_log)
+ fprintf (log_file, "\nIn Remove_breakpoint (addr=%x)\n", addr);
+
for (i = 0; i < MAX_MONITOR_BREAKPOINTS; i++)
if (breakaddr[i] == addr)
{
breakaddr[i] = 0;
- /* some monitors remove breakpoints based on the address */
- if (strcasecmp (target_shortname, "bug") == 0)
- printf_monitor(CLR_BREAK_CMD, addr);
- else
- printf_monitor(CLR_BREAK_CMD, i);
+ printf_monitor(CLR_BREAK_CMD, addr);
expect_prompt(1);
return 0;
}
char *args;
int fromtty;
{
-#ifdef LOG_FILE
- fprintf (log_file, "\nIn command (args=%s)\n", args);
-#endif
if (monitor_desc == NULL)
error("monitor target not open.");
+ if (monitor_log)
+ fprintf (log_file, "\nIn command (args=%s)\n", args);
+
if (!args)
error("Missing command.");
printf_monitor("%s\r", args);
- expect_prompt(0);
+ expect(CMD_DELIM, 0);
}
#if 0
struct monitor_ops rombug_cmds = {
"g \r", /* execute or usually GO command */
"g \r", /* continue command */
- "gs \r", /* single step */
+ "t \r", /* single step */
"b %x\r", /* set a breakpoint */
"k %x\r", /* clear a breakpoint */
"c %x\r", /* set memory to a value */
0, /* Terminal handling */
rombug_kill,
rombug_load, /* load */
- rombug_link, /* lookup_symbol */
+ rombug_link, /* lookup_symbol */
rombug_create_inferior,
rombug_mourn_inferior,
0, /* can_run */
&setlist),
&showlist);
+ add_show_from_set (
+ add_set_cmd ("monitor_log", no_class, var_zinteger,
+ (char *) &monitor_log,
+ "Set monitor activity log on(=1) or off(=0).",
+ &setlist),
+ &showlist);
+
add_com ("rombug <command>", class_obscure, rombug_command,
"Send a command to the debug monitor.");