diff options
-rw-r--r-- | gdb/ChangeLog | 19 | ||||
-rw-r--r-- | gdb/os9kread.c | 44 | ||||
-rw-r--r-- | gdb/remote-os9k.c | 133 | ||||
-rw-r--r-- | gdb/stabsread.c | 1 | ||||
-rw-r--r-- | gdb/symfile.c | 41 |
5 files changed, 134 insertions, 104 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index d4cf72e5eed..008cb37ac57 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,22 @@ +Wed Mar 9 18:56:36 1994 Kung Hsu (kung@mexican.cygnus.com) + + * os9kread.c (fill_sym): check compiler verion number for pre- + UltraC compiler. + * os9kread.c (os9k_process_one_symbol): address of symbol is + relative to section not module. + * stabsread.c (define_symbol): add symbol type 's' as local + symbol for os9k. + * remote-os9k.c: add command 'set monitor_log' to turn on or off + monitor logging. + * remote-os9k.c: fix bug in delete breakpoint, single step trace. + * remote-os9k.c: fix bug in 'set remotebaud' function. + * remote-os9k.c (rombug_link): minimize checking so to improve + speed. + * symfile.c (symfile_command): check if failed to link, also make + the command be able to accept more than one filenames. + * target.c (target_link): check if failed to link with rombug. + * config/i386/tm-i386os9k.h : add #define DECR_PC_AFTER_BREAK 0. + Wed Mar 9 15:23:19 1994 Jim Kingdon (kingdon@lioth.cygnus.com) * remote-es.c (es1800_child_ops): Don't declare it static. diff --git a/gdb/os9kread.c b/gdb/os9kread.c index 7a392925b1f..6577b6570a1 100644 --- a/gdb/os9kread.c +++ b/gdb/os9kread.c @@ -272,6 +272,7 @@ char buf[64], buf1[128]; 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); @@ -439,13 +440,14 @@ os9k_symfile_finish (objfile) } -struct dbghdr { +struct st_dbghdr { int sync; short rev; int crc; short os; short cpu; }; +#define SYNC (int)0xefbefeca #define SWAP_DBGHDR(hdrp, abfd) \ { \ @@ -471,7 +473,12 @@ struct internal_symstruct { }; 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) @@ -479,9 +486,10 @@ 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) @@ -498,6 +506,7 @@ int ii; 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); @@ -516,6 +525,15 @@ int ii; 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); @@ -577,7 +595,6 @@ read_os9k_psymtab (section_offsets, objfile, text_addr, text_size) 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; @@ -617,12 +634,12 @@ read_os9k_psymtab (section_offsets, objfile, text_addr, text_size) 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) @@ -888,6 +905,7 @@ read_os9k_psymtab (section_offsets, objfile, text_addr, text_size) case 'p': case 'l': + case 's': continue; case ':': @@ -1459,12 +1477,12 @@ os9k_process_one_symbol (type, desc, valu, name, section_offsets, objfile) 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) @@ -1530,7 +1548,7 @@ os9k_process_one_symbol (type, desc, valu, name, section_offsets, objfile) 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; diff --git a/gdb/remote-os9k.c b/gdb/remote-os9k.c index d0d91fd5115..6b862da2629 100644 --- a/gdb/remote-os9k.c +++ b/gdb/remote-os9k.c @@ -76,9 +76,8 @@ static int rombug_is_open = 0; /* 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; @@ -117,10 +116,8 @@ readchar(timeout) 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; @@ -197,11 +194,11 @@ static void 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; @@ -290,7 +287,7 @@ rombug_create_inferior (execfile, args, env) 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"); @@ -300,9 +297,9 @@ rombug_create_inferior (execfile, args, env) 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. */ @@ -314,7 +311,6 @@ rombug_create_inferior (execfile, args, env) /* 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 @@ -336,24 +332,21 @@ rombug_open(args, from_tty) 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); @@ -363,6 +356,7 @@ rombug_open(args, from_tty) dev_name); attach_flag = 1; + inferior_pid = 9000; rombug_fetch_registers(); } @@ -380,7 +374,6 @@ rombug_close (quitting) rombug_is_open = 0; } -#if defined (LOG_FILE) if (log_file) { if (ferror(log_file)) fprintf(stderr, "Error writing log file.\n"); @@ -388,7 +381,6 @@ rombug_close (quitting) fprintf(stderr, "Error closing log file.\n"); log_file = 0; } -#endif } int @@ -428,6 +420,7 @@ rombug_detach (from_tty) 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) @@ -442,9 +435,8 @@ rombug_resume (pid, step, sig) 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) { @@ -476,9 +468,8 @@ rombug_wait (pid, status) 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; @@ -492,25 +483,22 @@ rombug_wait (pid, status) 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; } @@ -610,10 +598,10 @@ rombug_fetch_register (regno) 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) { @@ -691,9 +679,9 @@ rombug_store_register (regno) { 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 @@ -725,7 +713,7 @@ static void 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 @@ -739,17 +727,18 @@ rombug_write_inferior_memory (memaddr, myaddr, len) 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); @@ -777,9 +766,8 @@ rombug_read_inferior_memory(memaddr, myaddr, len) /* 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 @@ -872,9 +860,9 @@ rombug_insert_breakpoint (addr, shadow) { 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) { @@ -901,18 +889,14 @@ rombug_remove_breakpoint (addr, shadow) { 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; } @@ -990,17 +974,17 @@ rombug_command (args, fromtty) 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 @@ -1104,7 +1088,7 @@ connect_command (args, fromtty) 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 */ @@ -1144,7 +1128,7 @@ Specify the serial device it is connected to (e.g. /dev/ttya).", 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 */ @@ -1179,6 +1163,13 @@ _initialize_remote_os9k () &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."); diff --git a/gdb/stabsread.c b/gdb/stabsread.c index 860d72adcc6..8e7aec405bd 100644 --- a/gdb/stabsread.c +++ b/gdb/stabsread.c @@ -805,6 +805,7 @@ define_symbol (valu, string, desc, type, objfile) /* This case is faked by a conditional above, when there is no code letter in the dbx data. Dbx data never actually contains 'l'. */ + case 's': case 'l': SYMBOL_TYPE (sym) = read_type (&p, objfile); SYMBOL_CLASS (sym) = LOC_LOCAL; diff --git a/gdb/symfile.c b/gdb/symfile.c index 98c5c457bbd..dbb84d91e6f 100644 --- a/gdb/symfile.c +++ b/gdb/symfile.c @@ -675,7 +675,27 @@ symbol_file_command (args, from_tty) } else { - name = *argv; + char *p; + + name = *argv; + + /* this is for rombug remote only, to get the text relocation by + using link command */ + p = strrchr(name, '/'); + if (p != NULL) p++; + else p = name; + + target_link(p, &text_relocation); + + if (text_relocation == (CORE_ADDR)0) + return; + else if (text_relocation == (CORE_ADDR)-1) + symbol_file_add (name, from_tty, (CORE_ADDR)0, 1, mapped, readno +w); + else + symbol_file_add (name, from_tty, (CORE_ADDR)text_relocation, 0, +mapped, readnow); + set_initial_language (); } argv++; } @@ -684,25 +704,6 @@ symbol_file_command (args, from_tty) { error ("no symbol file name was specified"); } - else - { - char *p; - - /* If target_link can find out where the file is, - more power to it. */ - p = strrchr (name, '/'); - if (p != NULL) p++; - else p = name; - - target_link (p, &text_relocation); - if (text_relocation == (CORE_ADDR)-1) - text_relocation = 0; - - symbol_file_add (name, from_tty, text_relocation, 1, mapped, - readnow); - set_initial_language (); - } - do_cleanups (cleanups); } } |