X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=gdb%2Fremote-udi.c;h=83cc553da9373730350bbbfc775bdb296f3bd7a8;hb=1d9d99f32d861ae85dd59689ada801cc51d3ac91;hp=eef0e1c681a7d819d25bd584a6120e281b99a589;hpb=c5aa993b1f4add48fbdc6cc3117059f616e49875;p=binutils-gdb.git diff --git a/gdb/remote-udi.c b/gdb/remote-udi.c index eef0e1c681a..83cc553da93 100644 --- a/gdb/remote-udi.c +++ b/gdb/remote-udi.c @@ -1,5 +1,6 @@ /* Remote debugging interface for AMD 29k interfaced via UDI, for GDB. - Copyright 1990, 1992, 1995 Free Software Foundation, Inc. + Copyright 1990, 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001 + Free Software Foundation, Inc. Written by Daniel Mann. Contributed by AMD. This file is part of GDB. @@ -35,11 +36,9 @@ #include "defs.h" #include "frame.h" #include "inferior.h" -#include "wait.h" #include "value.h" #include #include -#include #include #include "gdb_string.h" #include "terminal.h" @@ -48,26 +47,27 @@ #include "gdbcmd.h" #include "bfd.h" #include "gdbcore.h" /* For download function */ +#include "regcache.h" /* access the register store directly, without going through the normal handler functions. This avoids an extra data copy. */ extern int stop_soon_quietly; /* for wait_for_inferior */ extern struct value *call_function_by_hand (); -static void udi_resume PARAMS ((int pid, int step, enum target_signal sig)); -static void udi_fetch_registers PARAMS ((int regno)); -static void udi_load PARAMS ((char *args, int from_tty)); -static void fetch_register PARAMS ((int regno)); -static void udi_store_registers PARAMS ((int regno)); -static int store_register PARAMS ((int regno)); -static int regnum_to_srnum PARAMS ((int regno)); -static void udi_close PARAMS ((int quitting)); -static CPUSpace udi_memory_space PARAMS ((CORE_ADDR addr)); -static int udi_write_inferior_memory PARAMS ((CORE_ADDR memaddr, char *myaddr, - int len)); -static int udi_read_inferior_memory PARAMS ((CORE_ADDR memaddr, char *myaddr, - int len)); -static void download PARAMS ((char *load_arg_string, int from_tty)); +static void udi_resume (ptid_t ptid, int step, enum target_signal sig); +static void udi_fetch_registers (int regno); +static void udi_load (char *args, int from_tty); +static void fetch_register (int regno); +static void udi_store_registers (int regno); +static int store_register (int regno); +static int regnum_to_srnum (int regno); +static void udi_close (int quitting); +static CPUSpace udi_memory_space (CORE_ADDR addr); +static int udi_write_inferior_memory (CORE_ADDR memaddr, char *myaddr, + int len); +static int udi_read_inferior_memory (CORE_ADDR memaddr, char *myaddr, + int len); +static void download (char *load_arg_string, int from_tty); char CoffFileName[100] = ""; #define FREEZE_MODE (read_register(CPS_REGNUM) & 0x400) @@ -124,17 +124,14 @@ static char *prog_name = NULL; user types "run" after having attached. */ static void -udi_create_inferior (execfile, args, env) - char *execfile; - char *args; - char **env; +udi_create_inferior (char *execfile, char *args, char **env) { char *args1; if (execfile) { if (prog_name != NULL) - free (prog_name); + xfree (prog_name); prog_name = savestring (execfile, strlen (execfile)); } else if (entry.Offset) @@ -151,7 +148,7 @@ udi_create_inferior (execfile, args, env) entry.Offset = 0; } - inferior_pid = 40000; + inferior_ptid = pid_to_ptid (40000); if (!entry.Offset) download (execfile, 0); @@ -187,7 +184,7 @@ udi_create_inferior (execfile, args, env) } static void -udi_mourn () +udi_mourn (void) { #if 0 /* Requiring "target udi" each time you run is a major pain. I suspect @@ -212,9 +209,7 @@ udi_mourn () /* XXX - need cleanups for udiconnect for various failures!!! */ static void -udi_open (name, from_tty) - char *name; - int from_tty; +udi_open (char *name, int from_tty) { unsigned int prl; char *p; @@ -234,12 +229,12 @@ udi_open (name, from_tty) bkpt_table[cnt].Type = 0; if (udi_config_id) - free (udi_config_id); + xfree (udi_config_id); if (!name) error ("Usage: target udi config_id, where config_id appears in udi_soc file"); - udi_config_id = strdup (strtok (name, " \t")); + udi_config_id = xstrdup (strtok (name, " \t")); if (UDIConnect (udi_config_id, &udi_session_id)) /* FIXME: Should set udi_session_id to -1 here. */ @@ -304,8 +299,8 @@ udi_open (name, from_tty) Use this when you want to detach and do something else with your gdb. */ static void -udi_close (quitting) /*FIXME: how is quitting used */ - int quitting; +udi_close ( /*FIXME: how is quitting used */ + int quitting) { if (udi_session_id < 0) return; @@ -323,7 +318,7 @@ udi_close (quitting) /*FIXME: how is quitting used */ /* Do not try to close udi_session_id again, later in the program. */ udi_session_id = -1; - inferior_pid = 0; + inferior_ptid = null_ptid; printf_filtered (" Ending remote debugging\n"); } @@ -333,9 +328,7 @@ udi_close (quitting) /*FIXME: how is quitting used */ * Upon exiting the process's execution is stopped. */ static void -udi_attach (args, from_tty) - char *args; - int from_tty; +udi_attach (char *args, int from_tty) { UDIResource From; UDIInt32 PC_adds; @@ -366,9 +359,7 @@ udi_attach (args, from_tty) Use this when you want to detach and do something else with your gdb. Leave remote process running (with no breakpoints set). */ static void -udi_detach (args, from_tty) - char *args; - int from_tty; +udi_detach (char *args, int from_tty) { remove_breakpoints (); /* Just in case there were any left in */ @@ -379,7 +370,7 @@ udi_detach (args, from_tty) /* Don't try to UDIDisconnect it again in udi_close, which is called from pop_target. */ udi_session_id = -1; - inferior_pid = 0; + inferior_ptid = null_ptid; pop_target (); @@ -392,9 +383,7 @@ udi_detach (args, from_tty) ** Tell the remote machine to resume. */ static void -udi_resume (pid, step, sig) - int pid, step; - enum target_signal sig; +udi_resume (ptid_t ptid, int step, enum target_signal sig) { UDIError tip_error; UDIUInt32 Steps = 1; @@ -419,10 +408,8 @@ udi_resume (pid, step, sig) ** Wait until the remote machine stops, then return, storing status in STATUS just as `wait' would. */ -static int -udi_wait (pid, status) - int pid; - struct target_waitstatus *status; +static ptid_t +udi_wait (ptid_t ptid, struct target_waitstatus *status) { UDIInt32 MaxTime; UDIPId PId; @@ -597,12 +584,12 @@ udi_wait (pid, status) timeout = old_timeout; /* Restore original timeout value */ immediate_quit = old_immediate_quit; - return inferior_pid; + return inferior_ptid; } #if 0 /* Handy for debugging */ -udi_pc () +udi_pc (void) { UDIResource From; UDIUInt32 *To; @@ -654,8 +641,7 @@ udi_pc () * If regno==-1 then read all the registers. */ static void -udi_fetch_registers (regno) - int regno; +udi_fetch_registers (int regno) { UDIResource From; UDIUInt32 *To; @@ -781,8 +767,7 @@ udi_fetch_registers (regno) */ static void -udi_store_registers (regno) - int regno; +udi_store_registers (int regno) { UDIUInt32 *From; UDIResource To; @@ -907,15 +892,14 @@ udi_store_registers (regno) debugged. */ static void -udi_prepare_to_store () +udi_prepare_to_store (void) { /* Do nothing, since we can store individual regs */ } /********************************************************** TRANSLATE_ADDR */ static CORE_ADDR -translate_addr (addr) - CORE_ADDR addr; +translate_addr (CORE_ADDR addr) { #if defined(ULTRA3) && defined(KERNEL_DEBUGGING) /* Check for a virtual address in the kernel */ @@ -938,11 +922,9 @@ translate_addr (addr) /************************************************* UDI_XFER_INFERIOR_MEMORY */ /* FIXME! Merge these two. */ static int -udi_xfer_inferior_memory (memaddr, myaddr, len, write) - CORE_ADDR memaddr; - char *myaddr; - int len; - int write; +udi_xfer_inferior_memory (CORE_ADDR memaddr, char *myaddr, int len, int write, + struct mem_attrib *attrib ATTRIBUTE_UNUSED, + struct target_ops *target ATTRIBUTE_UNUSED) { memaddr = translate_addr (memaddr); @@ -955,7 +937,7 @@ udi_xfer_inferior_memory (memaddr, myaddr, len, write) /********************************************************** UDI_FILES_INFO */ static void -udi_files_info () +udi_files_info (struct target_ops *target) { printf_unfiltered ("\tAttached to UDI socket to %s", udi_config_id); if (prog_name != NULL) @@ -965,9 +947,7 @@ udi_files_info () /**************************************************** UDI_INSERT_BREAKPOINT */ static int -udi_insert_breakpoint (addr, contents_cache) - CORE_ADDR addr; - char *contents_cache; +udi_insert_breakpoint (CORE_ADDR addr, char *contents_cache) { int cnt; UDIError err; @@ -998,9 +978,7 @@ udi_insert_breakpoint (addr, contents_cache) /**************************************************** UDI_REMOVE_BREAKPOINT */ static int -udi_remove_breakpoint (addr, contents_cache) - CORE_ADDR addr; - char *contents_cache; +udi_remove_breakpoint (CORE_ADDR addr, char *contents_cache) { int cnt; UDIError err; @@ -1022,9 +1000,7 @@ udi_remove_breakpoint (addr, contents_cache) } static void -udi_kill (arg, from_tty) - char *arg; - int from_tty; +udi_kill (void) { #if 0 @@ -1036,7 +1012,7 @@ udi_kill (arg, from_tty) UDIStop (); udi_session_id = -1; - inferior_pid = 0; + inferior_ptid = null_ptid; if (from_tty) printf_unfiltered ("Target has been stopped."); @@ -1056,7 +1032,7 @@ udi_kill (arg, from_tty) /* Do not try to close udi_session_id again, later in the program. */ udi_session_id = -1; - inferior_pid = 0; + inferior_ptid = null_ptid; } /* @@ -1076,9 +1052,7 @@ udi_kill (arg, from_tty) */ static void -download (load_arg_string, from_tty) - char *load_arg_string; - int from_tty; +download (char *load_arg_string, int from_tty) { #define DEFAULT_MEM_STACK_SIZE 0x6000 #define DEFAULT_REG_STACK_SIZE 0x2000 @@ -1108,7 +1082,7 @@ download (load_arg_string, from_tty) error ("Must specify at least a file name with the load command"); filename = tilde_expand (filename); - make_cleanup ((make_cleanup_func) free, filename); + make_cleanup (xfree, filename); while (token = strtok (NULL, " \t")) { @@ -1162,7 +1136,7 @@ download (load_arg_string, from_tty) /* FIXME: should be checking for errors from bfd_close (for one thing, on error it does not free all the storage associated with the bfd). */ - make_cleanup ((make_cleanup_func) bfd_close, pbfd); + make_cleanup_bfd_close (pbfd); QUIT; immediate_quit++; @@ -1307,16 +1281,14 @@ download (load_arg_string, from_tty) /* Function to download an image into the remote target. */ static void -udi_load (args, from_tty) - char *args; - int from_tty; +udi_load (char *args, int from_tty) { download (args, from_tty); /* As a convenience, pick up any symbol info that is in the program being loaded. Note that we assume that the program is the``mainline''; if this is not always true, then this code will need to be augmented. */ - symbol_file_add (strtok (args, " \t"), from_tty, 0, 1, 0, 0, 0, 0); + symbol_file_add (strtok (args, " \t"), from_tty, NULL, 1, 0); /* Getting new symbols may change our opinion about what is frameless. */ @@ -1327,10 +1299,7 @@ udi_load (args, from_tty) ** Copy LEN bytes of data from debugger memory at MYADDR to inferior's memory at MEMADDR. Returns number of bytes written. */ static int -udi_write_inferior_memory (memaddr, myaddr, len) - CORE_ADDR memaddr; - char *myaddr; - int len; +udi_write_inferior_memory (CORE_ADDR memaddr, char *myaddr, int len) { int nwritten = 0; UDIUInt32 *From; @@ -1367,10 +1336,7 @@ udi_write_inferior_memory (memaddr, myaddr, len) ** Read LEN bytes from inferior memory at MEMADDR. Put the result at debugger address MYADDR. Returns number of bytes read. */ static int -udi_read_inferior_memory (memaddr, myaddr, len) - CORE_ADDR memaddr; - char *myaddr; - int len; +udi_read_inferior_memory (CORE_ADDR memaddr, char *myaddr, int len) { int nread = 0; UDIResource From; @@ -1406,8 +1372,7 @@ udi_read_inferior_memory (memaddr, myaddr, len) /********************************************************************* WARNING */ -udi_warning (num) - int num; +udi_warning (int num) { error ("ERROR while loading program into remote TIP: $d\n", num); } @@ -1418,8 +1383,7 @@ udi_warning (num) * Returns 0/-1 on success/failure. */ static void -fetch_register (regno) - int regno; +fetch_register (int regno) { UDIResource From; UDIUInt32 To; @@ -1483,8 +1447,7 @@ fetch_register (regno) * Returns 0/-1 on success/failure. */ static int -store_register (regno) - int regno; +store_register (int regno) { int result; UDIUInt32 From; @@ -1566,8 +1529,7 @@ store_register (regno) * Convert a gdb special register number to a 29000 special register number. */ static int -regnum_to_srnum (regno) - int regno; +regnum_to_srnum (int regno) { switch (regno) { @@ -1636,8 +1598,7 @@ regnum_to_srnum (regno) * FIXME: Doesn't know anything about I_CACHE/D_CACHE. */ static CPUSpace -udi_memory_space (addr) - CORE_ADDR addr; +udi_memory_space (CORE_ADDR addr) { UDIUInt32 tstart = IMemStart; UDIUInt32 tend = tstart + IMemSize; @@ -1666,19 +1627,18 @@ udi_memory_space (addr) */ void -convert16 () +convert16 (void) {; } void -convert32 () +convert32 (void) {; } -GDB_FILE *EchoFile = 0; /* used for debugging */ +struct ui_file *EchoFile = 0; /* used for debugging */ int QuietMode = 0; /* used for debugging */ #ifdef NO_HIF_SUPPORT -service_HIF (msg) - union msg_t *msg; +service_HIF (union msg_t *msg) { return (0); /* Emulate a failure */ } @@ -1755,7 +1715,7 @@ To connect using a local connection to the \"tip.exe\" program which is\n\ }; void -_initialize_remote_udi () +_initialize_remote_udi (void) { init_udi_ops (); add_target (&udi_ops);