* 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.
This commit is contained in:
Stu Grossman 1992-11-18 22:51:58 +00:00
parent 2e66cf7d6d
commit b5a3d2aac6
3 changed files with 116 additions and 47 deletions

View File

@ -462,6 +462,8 @@ UDIBool Terminate;
sprintf(dfe_errmsg, "DFE-ipc WARNING: socket shutdown failed"); sprintf(dfe_errmsg, "DFE-ipc WARNING: socket shutdown failed");
return UDIErrorIPCInternal; return UDIErrorIPCInternal;
} }
else
session[Session].soc_con_p->in_use = 0;
udrs->udr_op = UDR_DECODE; /* receive all "out" parameters */ udrs->udr_op = UDR_DECODE; /* receive all "out" parameters */
udr_UDIError(udrs, &dfe_errno); /* get any TIP error */ udr_UDIError(udrs, &dfe_errno); /* get any TIP error */
@ -501,6 +503,8 @@ UDIInt32 Signal;
sprintf(dfe_errmsg, "DFE-ipc WARNING: socket shutdown failed"); sprintf(dfe_errmsg, "DFE-ipc WARNING: socket shutdown failed");
return UDIErrorIPCInternal; return UDIErrorIPCInternal;
} }
else
session[Session].soc_con_p->in_use = 0;
udrs->udr_op = UDR_DECODE; /* receive all "out" parameters */ udrs->udr_op = UDR_DECODE; /* receive all "out" parameters */
udr_UDIError(udrs, &dfe_errno); /* get any TIP error */ udr_UDIError(udrs, &dfe_errno); /* get any TIP error */

View File

@ -173,6 +173,7 @@ CORE_ADDR step_range_end; /* Exclusive */
FRAME_ADDR step_frame_address; FRAME_ADDR step_frame_address;
/* 1 means step over all subroutine calls. /* 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. */ -1 means step over calls to undebuggable functions. */
int step_over_calls; int step_over_calls;
@ -235,8 +236,12 @@ Start it from the beginning? "))
if (from_tty) if (from_tty)
{ {
printf_filtered ("Starting program: %s %s\n", puts_filtered("Starting program: ");
exec_file? exec_file: "", inferior_args); if (exec_file)
puts_filtered(exec_file);
puts_filtered(" ");
puts_filtered(inferior_args);
puts_filtered("\n");
fflush (stdout); fflush (stdout);
} }
@ -773,7 +778,9 @@ set_environment_command (arg, from_tty)
/* Take the smaller of the two. If there was space before the /* Take the smaller of the two. If there was space before the
"=", they will be the same right now. */ "=", 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) else if (val != 0 && p == 0)
p = val; p = val;
@ -837,8 +844,9 @@ path_info (args, from_tty)
char *args; char *args;
int from_tty; int from_tty;
{ {
printf_filtered ("Executable and object file path: %s\n", puts_filtered ("Executable and object file path: ");
get_in_environ (inferior_environ, path_var_name)); 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. */ /* Add zero or more directories to the front of the execution path. */
@ -922,7 +930,7 @@ do_registers_info (regnum, fpregs)
continue; 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 virtual format is floating, print it that way, and in raw hex. */
if (TYPE_CODE (REGISTER_VIRTUAL_TYPE (i)) == TYPE_CODE_FLT if (TYPE_CODE (REGISTER_VIRTUAL_TYPE (i)) == TYPE_CODE_FLT
@ -977,30 +985,40 @@ registers_info (addr_exp, fpregs)
int fpregs; int fpregs;
{ {
int regnum; int regnum;
register char *end;
if (!target_has_registers) if (!target_has_registers)
error ("The program has no registers now."); error ("The program has no registers now.");
if (addr_exp) if (!addr_exp)
{ {
if (*addr_exp >= '0' && *addr_exp <= '9') DO_REGISTERS_INFO(-1, fpregs);
regnum = atoi (addr_exp); return;
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);
}
} }
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 static void
@ -1030,19 +1048,49 @@ nofp_registers_info (addr_exp, from_tty)
*/ */
/* /*
* attach_command -- attach_command --
* takes a program started up outside of gdb and ``attaches'' to it. 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. This stops it cold in its tracks and allows us to start debugging it.
* For this to work, we must be able to send the process a and wait for the trace-trap that results from attaching. */
* signal and we must have the same effective uid as the program.
*/
void void
attach_command (args, from_tty) attach_command (args, from_tty)
char *args; char *args;
int from_tty; int from_tty;
{ {
dont_repeat (); /* Not for the faint of heart */ 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); 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 #endif
} }
struct cmd_list_element *unsetlist = NULL;
/* ARGSUSED */ /* ARGSUSED */
static void static void
unset_command (args, from_tty) unset_command (args, from_tty)

View File

@ -238,6 +238,11 @@ udi_open (name, from_tty)
target_preopen(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) if (udi_config_id)
free (udi_config_id); free (udi_config_id);
@ -391,6 +396,7 @@ udi_attach (args, from_tty)
UDISizeT Size = 4; UDISizeT Size = 4;
UDICount CountDone; UDICount CountDone;
UDIBool HostEndian = 0; UDIBool HostEndian = 0;
UDIError err;
if (udi_session_id < 0) if (udi_session_id < 0)
error ("UDI connection not opened yet, use the 'target udi' command.\n"); error ("UDI connection not opened yet, use the 'target udi' command.\n");
@ -401,7 +407,7 @@ udi_attach (args, from_tty)
UDIStop(); UDIStop();
From.Space = 11; From.Space = 11;
From.Offset = UDI29KSpecialRegs; 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"); error ("UDIRead failed in udi_attach");
printf ("Remote process is now halted, pc1 = 0x%x.\n", PC_adds); printf ("Remote process is now halted, pc1 = 0x%x.\n", PC_adds);
} }
@ -612,6 +618,7 @@ int regno;
UDISizeT Size = 4; UDISizeT Size = 4;
UDICount CountDone; UDICount CountDone;
UDIBool HostEndian = 0; UDIBool HostEndian = 0;
UDIError err;
int i; int i;
if (regno >= 0) { if (regno >= 0) {
@ -625,7 +632,7 @@ int regno;
From.Offset = 1; From.Offset = 1;
To = (UDIUInt32 *)&registers[4 * GR1_REGNUM]; To = (UDIUInt32 *)&registers[4 * GR1_REGNUM];
Count = 1; 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"); error("UDIRead() failed in udi_fetch_registers");
register_valid[GR1_REGNUM] = 1; register_valid[GR1_REGNUM] = 1;
@ -638,7 +645,7 @@ int regno;
From.Offset = 64; From.Offset = 64;
To = (UDIUInt32 *)&registers[4 * GR64_REGNUM]; To = (UDIUInt32 *)&registers[4 * GR64_REGNUM];
Count = 32; 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"); error("UDIRead() failed in udi_fetch_registers");
for (i = GR64_REGNUM; i < GR64_REGNUM + 32; i++) for (i = GR64_REGNUM; i < GR64_REGNUM + 32; i++)
@ -652,7 +659,7 @@ int regno;
From.Offset = 96; From.Offset = 96;
To = (UDIUInt32 *)&registers[4 * GR96_REGNUM]; To = (UDIUInt32 *)&registers[4 * GR96_REGNUM];
Count = 32; 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"); error("UDIRead() failed in udi_fetch_registers");
for (i = GR96_REGNUM; i < GR96_REGNUM + 32; i++) for (i = GR96_REGNUM; i < GR96_REGNUM + 32; i++)
@ -664,7 +671,7 @@ int regno;
From.Offset = 0; From.Offset = 0;
To = (UDIUInt32 *)&registers[4 * LR0_REGNUM]; To = (UDIUInt32 *)&registers[4 * LR0_REGNUM];
Count = 128; 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"); error("UDIRead() failed in udi_fetch_registers");
for (i = LR0_REGNUM; i < LR0_REGNUM + 128; i++) for (i = LR0_REGNUM; i < LR0_REGNUM + 128; i++)
@ -676,7 +683,7 @@ int regno;
From.Offset = 0; From.Offset = 0;
To = (UDIUInt32 *)&registers[4 * SR_REGNUM(0)]; To = (UDIUInt32 *)&registers[4 * SR_REGNUM(0)];
Count = 15; 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"); error("UDIRead() failed in udi_fetch_registers");
for (i = SR_REGNUM(0); i < SR_REGNUM(0) + 15; i++) for (i = SR_REGNUM(0); i < SR_REGNUM(0) + 15; i++)
@ -693,7 +700,7 @@ int regno;
From.Offset = 128; From.Offset = 128;
To = (UDIUInt32 *)&registers[4 * SR_REGNUM(128)]; To = (UDIUInt32 *)&registers[4 * SR_REGNUM(128)];
Count = 135-128 + 1; 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"); error("UDIRead() failed in udi_fetch_registers");
for (i = SR_REGNUM(128); i < SR_REGNUM(128) + 135-128+1; i++) 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 */ else /* BSS */
{ {
UDIResource From; UDIResource From;
char zero = 0; unsigned long zero = 0;
/* Write a zero byte at the vma */ /* Write a zero byte at the vma */
err = UDIWrite ((UDIHostMemPtr)&zero, /* From */ err = UDIWrite ((UDIHostMemPtr)&zero, /* From */
To, /* To */ To, /* To */
(UDICount)1, /* Count */ (UDICount)1, /* Count */
(UDISizeT)1, /* Size */ (UDISizeT)4, /* Size */
&Count, /* CountDone */ &Count, /* CountDone */
(UDIBool)0); /* HostEndian */ (UDIBool)0); /* HostEndian */
if (err) if (err)
error ("UDIWrite failed, error = %d", err); error ("UDIWrite failed, error = %d", err);
From = To; From = To;
To.Offset++; To.Offset+=4;
/* Now, duplicate it for the length of the BSS */ /* Now, duplicate it for the length of the BSS */
err = UDICopy (From, /* From */ err = UDICopy (From, /* From */
To, /* To */ To, /* To */
(UDICount)section_size - 1, /* Count */ (UDICount)(section_size/4 - 1), /* Count */
(UDISizeT)1, /* Size */ (UDISizeT)4, /* Size */
&Count, /* CountDone */ &Count, /* CountDone */
(UDIBool)1); /* Direction */ (UDIBool)1); /* Direction */
if (err) 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; UDISizeT Size = 1;
UDICount CountDone = 0; UDICount CountDone = 0;
UDIBool HostEndian = 0; UDIBool HostEndian = 0;
UDIError err;
From.Space = udi_memory_space(memaddr); From.Space = udi_memory_space(memaddr);
To = (UDIUInt32*)myaddr; To = (UDIUInt32*)myaddr;
@ -1267,8 +1285,8 @@ udi_read_inferior_memory(memaddr, myaddr, len)
{ Count = len - nread; { Count = len - nread;
if (Count > MAXDATA) Count = MAXDATA; if (Count > MAXDATA) Count = MAXDATA;
From.Offset = memaddr + nread; From.Offset = memaddr + nread;
if(UDIRead(From, To, Count, Size, &CountDone, HostEndian)) if(err = UDIRead(From, To, Count, Size, &CountDone, HostEndian))
{ error("UDIWrite() failed in udi_read_inferrior_memory"); { error("UDIRead() failed in udi_read_inferrior_memory");
break; break;
} }
else else
@ -1302,6 +1320,7 @@ fetch_register (regno)
UDISizeT Size = 4; UDISizeT Size = 4;
UDICount CountDone; UDICount CountDone;
UDIBool HostEndian = 0; UDIBool HostEndian = 0;
UDIError err;
int result; int result;
if (regno == GR1_REGNUM) if (regno == GR1_REGNUM)
@ -1342,7 +1361,7 @@ fetch_register (regno)
From.Offset = regnum_to_srnum(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"); error("UDIRead() failed in udi_fetch_registers");
supply_register(regno, (char *) &To); supply_register(regno, (char *) &To);