From b5a3d2aac6f222e99d007f0f8276958128901d3e Mon Sep 17 00:00:00 2001 From: Stu Grossman Date: Wed, 18 Nov 1992 22:51:58 +0000 Subject: [PATCH] * infcmd.c (set_environment_command): Make set env FOO x=y work. Fix from maj@lucid.com. * remote-udi.c (udi_open): Reset vars so that user can re-run programs without leaving GDB. * (many routines): Slightly improve error handling. * (download): Zero out BSS by longs instead of bytes to avoid timeouts in real hardware. * 29k-share/udi/udip2soc.c (UDIDisconnect, UDIKill): Indicate that connection is no longer in use after shutdown() of socket. This keeps GDB from dying of a SIGPIPE when you issue multiple `target udi' commands. --- gdb/29k-share/udi/udip2soc.c | 4 ++ gdb/infcmd.c | 108 +++++++++++++++++++++++++---------- gdb/remote-udi.c | 51 +++++++++++------ 3 files changed, 116 insertions(+), 47 deletions(-) diff --git a/gdb/29k-share/udi/udip2soc.c b/gdb/29k-share/udi/udip2soc.c index ff2d3439f91..cadc074ff84 100644 --- a/gdb/29k-share/udi/udip2soc.c +++ b/gdb/29k-share/udi/udip2soc.c @@ -462,6 +462,8 @@ UDIBool Terminate; sprintf(dfe_errmsg, "DFE-ipc WARNING: socket shutdown failed"); return UDIErrorIPCInternal; } + else + session[Session].soc_con_p->in_use = 0; udrs->udr_op = UDR_DECODE; /* receive all "out" parameters */ udr_UDIError(udrs, &dfe_errno); /* get any TIP error */ @@ -501,6 +503,8 @@ UDIInt32 Signal; sprintf(dfe_errmsg, "DFE-ipc WARNING: socket shutdown failed"); return UDIErrorIPCInternal; } + else + session[Session].soc_con_p->in_use = 0; udrs->udr_op = UDR_DECODE; /* receive all "out" parameters */ udr_UDIError(udrs, &dfe_errno); /* get any TIP error */ diff --git a/gdb/infcmd.c b/gdb/infcmd.c index 8f5ba51c792..4230b66e21a 100644 --- a/gdb/infcmd.c +++ b/gdb/infcmd.c @@ -173,6 +173,7 @@ CORE_ADDR step_range_end; /* Exclusive */ FRAME_ADDR step_frame_address; /* 1 means step over all subroutine calls. + 0 means don't step over calls (used by stepi). -1 means step over calls to undebuggable functions. */ int step_over_calls; @@ -235,8 +236,12 @@ Start it from the beginning? ")) if (from_tty) { - printf_filtered ("Starting program: %s %s\n", - exec_file? exec_file: "", inferior_args); + puts_filtered("Starting program: "); + if (exec_file) + puts_filtered(exec_file); + puts_filtered(" "); + puts_filtered(inferior_args); + puts_filtered("\n"); fflush (stdout); } @@ -773,7 +778,9 @@ set_environment_command (arg, from_tty) /* Take the smaller of the two. If there was space before the "=", they will be the same right now. */ - p = arg + min (p - arg, val - arg); + + if (val < p) + p = val - 1; } else if (val != 0 && p == 0) p = val; @@ -837,8 +844,9 @@ path_info (args, from_tty) char *args; int from_tty; { - printf_filtered ("Executable and object file path: %s\n", - get_in_environ (inferior_environ, path_var_name)); + puts_filtered ("Executable and object file path: "); + puts_filtered (get_in_environ (inferior_environ, path_var_name)); + puts_filtered ("\n"); } /* Add zero or more directories to the front of the execution path. */ @@ -922,7 +930,7 @@ do_registers_info (regnum, fpregs) continue; } - target_convert_to_virtual (i, raw_buffer, virtual_buffer); + REGISTER_CONVERT_TO_VIRTUAL (i, raw_buffer, virtual_buffer); /* If virtual format is floating, print it that way, and in raw hex. */ if (TYPE_CODE (REGISTER_VIRTUAL_TYPE (i)) == TYPE_CODE_FLT @@ -977,30 +985,40 @@ registers_info (addr_exp, fpregs) int fpregs; { int regnum; + register char *end; if (!target_has_registers) error ("The program has no registers now."); - if (addr_exp) + if (!addr_exp) { - if (*addr_exp >= '0' && *addr_exp <= '9') - regnum = atoi (addr_exp); - else - { - register char *p = addr_exp; - if (p[0] == '$') - p++; - for (regnum = 0; regnum < NUM_REGS; regnum++) - if (!strcmp (p, reg_names[regnum])) - break; - if (regnum == NUM_REGS) - error ("%s: invalid register name.", addr_exp); - } + DO_REGISTERS_INFO(-1, fpregs); + return; } - else - regnum = -1; - DO_REGISTERS_INFO(regnum, fpregs); + do + { + if (addr_exp[0] == '$') + addr_exp++; + end = addr_exp; + while (*end != '\0' && *end != ' ' && *end != '\t') + ++end; + for (regnum = 0; regnum < NUM_REGS; regnum++) + if (!strncmp (addr_exp, reg_names[regnum], end - addr_exp) + && strlen (reg_names[regnum]) == end - addr_exp) + goto found; + if (*addr_exp >= '0' && *addr_exp <= '9') + regnum = atoi (addr_exp); /* Take a number */ + if (regnum >= NUM_REGS) /* Bad name, or bad number */ + error ("%.*s: invalid register", end - addr_exp, addr_exp); + +found: + DO_REGISTERS_INFO(regnum, fpregs); + + addr_exp = end; + while (*addr_exp == ' ' || *addr_exp == '\t') + ++addr_exp; + } while (*addr_exp != '\0'); } static void @@ -1030,19 +1048,49 @@ nofp_registers_info (addr_exp, from_tty) */ /* - * attach_command -- - * takes a program started up outside of gdb and ``attaches'' to it. - * This stops it cold in its tracks and allows us to start tracing it. - * For this to work, we must be able to send the process a - * signal and we must have the same effective uid as the program. - */ + attach_command -- + takes a program started up outside of gdb and ``attaches'' to it. + This stops it cold in its tracks and allows us to start debugging it. + and wait for the trace-trap that results from attaching. */ + void attach_command (args, from_tty) char *args; int from_tty; { dont_repeat (); /* Not for the faint of heart */ + + if (target_has_execution) + { + if (query ("A program is being debugged already. Kill it? ")) + target_kill (); + else + error ("Inferior not killed."); + } + target_attach (args, from_tty); + + /* Set up the "saved terminal modes" of the inferior + based on what modes we are starting it with. */ + target_terminal_init (); + + /* Install inferior's terminal modes. */ + target_terminal_inferior (); + + /* Set up execution context to know that we should return from + wait_for_inferior as soon as the target reports a stop. */ + init_wait_for_inferior (); + clear_proceed_status (); + stop_soon_quietly = 1; + + wait_for_inferior (); + +#ifdef SOLIB_ADD + /* Add shared library symbols from the newly attached process, if any. */ + SOLIB_ADD ((char *)0, from_tty, (struct target_ops *)0); +#endif + + normal_stop (); } /* @@ -1078,8 +1126,6 @@ float_info (addr_exp, from_tty) #endif } -struct cmd_list_element *unsetlist = NULL; - /* ARGSUSED */ static void unset_command (args, from_tty) diff --git a/gdb/remote-udi.c b/gdb/remote-udi.c index 681854c0f49..9615112c8e6 100644 --- a/gdb/remote-udi.c +++ b/gdb/remote-udi.c @@ -238,6 +238,11 @@ udi_open (name, from_tty) target_preopen(from_tty); + entry.Offset = 0; + + for (cnt = 0; cnt < BKPT_TABLE_SIZE; cnt++) + bkpt_table[cnt].Type = 0; + if (udi_config_id) free (udi_config_id); @@ -391,6 +396,7 @@ udi_attach (args, from_tty) UDISizeT Size = 4; UDICount CountDone; UDIBool HostEndian = 0; + UDIError err; if (udi_session_id < 0) error ("UDI connection not opened yet, use the 'target udi' command.\n"); @@ -401,7 +407,7 @@ udi_attach (args, from_tty) UDIStop(); From.Space = 11; From.Offset = UDI29KSpecialRegs; - if(UDIRead(From, &PC_adds, Count, Size, &CountDone, HostEndian)) + if (err = UDIRead(From, &PC_adds, Count, Size, &CountDone, HostEndian)) error ("UDIRead failed in udi_attach"); printf ("Remote process is now halted, pc1 = 0x%x.\n", PC_adds); } @@ -612,6 +618,7 @@ int regno; UDISizeT Size = 4; UDICount CountDone; UDIBool HostEndian = 0; + UDIError err; int i; if (regno >= 0) { @@ -625,7 +632,7 @@ int regno; From.Offset = 1; To = (UDIUInt32 *)®isters[4 * GR1_REGNUM]; Count = 1; - if (UDIRead(From, To, Count, Size, &CountDone, HostEndian)) + if (err = UDIRead(From, To, Count, Size, &CountDone, HostEndian)) error("UDIRead() failed in udi_fetch_registers"); register_valid[GR1_REGNUM] = 1; @@ -638,7 +645,7 @@ int regno; From.Offset = 64; To = (UDIUInt32 *)®isters[4 * GR64_REGNUM]; Count = 32; - if (UDIRead(From, To, Count, Size, &CountDone, HostEndian)) + if (err = UDIRead(From, To, Count, Size, &CountDone, HostEndian)) error("UDIRead() failed in udi_fetch_registers"); for (i = GR64_REGNUM; i < GR64_REGNUM + 32; i++) @@ -652,7 +659,7 @@ int regno; From.Offset = 96; To = (UDIUInt32 *)®isters[4 * GR96_REGNUM]; Count = 32; - if (UDIRead(From, To, Count, Size, &CountDone, HostEndian)) + if (err = UDIRead(From, To, Count, Size, &CountDone, HostEndian)) error("UDIRead() failed in udi_fetch_registers"); for (i = GR96_REGNUM; i < GR96_REGNUM + 32; i++) @@ -664,7 +671,7 @@ int regno; From.Offset = 0; To = (UDIUInt32 *)®isters[4 * LR0_REGNUM]; Count = 128; - if (UDIRead(From, To, Count, Size, &CountDone, HostEndian)) + if (err = UDIRead(From, To, Count, Size, &CountDone, HostEndian)) error("UDIRead() failed in udi_fetch_registers"); for (i = LR0_REGNUM; i < LR0_REGNUM + 128; i++) @@ -676,7 +683,7 @@ int regno; From.Offset = 0; To = (UDIUInt32 *)®isters[4 * SR_REGNUM(0)]; Count = 15; - if (UDIRead(From, To, Count, Size, &CountDone, HostEndian)) + if (err = UDIRead(From, To, Count, Size, &CountDone, HostEndian)) error("UDIRead() failed in udi_fetch_registers"); for (i = SR_REGNUM(0); i < SR_REGNUM(0) + 15; i++) @@ -693,7 +700,7 @@ int regno; From.Offset = 128; To = (UDIUInt32 *)®isters[4 * SR_REGNUM(128)]; Count = 135-128 + 1; - if (UDIRead(From, To, Count, Size, &CountDone, HostEndian)) + if (err = UDIRead(From, To, Count, Size, &CountDone, HostEndian)) error("UDIRead() failed in udi_fetch_registers"); for (i = SR_REGNUM(128); i < SR_REGNUM(128) + 135-128+1; i++) @@ -1158,30 +1165,40 @@ download(load_arg_string, from_tty) else /* BSS */ { UDIResource From; - char zero = 0; + unsigned long zero = 0; /* Write a zero byte at the vma */ err = UDIWrite ((UDIHostMemPtr)&zero, /* From */ To, /* To */ (UDICount)1, /* Count */ - (UDISizeT)1, /* Size */ + (UDISizeT)4, /* Size */ &Count, /* CountDone */ (UDIBool)0); /* HostEndian */ if (err) error ("UDIWrite failed, error = %d", err); From = To; - To.Offset++; + To.Offset+=4; /* Now, duplicate it for the length of the BSS */ err = UDICopy (From, /* From */ To, /* To */ - (UDICount)section_size - 1, /* Count */ - (UDISizeT)1, /* Size */ + (UDICount)(section_size/4 - 1), /* Count */ + (UDISizeT)4, /* Size */ &Count, /* CountDone */ (UDIBool)1); /* Direction */ if (err) - error ("UDICopy failed, error = %d", err); + { + char message[100]; + int xerr; + + xerr = UDIGetErrorMsg(err, 100, message, &Count); + if (!xerr) + fprintf (stderr, "Error is %s\n", message); + else + fprintf (stderr, "xerr is %d\n", xerr); + error ("UDICopy failed, error = %d", err); + } } } @@ -1259,6 +1276,7 @@ udi_read_inferior_memory(memaddr, myaddr, len) UDISizeT Size = 1; UDICount CountDone = 0; UDIBool HostEndian = 0; + UDIError err; From.Space = udi_memory_space(memaddr); To = (UDIUInt32*)myaddr; @@ -1267,8 +1285,8 @@ udi_read_inferior_memory(memaddr, myaddr, len) { Count = len - nread; if (Count > MAXDATA) Count = MAXDATA; From.Offset = memaddr + nread; - if(UDIRead(From, To, Count, Size, &CountDone, HostEndian)) - { error("UDIWrite() failed in udi_read_inferrior_memory"); + if(err = UDIRead(From, To, Count, Size, &CountDone, HostEndian)) + { error("UDIRead() failed in udi_read_inferrior_memory"); break; } else @@ -1302,6 +1320,7 @@ fetch_register (regno) UDISizeT Size = 4; UDICount CountDone; UDIBool HostEndian = 0; + UDIError err; int result; if (regno == GR1_REGNUM) @@ -1342,7 +1361,7 @@ fetch_register (regno) From.Offset = regnum_to_srnum(regno); } - if (UDIRead(From, &To, Count, Size, &CountDone, HostEndian)) + if (err = UDIRead(From, &To, Count, Size, &CountDone, HostEndian)) error("UDIRead() failed in udi_fetch_registers"); supply_register(regno, (char *) &To); -- 2.30.2