+2000-12-14 Kevin Buettner <kevinb@redhat.com>
2000-12-14 J.T. Conklin <jtc@redback.com>
* configure.tgt (hppa*-*-bsd*, hppa*-*-osf*, m68*-*-sunos4*,
else
linked_proc_desc_table = pi_ptr->next;
- free (pi_ptr);
+ xfree (pi_ptr);
}
}
\f
-/* Low level interface to ptrace, for GDB when running under m68k SVR2 Unix
- on Altos 3068. Report bugs to Jyrki Kuoppala <jkp@cs.hut.fi>
- Copyright (C) 1989, 1991 Free Software Foundation, Inc.
-
-This file is part of GDB.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include "defs.h"
-#include "frame.h"
-#include "inferior.h"
-
-#ifdef USG
-#include <sys/types.h>
-#endif
-
-#include <sys/param.h>
-#include <sys/dir.h>
-#include <signal.h>
-#include <sys/ioctl.h>
-#include <fcntl.h>
-#ifdef USG
-#include <sys/page.h>
-#ifdef ALTOS
-#include <sys/net.h>
-#include <errno.h>
-#endif
-#endif
-
-#include "gdbcore.h"
-#include <sys/user.h> /* After a.out.h */
-#include <sys/file.h>
-#include "gdb_stat.h"
-
-\f
-/* Work with core dump and executable files, for GDB.
- This code would be in corefile.c if it weren't machine-dependent. */
-
-void
-core_file_command (filename, from_tty)
- char *filename;
- int from_tty;
-{
- int val;
- extern char registers[];
-
- /* Discard all vestiges of any previous core file
- and mark data and stack spaces as empty. */
-
- if (corefile)
- free (corefile);
- corefile = 0;
-
- if (corechan >= 0)
- close (corechan);
- corechan = -1;
-
- data_start = 0;
- data_end = 0;
- stack_start = STACK_END_ADDR;
- stack_end = STACK_END_ADDR;
-
- /* Now, if a new core file was specified, open it and digest it. */
-
- if (filename)
- {
- filename = tilde_expand (filename);
- make_cleanup (free, filename);
-
- if (have_inferior_p ())
- error ("To look at a core file, you must kill the program with \"kill\".");
- corechan = open (filename, O_RDONLY, 0);
- if (corechan < 0)
- perror_with_name (filename);
- /* 4.2-style (and perhaps also sysV-style) core dump file. */
- {
- struct user u;
-
- unsigned int reg_offset;
-
- val = myread (corechan, &u, sizeof u);
- if (val < 0)
- perror_with_name ("Not a core file: reading upage");
- if (val != sizeof u)
- error ("Not a core file: could only read %d bytes", val);
- data_start = exec_data_start;
-
-#if !defined (NBPG)
-#define NBPG NBPP
-#endif
-#if !defined (UPAGES)
-#define UPAGES USIZE
-#endif
-
- data_end = data_start + NBPG * u.u_dsize;
- stack_start = stack_end - NBPG * u.u_ssize;
- data_offset = NBPG * UPAGES + exec_data_start % NBPG /* Not sure about this //jkp */;
- stack_offset = NBPG * (UPAGES + u.u_dsize);
-
- /* Some machines put an absolute address in here and some put
- the offset in the upage of the regs. */
- reg_offset = (int) u.u_state;
- if (reg_offset > NBPG * UPAGES)
- reg_offset -= KERNEL_U_ADDR;
-
- memcpy (&core_aouthdr, &u.u_exdata, sizeof (AOUTHDR));
- printf_unfiltered ("Core file is from \"%s\".\n", u.u_comm);
-
- /* I don't know where to find this info.
- So, for now, mark it as not available. */
- N_SET_MAGIC (core_aouthdr, 0);
-
- /* Read the register values out of the core file and store
- them where `read_register' will find them. */
-
- {
- register int regno;
-
- for (regno = 0; regno < NUM_REGS; regno++)
- {
- char buf[MAX_REGISTER_RAW_SIZE];
-
- val = lseek (corechan, register_addr (regno, reg_offset), 0);
- if (val < 0
- || (val = myread (corechan, buf, sizeof buf)) < 0)
- {
- char * buffer = (char *) alloca (strlen (REGISTER_NAME (regno))
- + 30);
- strcpy (buffer, "Reading register ");
- strcat (buffer, REGISTER_NAME (regno));
-
- perror_with_name (buffer);
- }
-
- supply_register (regno, buf);
- }
- }
- }
- if (filename[0] == '/')
- corefile = savestring (filename, strlen (filename));
- else
- {
- corefile = concat (current_directory, "/", filename, NULL);
- }
-
- flush_cached_frames ();
- select_frame (get_current_frame (), 0);
- validate_files ();
- }
- else if (from_tty)
- printf_unfiltered ("No core file now.\n");
-}
+/* OBSOLETE /* Low level interface to ptrace, for GDB when running under m68k SVR2 Unix */
+/* OBSOLETE on Altos 3068. Report bugs to Jyrki Kuoppala <jkp@cs.hut.fi> */
+/* OBSOLETE Copyright (C) 1989, 1991 Free Software Foundation, Inc. */
+/* OBSOLETE */
+/* OBSOLETE This file is part of GDB. */
+/* OBSOLETE */
+/* OBSOLETE This program is free software; you can redistribute it and/or modify */
+/* OBSOLETE it under the terms of the GNU General Public License as published by */
+/* OBSOLETE the Free Software Foundation; either version 2 of the License, or */
+/* OBSOLETE (at your option) any later version. */
+/* OBSOLETE */
+/* OBSOLETE This program is distributed in the hope that it will be useful, */
+/* OBSOLETE but WITHOUT ANY WARRANTY; without even the implied warranty of */
+/* OBSOLETE MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
+/* OBSOLETE GNU General Public License for more details. */
+/* OBSOLETE */
+/* OBSOLETE You should have received a copy of the GNU General Public License */
+/* OBSOLETE along with this program; if not, write to the Free Software */
+/* OBSOLETE Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *x/ */
+/* OBSOLETE */
+/* OBSOLETE #include "defs.h" */
+/* OBSOLETE #include "frame.h" */
+/* OBSOLETE #include "inferior.h" */
+/* OBSOLETE */
+/* OBSOLETE #ifdef USG */
+/* OBSOLETE #include <sys/types.h> */
+/* OBSOLETE #endif */
+/* OBSOLETE */
+/* OBSOLETE #include <sys/param.h> */
+/* OBSOLETE #include <sys/dir.h> */
+/* OBSOLETE #include <signal.h> */
+/* OBSOLETE #include <sys/ioctl.h> */
+/* OBSOLETE #include <fcntl.h> */
+/* OBSOLETE #ifdef USG */
+/* OBSOLETE #include <sys/page.h> */
+/* OBSOLETE #ifdef ALTOS */
+/* OBSOLETE #include <sys/net.h> */
+/* OBSOLETE #include <errno.h> */
+/* OBSOLETE #endif */
+/* OBSOLETE #endif */
+/* OBSOLETE */
+/* OBSOLETE #include "gdbcore.h" */
+/* OBSOLETE #include <sys/user.h> /* After a.out.h *x/ */
+/* OBSOLETE #include <sys/file.h> */
+/* OBSOLETE #include "gdb_stat.h" */
+/* OBSOLETE */
+/* OBSOLETE \f */
+/* OBSOLETE /* Work with core dump and executable files, for GDB. */
+/* OBSOLETE This code would be in corefile.c if it weren't machine-dependent. *x/ */
+/* OBSOLETE */
+/* OBSOLETE void */
+/* OBSOLETE core_file_command (filename, from_tty) */
+/* OBSOLETE char *filename; */
+/* OBSOLETE int from_tty; */
+/* OBSOLETE { */
+/* OBSOLETE int val; */
+/* OBSOLETE */
+/* OBSOLETE /* Discard all vestiges of any previous core file */
+/* OBSOLETE and mark data and stack spaces as empty. *x/ */
+/* OBSOLETE */
+/* OBSOLETE if (corefile) */
+/* OBSOLETE xfree (corefile); */
+/* OBSOLETE corefile = 0; */
+/* OBSOLETE */
+/* OBSOLETE if (corechan >= 0) */
+/* OBSOLETE close (corechan); */
+/* OBSOLETE corechan = -1; */
+/* OBSOLETE */
+/* OBSOLETE data_start = 0; */
+/* OBSOLETE data_end = 0; */
+/* OBSOLETE stack_start = STACK_END_ADDR; */
+/* OBSOLETE stack_end = STACK_END_ADDR; */
+/* OBSOLETE */
+/* OBSOLETE /* Now, if a new core file was specified, open it and digest it. *x/ */
+/* OBSOLETE */
+/* OBSOLETE if (filename) */
+/* OBSOLETE { */
+/* OBSOLETE filename = tilde_expand (filename); */
+/* OBSOLETE make_cleanup (xfree, filename); */
+/* OBSOLETE */
+/* OBSOLETE if (have_inferior_p ()) */
+/* OBSOLETE error ("To look at a core file, you must kill the program with \"kill\"."); */
+/* OBSOLETE corechan = open (filename, O_RDONLY, 0); */
+/* OBSOLETE if (corechan < 0) */
+/* OBSOLETE perror_with_name (filename); */
+/* OBSOLETE /* 4.2-style (and perhaps also sysV-style) core dump file. *x/ */
+/* OBSOLETE { */
+/* OBSOLETE struct user u; */
+/* OBSOLETE */
+/* OBSOLETE unsigned int reg_offset; */
+/* OBSOLETE */
+/* OBSOLETE val = myread (corechan, &u, sizeof u); */
+/* OBSOLETE if (val < 0) */
+/* OBSOLETE perror_with_name ("Not a core file: reading upage"); */
+/* OBSOLETE if (val != sizeof u) */
+/* OBSOLETE error ("Not a core file: could only read %d bytes", val); */
+/* OBSOLETE data_start = exec_data_start; */
+/* OBSOLETE */
+/* OBSOLETE #if !defined (NBPG) */
+/* OBSOLETE #define NBPG NBPP */
+/* OBSOLETE #endif */
+/* OBSOLETE #if !defined (UPAGES) */
+/* OBSOLETE #define UPAGES USIZE */
+/* OBSOLETE #endif */
+/* OBSOLETE */
+/* OBSOLETE data_end = data_start + NBPG * u.u_dsize; */
+/* OBSOLETE stack_start = stack_end - NBPG * u.u_ssize; */
+/* OBSOLETE data_offset = NBPG * UPAGES + exec_data_start % NBPG /* Not sure about this //jkp *x/; */
+/* OBSOLETE stack_offset = NBPG * (UPAGES + u.u_dsize); */
+/* OBSOLETE */
+/* OBSOLETE /* Some machines put an absolute address in here and some put */
+/* OBSOLETE the offset in the upage of the regs. *x/ */
+/* OBSOLETE reg_offset = (int) u.u_state; */
+/* OBSOLETE if (reg_offset > NBPG * UPAGES) */
+/* OBSOLETE reg_offset -= KERNEL_U_ADDR; */
+/* OBSOLETE */
+/* OBSOLETE memcpy (&core_aouthdr, &u.u_exdata, sizeof (AOUTHDR)); */
+/* OBSOLETE printf_unfiltered ("Core file is from \"%s\".\n", u.u_comm); */
+/* OBSOLETE */
+/* OBSOLETE /* I don't know where to find this info. */
+/* OBSOLETE So, for now, mark it as not available. *x/ */
+/* OBSOLETE N_SET_MAGIC (core_aouthdr, 0); */
+/* OBSOLETE */
+/* OBSOLETE /* Read the register values out of the core file and store */
+/* OBSOLETE them where `read_register' will find them. *x/ */
+/* OBSOLETE */
+/* OBSOLETE { */
+/* OBSOLETE register int regno; */
+/* OBSOLETE */
+/* OBSOLETE for (regno = 0; regno < NUM_REGS; regno++) */
+/* OBSOLETE { */
+/* OBSOLETE char buf[MAX_REGISTER_RAW_SIZE]; */
+/* OBSOLETE */
+/* OBSOLETE val = lseek (corechan, register_addr (regno, reg_offset), 0); */
+/* OBSOLETE if (val < 0 */
+/* OBSOLETE || (val = myread (corechan, buf, sizeof buf)) < 0) */
+/* OBSOLETE { */
+/* OBSOLETE char * buffer = (char *) alloca (strlen (REGISTER_NAME (regno)) */
+/* OBSOLETE + 30); */
+/* OBSOLETE strcpy (buffer, "Reading register "); */
+/* OBSOLETE strcat (buffer, REGISTER_NAME (regno)); */
+/* OBSOLETE */
+/* OBSOLETE perror_with_name (buffer); */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE supply_register (regno, buf); */
+/* OBSOLETE } */
+/* OBSOLETE } */
+/* OBSOLETE } */
+/* OBSOLETE if (filename[0] == '/') */
+/* OBSOLETE corefile = savestring (filename, strlen (filename)); */
+/* OBSOLETE else */
+/* OBSOLETE { */
+/* OBSOLETE corefile = concat (current_directory, "/", filename, NULL); */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE flush_cached_frames (); */
+/* OBSOLETE select_frame (get_current_frame (), 0); */
+/* OBSOLETE validate_files (); */
+/* OBSOLETE } */
+/* OBSOLETE else if (from_tty) */
+/* OBSOLETE printf_unfiltered ("No core file now.\n"); */
+/* OBSOLETE } */
{
printf_filtered (" %s", *arch);
}
- free (arches);
+ xfree (arches);
}
else
{
-/* Acorn Risc Machine host machine support.
- Copyright (C) 1988, 1989, 1991 Free Software Foundation, Inc.
-
-This file is part of GDB.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include "defs.h"
-#include "frame.h"
-#include "inferior.h"
-#include "arm-opcode.h"
-
-#include <sys/param.h>
-#include <sys/dir.h>
-#include <signal.h>
-#include <sys/ioctl.h>
-#include <sys/ptrace.h>
-#include <machine/reg.h>
-
-#define N_TXTADDR(hdr) 0x8000
-#define N_DATADDR(hdr) (hdr.a_text + 0x8000)
-
-#include "gdbcore.h"
-
-#include <sys/user.h> /* After a.out.h */
-#include <sys/file.h>
-#include "gdb_stat.h"
-
-#include <errno.h>
-
-void
-fetch_inferior_registers (regno)
- int regno; /* Original value discarded */
-{
- register unsigned int regaddr;
- char buf[MAX_REGISTER_RAW_SIZE];
- register int i;
-
- struct user u;
- unsigned int offset = (char *) &u.u_ar0 - (char *) &u;
- offset = ptrace (PT_READ_U, inferior_pid, (PTRACE_ARG3_TYPE) offset, 0)
- - KERNEL_U_ADDR;
-
- registers_fetched ();
-
- for (regno = 0; regno < 16; regno++)
- {
- regaddr = offset + regno * 4;
- *(int *)&buf[0] = ptrace (PT_READ_U, inferior_pid,
- (PTRACE_ARG3_TYPE) regaddr, 0);
- if (regno == PC_REGNUM)
- *(int *)&buf[0] = GET_PC_PART(*(int *)&buf[0]);
- supply_register (regno, buf);
- }
- *(int *)&buf[0] = ptrace (PT_READ_U, inferior_pid,
- (PTRACE_ARG3_TYPE) (offset + PC*4), 0);
- supply_register (PS_REGNUM, buf); /* set virtual register ps same as pc */
-
- /* read the floating point registers */
- offset = (char *) &u.u_fp_regs - (char *)&u;
- *(int *)buf = ptrace (PT_READ_U, inferior_pid, (PTRACE_ARG3_TYPE) offset, 0);
- supply_register (FPS_REGNUM, buf);
- for (regno = 16; regno < 24; regno++) {
- regaddr = offset + 4 + 12 * (regno - 16);
- for (i = 0; i < 12; i += sizeof(int))
- *(int *) &buf[i] = ptrace (PT_READ_U, inferior_pid,
- (PTRACE_ARG3_TYPE) (regaddr + i), 0);
- supply_register (regno, buf);
- }
-}
-
-/* Store our register values back into the inferior.
- If REGNO is -1, do this for all registers.
- Otherwise, REGNO specifies which register (so we can save time). */
-
-void
-store_inferior_registers (regno)
- int regno;
-{
- register unsigned int regaddr;
- char buf[80];
-
- struct user u;
- unsigned long value;
- unsigned int offset = (char *) &u.u_ar0 - (char *) &u;
- offset = ptrace (PT_READ_U, inferior_pid, (PTRACE_ARG3_TYPE) offset, 0)
- - KERNEL_U_ADDR;
-
- if (regno >= 0) {
- if (regno >= 16) return;
- regaddr = offset + 4 * regno;
- errno = 0;
- value = read_register(regno);
- if (regno == PC_REGNUM)
- value = SET_PC_PART(read_register (PS_REGNUM), value);
- ptrace (PT_WRITE_U, inferior_pid, (PTRACE_ARG3_TYPE) regaddr, value);
- if (errno != 0)
- {
- sprintf (buf, "writing register number %d", regno);
- perror_with_name (buf);
- }
- }
- else for (regno = 0; regno < 15; regno++)
- {
- regaddr = offset + regno * 4;
- errno = 0;
- value = read_register(regno);
- if (regno == PC_REGNUM)
- value = SET_PC_PART(read_register (PS_REGNUM), value);
- ptrace (6, inferior_pid, (PTRACE_ARG3_TYPE) regaddr, value);
- if (errno != 0)
- {
- sprintf (buf, "writing all regs, number %d", regno);
- perror_with_name (buf);
- }
- }
-}
-\f
-/* Work with core dump and executable files, for GDB.
- This code would be in corefile.c if it weren't machine-dependent. */
-
-/* Structure to describe the chain of shared libraries used
- by the execfile.
- e.g. prog shares Xt which shares X11 which shares c. */
-
-struct shared_library {
- struct exec_header header;
- char name[SHLIBLEN];
- CORE_ADDR text_start; /* CORE_ADDR of 1st byte of text, this file */
- long data_offset; /* offset of data section in file */
- int chan; /* file descriptor for the file */
- struct shared_library *shares; /* library this one shares */
-};
-static struct shared_library *shlib = 0;
-
-/* Hook for `exec_file_command' command to call. */
-
-extern void (*exec_file_display_hook) ();
-
-static CORE_ADDR unshared_text_start;
-
-/* extended header from exec file (for shared library info) */
-
-static struct exec_header exec_header;
-\f
-void
-core_file_command (filename, from_tty)
- char *filename;
- int from_tty;
-{
- int val;
- extern char registers[];
-
- /* Discard all vestiges of any previous core file
- and mark data and stack spaces as empty. */
-
- if (corefile)
- free (corefile);
- corefile = 0;
-
- if (corechan >= 0)
- close (corechan);
- corechan = -1;
-
- data_start = 0;
- data_end = 0;
- stack_start = STACK_END_ADDR;
- stack_end = STACK_END_ADDR;
-
- /* Now, if a new core file was specified, open it and digest it. */
-
- if (filename)
- {
- filename = tilde_expand (filename);
- make_cleanup (free, filename);
-
- if (have_inferior_p ())
- error ("To look at a core file, you must kill the program with \"kill\".");
- corechan = open (filename, O_RDONLY, 0);
- if (corechan < 0)
- perror_with_name (filename);
- /* 4.2-style (and perhaps also sysV-style) core dump file. */
- {
- struct user u;
-
- unsigned int reg_offset, fp_reg_offset;
-
- val = myread (corechan, &u, sizeof u);
- if (val < 0)
- perror_with_name ("Not a core file: reading upage");
- if (val != sizeof u)
- error ("Not a core file: could only read %d bytes", val);
-
- /* We are depending on exec_file_command having been called
- previously to set exec_data_start. Since the executable
- and the core file share the same text segment, the address
- of the data segment will be the same in both. */
- data_start = exec_data_start;
-
- data_end = data_start + NBPG * u.u_dsize;
- stack_start = stack_end - NBPG * u.u_ssize;
- data_offset = NBPG * UPAGES;
- stack_offset = NBPG * (UPAGES + u.u_dsize);
-
- /* Some machines put an absolute address in here and some put
- the offset in the upage of the regs. */
- reg_offset = (int) u.u_ar0;
- if (reg_offset > NBPG * UPAGES)
- reg_offset -= KERNEL_U_ADDR;
- fp_reg_offset = (char *) &u.u_fp_regs - (char *)&u;
-
- /* I don't know where to find this info.
- So, for now, mark it as not available. */
- N_SET_MAGIC (core_aouthdr, 0);
-
- /* Read the register values out of the core file and store
- them where `read_register' will find them. */
-
- {
- register int regno;
-
- for (regno = 0; regno < NUM_REGS; regno++)
- {
- char buf[MAX_REGISTER_RAW_SIZE];
-
- if (regno < 16)
- val = lseek (corechan, reg_offset + 4 * regno, 0);
- else if (regno < 24)
- val = lseek (corechan, fp_reg_offset + 4 + 12*(regno - 24), 0);
- else if (regno == 24)
- val = lseek (corechan, fp_reg_offset, 0);
- else if (regno == 25)
- val = lseek (corechan, reg_offset + 4 * PC, 0);
- if (val < 0
- || (val = myread (corechan, buf, sizeof buf)) < 0)
- {
- char * buffer = (char *) alloca (strlen (REGISTER_NAME (regno))
- + 30);
- strcpy (buffer, "Reading register ");
- strcat (buffer, REGISTER_NAME (regno));
-
- perror_with_name (buffer);
- }
-
- if (regno == PC_REGNUM)
- *(int *)buf = GET_PC_PART(*(int *)buf);
- supply_register (regno, buf);
- }
- }
- }
- if (filename[0] == '/')
- corefile = savestring (filename, strlen (filename));
- else
- {
- corefile = concat (current_directory, "/", filename, NULL);
- }
-
- flush_cached_frames ();
- select_frame (get_current_frame (), 0);
- validate_files ();
- }
- else if (from_tty)
- printf ("No core file now.\n");
-}
-
-#if 0
-/* Work with core dump and executable files, for GDB.
- This code would be in corefile.c if it weren't machine-dependent. */
-
-/* Structure to describe the chain of shared libraries used
- by the execfile.
- e.g. prog shares Xt which shares X11 which shares c. */
-
-struct shared_library {
- struct exec_header header;
- char name[SHLIBLEN];
- CORE_ADDR text_start; /* CORE_ADDR of 1st byte of text, this file */
- long data_offset; /* offset of data section in file */
- int chan; /* file descriptor for the file */
- struct shared_library *shares; /* library this one shares */
-};
-static struct shared_library *shlib = 0;
-
-/* Hook for `exec_file_command' command to call. */
-
-extern void (*exec_file_display_hook) ();
-
-static CORE_ADDR unshared_text_start;
-
-/* extended header from exec file (for shared library info) */
-
-static struct exec_header exec_header;
-
-void
-exec_file_command (filename, from_tty)
- char *filename;
- int from_tty;
-{
- int val;
-
- /* Eliminate all traces of old exec file.
- Mark text segment as empty. */
-
- if (execfile)
- free (execfile);
- execfile = 0;
- data_start = 0;
- data_end -= exec_data_start;
- text_start = 0;
- unshared_text_start = 0;
- text_end = 0;
- exec_data_start = 0;
- exec_data_end = 0;
- if (execchan >= 0)
- close (execchan);
- execchan = -1;
- if (shlib) {
- close_shared_library(shlib);
- shlib = 0;
- }
-
- /* Now open and digest the file the user requested, if any. */
-
- if (filename)
- {
- filename = tilde_expand (filename);
- make_cleanup (free, filename);
-
- execchan = openp (getenv ("PATH"), 1, filename, O_RDONLY, 0,
- &execfile);
- if (execchan < 0)
- perror_with_name (filename);
-
- {
- struct stat st_exec;
-
-#ifdef HEADER_SEEK_FD
- HEADER_SEEK_FD (execchan);
-#endif
-
- val = myread (execchan, &exec_header, sizeof exec_header);
- exec_aouthdr = exec_header.a_exec;
-
- if (val < 0)
- perror_with_name (filename);
-
- text_start = 0x8000;
-
- /* Look for shared library if needed */
- if (exec_header.a_exec.a_magic & MF_USES_SL)
- shlib = open_shared_library(exec_header.a_shlibname, text_start);
-
- text_offset = N_TXTOFF (exec_aouthdr);
- exec_data_offset = N_TXTOFF (exec_aouthdr) + exec_aouthdr.a_text;
-
- if (shlib) {
- unshared_text_start = shared_text_end(shlib) & ~0x7fff;
- stack_start = shlib->header.a_exec.a_sldatabase;
- stack_end = STACK_END_ADDR;
- } else
- unshared_text_start = 0x8000;
- text_end = unshared_text_start + exec_aouthdr.a_text;
-
- exec_data_start = unshared_text_start + exec_aouthdr.a_text;
- exec_data_end = exec_data_start + exec_aouthdr.a_data;
-
- data_start = exec_data_start;
- data_end += exec_data_start;
-
- fstat (execchan, &st_exec);
- exec_mtime = st_exec.st_mtime;
- }
-
- validate_files ();
- }
- else if (from_tty)
- printf ("No executable file now.\n");
-
- /* Tell display code (if any) about the changed file name. */
- if (exec_file_display_hook)
- (*exec_file_display_hook) (filename);
-}
-#endif
-
-#if 0
-/* Read from the program's memory (except for inferior processes).
- This function is misnamed, since it only reads, never writes; and
- since it will use the core file and/or executable file as necessary.
-
- It should be extended to write as well as read, FIXME, for patching files.
-
- Return 0 if address could be read, EIO if addresss out of bounds. */
-
-int
-xfer_core_file (memaddr, myaddr, len)
- CORE_ADDR memaddr;
- char *myaddr;
- int len;
-{
- register int i;
- register int val;
- int xferchan;
- char **xferfile;
- int fileptr;
- int returnval = 0;
-
- while (len > 0)
- {
- xferfile = 0;
- xferchan = 0;
-
- /* Determine which file the next bunch of addresses reside in,
- and where in the file. Set the file's read/write pointer
- to point at the proper place for the desired address
- and set xferfile and xferchan for the correct file.
-
- If desired address is nonexistent, leave them zero.
-
- i is set to the number of bytes that can be handled
- along with the next address.
-
- We put the most likely tests first for efficiency. */
-
- /* Note that if there is no core file
- data_start and data_end are equal. */
- if (memaddr >= data_start && memaddr < data_end)
- {
- i = min (len, data_end - memaddr);
- fileptr = memaddr - data_start + data_offset;
- xferfile = &corefile;
- xferchan = corechan;
- }
- /* Note that if there is no core file
- stack_start and stack_end define the shared library data. */
- else if (memaddr >= stack_start && memaddr < stack_end)
- {
- if (corechan < 0) {
- struct shared_library *lib;
- for (lib = shlib; lib; lib = lib->shares)
- if (memaddr >= lib->header.a_exec.a_sldatabase &&
- memaddr < lib->header.a_exec.a_sldatabase +
- lib->header.a_exec.a_data)
- break;
- if (lib) {
- i = min (len, lib->header.a_exec.a_sldatabase +
- lib->header.a_exec.a_data - memaddr);
- fileptr = lib->data_offset + memaddr -
- lib->header.a_exec.a_sldatabase;
- xferfile = execfile;
- xferchan = lib->chan;
- }
- } else {
- i = min (len, stack_end - memaddr);
- fileptr = memaddr - stack_start + stack_offset;
- xferfile = &corefile;
- xferchan = corechan;
- }
- }
- else if (corechan < 0
- && memaddr >= exec_data_start && memaddr < exec_data_end)
- {
- i = min (len, exec_data_end - memaddr);
- fileptr = memaddr - exec_data_start + exec_data_offset;
- xferfile = &execfile;
- xferchan = execchan;
- }
- else if (memaddr >= text_start && memaddr < text_end)
- {
- struct shared_library *lib;
- for (lib = shlib; lib; lib = lib->shares)
- if (memaddr >= lib->text_start &&
- memaddr < lib->text_start + lib->header.a_exec.a_text)
- break;
- if (lib) {
- i = min (len, lib->header.a_exec.a_text +
- lib->text_start - memaddr);
- fileptr = memaddr - lib->text_start + text_offset;
- xferfile = &execfile;
- xferchan = lib->chan;
- } else {
- i = min (len, text_end - memaddr);
- fileptr = memaddr - unshared_text_start + text_offset;
- xferfile = &execfile;
- xferchan = execchan;
- }
- }
- else if (memaddr < text_start)
- {
- i = min (len, text_start - memaddr);
- }
- else if (memaddr >= text_end
- && memaddr < (corechan >= 0? data_start : exec_data_start))
- {
- i = min (len, data_start - memaddr);
- }
- else if (corechan >= 0
- && memaddr >= data_end && memaddr < stack_start)
- {
- i = min (len, stack_start - memaddr);
- }
- else if (corechan < 0 && memaddr >= exec_data_end)
- {
- i = min (len, - memaddr);
- }
- else if (memaddr >= stack_end && stack_end != 0)
- {
- i = min (len, - memaddr);
- }
- else
- {
- /* Address did not classify into one of the known ranges.
- This shouldn't happen; we catch the endpoints. */
- fatal ("Internal: Bad case logic in xfer_core_file.");
- }
-
- /* Now we know which file to use.
- Set up its pointer and transfer the data. */
- if (xferfile)
- {
- if (*xferfile == 0)
- if (xferfile == &execfile)
- error ("No program file to examine.");
- else
- error ("No core dump file or running program to examine.");
- val = lseek (xferchan, fileptr, 0);
- if (val < 0)
- perror_with_name (*xferfile);
- val = myread (xferchan, myaddr, i);
- if (val < 0)
- perror_with_name (*xferfile);
- }
- /* If this address is for nonexistent memory,
- read zeros if reading, or do nothing if writing.
- Actually, we never right. */
- else
- {
- memset (myaddr, '\0', i);
- returnval = EIO;
- }
-
- memaddr += i;
- myaddr += i;
- len -= i;
- }
- return returnval;
-}
-#endif
+/* OBSOLETE /* Acorn Risc Machine host machine support. */
+/* OBSOLETE Copyright (C) 1988, 1989, 1991 Free Software Foundation, Inc. */
+/* OBSOLETE */
+/* OBSOLETE This file is part of GDB. */
+/* OBSOLETE */
+/* OBSOLETE This program is free software; you can redistribute it and/or modify */
+/* OBSOLETE it under the terms of the GNU General Public License as published by */
+/* OBSOLETE the Free Software Foundation; either version 2 of the License, or */
+/* OBSOLETE (at your option) any later version. */
+/* OBSOLETE */
+/* OBSOLETE This program is distributed in the hope that it will be useful, */
+/* OBSOLETE but WITHOUT ANY WARRANTY; without even the implied warranty of */
+/* OBSOLETE MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
+/* OBSOLETE GNU General Public License for more details. */
+/* OBSOLETE */
+/* OBSOLETE You should have received a copy of the GNU General Public License */
+/* OBSOLETE along with this program; if not, write to the Free Software */
+/* OBSOLETE Foundation, Inc., 59 Temple Place - Suite 330, */
+/* OBSOLETE Boston, MA 02111-1307, USA. *x/ */
+/* OBSOLETE */
+/* OBSOLETE #include "defs.h" */
+/* OBSOLETE #include "frame.h" */
+/* OBSOLETE #include "inferior.h" */
+/* OBSOLETE #include "opcode/arm.h" */
+/* OBSOLETE */
+/* OBSOLETE #include <sys/param.h> */
+/* OBSOLETE #include <sys/dir.h> */
+/* OBSOLETE #include <signal.h> */
+/* OBSOLETE #include <sys/ioctl.h> */
+/* OBSOLETE #include <sys/ptrace.h> */
+/* OBSOLETE #include <machine/reg.h> */
+/* OBSOLETE */
+/* OBSOLETE #define N_TXTADDR(hdr) 0x8000 */
+/* OBSOLETE #define N_DATADDR(hdr) (hdr.a_text + 0x8000) */
+/* OBSOLETE */
+/* OBSOLETE #include "gdbcore.h" */
+/* OBSOLETE */
+/* OBSOLETE #include <sys/user.h> /* After a.out.h *x/ */
+/* OBSOLETE #include <sys/file.h> */
+/* OBSOLETE #include "gdb_stat.h" */
+/* OBSOLETE */
+/* OBSOLETE #include <errno.h> */
+/* OBSOLETE */
+/* OBSOLETE void */
+/* OBSOLETE fetch_inferior_registers (regno) */
+/* OBSOLETE int regno; /* Original value discarded *x/ */
+/* OBSOLETE { */
+/* OBSOLETE register unsigned int regaddr; */
+/* OBSOLETE char buf[MAX_REGISTER_RAW_SIZE]; */
+/* OBSOLETE register int i; */
+/* OBSOLETE */
+/* OBSOLETE struct user u; */
+/* OBSOLETE unsigned int offset = (char *) &u.u_ar0 - (char *) &u; */
+/* OBSOLETE offset = ptrace (PT_READ_U, inferior_pid, (PTRACE_ARG3_TYPE) offset, 0) */
+/* OBSOLETE - KERNEL_U_ADDR; */
+/* OBSOLETE */
+/* OBSOLETE registers_fetched (); */
+/* OBSOLETE */
+/* OBSOLETE for (regno = 0; regno < 16; regno++) */
+/* OBSOLETE { */
+/* OBSOLETE regaddr = offset + regno * 4; */
+/* OBSOLETE *(int *) &buf[0] = ptrace (PT_READ_U, inferior_pid, */
+/* OBSOLETE (PTRACE_ARG3_TYPE) regaddr, 0); */
+/* OBSOLETE if (regno == PC_REGNUM) */
+/* OBSOLETE *(int *) &buf[0] = GET_PC_PART (*(int *) &buf[0]); */
+/* OBSOLETE supply_register (regno, buf); */
+/* OBSOLETE } */
+/* OBSOLETE *(int *) &buf[0] = ptrace (PT_READ_U, inferior_pid, */
+/* OBSOLETE (PTRACE_ARG3_TYPE) (offset + PC * 4), 0); */
+/* OBSOLETE supply_register (PS_REGNUM, buf); /* set virtual register ps same as pc *x/ */
+/* OBSOLETE */
+/* OBSOLETE /* read the floating point registers *x/ */
+/* OBSOLETE offset = (char *) &u.u_fp_regs - (char *) &u; */
+/* OBSOLETE *(int *) buf = ptrace (PT_READ_U, inferior_pid, (PTRACE_ARG3_TYPE) offset, 0); */
+/* OBSOLETE supply_register (FPS_REGNUM, buf); */
+/* OBSOLETE for (regno = 16; regno < 24; regno++) */
+/* OBSOLETE { */
+/* OBSOLETE regaddr = offset + 4 + 12 * (regno - 16); */
+/* OBSOLETE for (i = 0; i < 12; i += sizeof (int)) */
+/* OBSOLETE *(int *) &buf[i] = ptrace (PT_READ_U, inferior_pid, */
+/* OBSOLETE (PTRACE_ARG3_TYPE) (regaddr + i), 0); */
+/* OBSOLETE supply_register (regno, buf); */
+/* OBSOLETE } */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE /* Store our register values back into the inferior. */
+/* OBSOLETE If REGNO is -1, do this for all registers. */
+/* OBSOLETE Otherwise, REGNO specifies which register (so we can save time). *x/ */
+/* OBSOLETE */
+/* OBSOLETE void */
+/* OBSOLETE store_inferior_registers (regno) */
+/* OBSOLETE int regno; */
+/* OBSOLETE { */
+/* OBSOLETE register unsigned int regaddr; */
+/* OBSOLETE char buf[80]; */
+/* OBSOLETE */
+/* OBSOLETE struct user u; */
+/* OBSOLETE unsigned long value; */
+/* OBSOLETE unsigned int offset = (char *) &u.u_ar0 - (char *) &u; */
+/* OBSOLETE offset = ptrace (PT_READ_U, inferior_pid, (PTRACE_ARG3_TYPE) offset, 0) */
+/* OBSOLETE - KERNEL_U_ADDR; */
+/* OBSOLETE */
+/* OBSOLETE if (regno >= 0) */
+/* OBSOLETE { */
+/* OBSOLETE if (regno >= 16) */
+/* OBSOLETE return; */
+/* OBSOLETE regaddr = offset + 4 * regno; */
+/* OBSOLETE errno = 0; */
+/* OBSOLETE value = read_register (regno); */
+/* OBSOLETE if (regno == PC_REGNUM) */
+/* OBSOLETE value = SET_PC_PART (read_register (PS_REGNUM), value); */
+/* OBSOLETE ptrace (PT_WRITE_U, inferior_pid, (PTRACE_ARG3_TYPE) regaddr, value); */
+/* OBSOLETE if (errno != 0) */
+/* OBSOLETE { */
+/* OBSOLETE sprintf (buf, "writing register number %d", regno); */
+/* OBSOLETE perror_with_name (buf); */
+/* OBSOLETE } */
+/* OBSOLETE } */
+/* OBSOLETE else */
+/* OBSOLETE for (regno = 0; regno < 15; regno++) */
+/* OBSOLETE { */
+/* OBSOLETE regaddr = offset + regno * 4; */
+/* OBSOLETE errno = 0; */
+/* OBSOLETE value = read_register (regno); */
+/* OBSOLETE if (regno == PC_REGNUM) */
+/* OBSOLETE value = SET_PC_PART (read_register (PS_REGNUM), value); */
+/* OBSOLETE ptrace (6, inferior_pid, (PTRACE_ARG3_TYPE) regaddr, value); */
+/* OBSOLETE if (errno != 0) */
+/* OBSOLETE { */
+/* OBSOLETE sprintf (buf, "writing all regs, number %d", regno); */
+/* OBSOLETE perror_with_name (buf); */
+/* OBSOLETE } */
+/* OBSOLETE } */
+/* OBSOLETE } */
+/* OBSOLETE \f */
+/* OBSOLETE /* Work with core dump and executable files, for GDB. */
+/* OBSOLETE This code would be in corefile.c if it weren't machine-dependent. *x/ */
+/* OBSOLETE */
+/* OBSOLETE /* Structure to describe the chain of shared libraries used */
+/* OBSOLETE by the execfile. */
+/* OBSOLETE e.g. prog shares Xt which shares X11 which shares c. *x/ */
+/* OBSOLETE */
+/* OBSOLETE struct shared_library */
+/* OBSOLETE { */
+/* OBSOLETE struct exec_header header; */
+/* OBSOLETE char name[SHLIBLEN]; */
+/* OBSOLETE CORE_ADDR text_start; /* CORE_ADDR of 1st byte of text, this file *x/ */
+/* OBSOLETE long data_offset; /* offset of data section in file *x/ */
+/* OBSOLETE int chan; /* file descriptor for the file *x/ */
+/* OBSOLETE struct shared_library *shares; /* library this one shares *x/ */
+/* OBSOLETE }; */
+/* OBSOLETE static struct shared_library *shlib = 0; */
+/* OBSOLETE */
+/* OBSOLETE /* Hook for `exec_file_command' command to call. *x/ */
+/* OBSOLETE */
+/* OBSOLETE extern void (*exec_file_display_hook) (); */
+/* OBSOLETE */
+/* OBSOLETE static CORE_ADDR unshared_text_start; */
+/* OBSOLETE */
+/* OBSOLETE /* extended header from exec file (for shared library info) *x/ */
+/* OBSOLETE */
+/* OBSOLETE static struct exec_header exec_header; */
+/* OBSOLETE \f */
+/* OBSOLETE void */
+/* OBSOLETE core_file_command (filename, from_tty) */
+/* OBSOLETE char *filename; */
+/* OBSOLETE int from_tty; */
+/* OBSOLETE { */
+/* OBSOLETE int val; */
+/* OBSOLETE */
+/* OBSOLETE /* Discard all vestiges of any previous core file */
+/* OBSOLETE and mark data and stack spaces as empty. *x/ */
+/* OBSOLETE */
+/* OBSOLETE if (corefile) */
+/* OBSOLETE xfree (corefile); */
+/* OBSOLETE corefile = 0; */
+/* OBSOLETE */
+/* OBSOLETE if (corechan >= 0) */
+/* OBSOLETE close (corechan); */
+/* OBSOLETE corechan = -1; */
+/* OBSOLETE */
+/* OBSOLETE data_start = 0; */
+/* OBSOLETE data_end = 0; */
+/* OBSOLETE stack_start = STACK_END_ADDR; */
+/* OBSOLETE stack_end = STACK_END_ADDR; */
+/* OBSOLETE */
+/* OBSOLETE /* Now, if a new core file was specified, open it and digest it. *x/ */
+/* OBSOLETE */
+/* OBSOLETE if (filename) */
+/* OBSOLETE { */
+/* OBSOLETE filename = tilde_expand (filename); */
+/* OBSOLETE make_cleanup (xfree, filename); */
+/* OBSOLETE */
+/* OBSOLETE if (have_inferior_p ()) */
+/* OBSOLETE error ("To look at a core file, you must kill the program with \"kill\"."); */
+/* OBSOLETE corechan = open (filename, O_RDONLY, 0); */
+/* OBSOLETE if (corechan < 0) */
+/* OBSOLETE perror_with_name (filename); */
+/* OBSOLETE /* 4.2-style (and perhaps also sysV-style) core dump file. *x/ */
+/* OBSOLETE { */
+/* OBSOLETE struct user u; */
+/* OBSOLETE */
+/* OBSOLETE unsigned int reg_offset, fp_reg_offset; */
+/* OBSOLETE */
+/* OBSOLETE val = myread (corechan, &u, sizeof u); */
+/* OBSOLETE if (val < 0) */
+/* OBSOLETE perror_with_name ("Not a core file: reading upage"); */
+/* OBSOLETE if (val != sizeof u) */
+/* OBSOLETE error ("Not a core file: could only read %d bytes", val); */
+/* OBSOLETE */
+/* OBSOLETE /* We are depending on exec_file_command having been called */
+/* OBSOLETE previously to set exec_data_start. Since the executable */
+/* OBSOLETE and the core file share the same text segment, the address */
+/* OBSOLETE of the data segment will be the same in both. *x/ */
+/* OBSOLETE data_start = exec_data_start; */
+/* OBSOLETE */
+/* OBSOLETE data_end = data_start + NBPG * u.u_dsize; */
+/* OBSOLETE stack_start = stack_end - NBPG * u.u_ssize; */
+/* OBSOLETE data_offset = NBPG * UPAGES; */
+/* OBSOLETE stack_offset = NBPG * (UPAGES + u.u_dsize); */
+/* OBSOLETE */
+/* OBSOLETE /* Some machines put an absolute address in here and some put */
+/* OBSOLETE the offset in the upage of the regs. *x/ */
+/* OBSOLETE reg_offset = (int) u.u_ar0; */
+/* OBSOLETE if (reg_offset > NBPG * UPAGES) */
+/* OBSOLETE reg_offset -= KERNEL_U_ADDR; */
+/* OBSOLETE fp_reg_offset = (char *) &u.u_fp_regs - (char *) &u; */
+/* OBSOLETE */
+/* OBSOLETE /* I don't know where to find this info. */
+/* OBSOLETE So, for now, mark it as not available. *x/ */
+/* OBSOLETE N_SET_MAGIC (core_aouthdr, 0); */
+/* OBSOLETE */
+/* OBSOLETE /* Read the register values out of the core file and store */
+/* OBSOLETE them where `read_register' will find them. *x/ */
+/* OBSOLETE */
+/* OBSOLETE { */
+/* OBSOLETE register int regno; */
+/* OBSOLETE */
+/* OBSOLETE for (regno = 0; regno < NUM_REGS; regno++) */
+/* OBSOLETE { */
+/* OBSOLETE char buf[MAX_REGISTER_RAW_SIZE]; */
+/* OBSOLETE */
+/* OBSOLETE if (regno < 16) */
+/* OBSOLETE val = lseek (corechan, reg_offset + 4 * regno, 0); */
+/* OBSOLETE else if (regno < 24) */
+/* OBSOLETE val = lseek (corechan, fp_reg_offset + 4 + 12 * (regno - 24), 0); */
+/* OBSOLETE else if (regno == 24) */
+/* OBSOLETE val = lseek (corechan, fp_reg_offset, 0); */
+/* OBSOLETE else if (regno == 25) */
+/* OBSOLETE val = lseek (corechan, reg_offset + 4 * PC, 0); */
+/* OBSOLETE if (val < 0 */
+/* OBSOLETE || (val = myread (corechan, buf, sizeof buf)) < 0) */
+/* OBSOLETE { */
+/* OBSOLETE char *buffer = (char *) alloca (strlen (REGISTER_NAME (regno)) */
+/* OBSOLETE + 30); */
+/* OBSOLETE strcpy (buffer, "Reading register "); */
+/* OBSOLETE strcat (buffer, REGISTER_NAME (regno)); */
+/* OBSOLETE */
+/* OBSOLETE perror_with_name (buffer); */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE if (regno == PC_REGNUM) */
+/* OBSOLETE *(int *) buf = GET_PC_PART (*(int *) buf); */
+/* OBSOLETE supply_register (regno, buf); */
+/* OBSOLETE } */
+/* OBSOLETE } */
+/* OBSOLETE } */
+/* OBSOLETE if (filename[0] == '/') */
+/* OBSOLETE corefile = savestring (filename, strlen (filename)); */
+/* OBSOLETE else */
+/* OBSOLETE { */
+/* OBSOLETE corefile = concat (current_directory, "/", filename, NULL); */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE flush_cached_frames (); */
+/* OBSOLETE select_frame (get_current_frame (), 0); */
+/* OBSOLETE validate_files (); */
+/* OBSOLETE } */
+/* OBSOLETE else if (from_tty) */
+/* OBSOLETE printf ("No core file now.\n"); */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE #if 0 */
+/* OBSOLETE /* Work with core dump and executable files, for GDB. */
+/* OBSOLETE This code would be in corefile.c if it weren't machine-dependent. *x/ */
+/* OBSOLETE */
+/* OBSOLETE /* Structure to describe the chain of shared libraries used */
+/* OBSOLETE by the execfile. */
+/* OBSOLETE e.g. prog shares Xt which shares X11 which shares c. *x/ */
+/* OBSOLETE */
+/* OBSOLETE struct shared_library */
+/* OBSOLETE { */
+/* OBSOLETE struct exec_header header; */
+/* OBSOLETE char name[SHLIBLEN]; */
+/* OBSOLETE CORE_ADDR text_start; /* CORE_ADDR of 1st byte of text, this file *x/ */
+/* OBSOLETE long data_offset; /* offset of data section in file *x/ */
+/* OBSOLETE int chan; /* file descriptor for the file *x/ */
+/* OBSOLETE struct shared_library *shares; /* library this one shares *x/ */
+/* OBSOLETE }; */
+/* OBSOLETE static struct shared_library *shlib = 0; */
+/* OBSOLETE */
+/* OBSOLETE /* Hook for `exec_file_command' command to call. *x/ */
+/* OBSOLETE */
+/* OBSOLETE extern void (*exec_file_display_hook) (); */
+/* OBSOLETE */
+/* OBSOLETE static CORE_ADDR unshared_text_start; */
+/* OBSOLETE */
+/* OBSOLETE /* extended header from exec file (for shared library info) *x/ */
+/* OBSOLETE */
+/* OBSOLETE static struct exec_header exec_header; */
+/* OBSOLETE */
+/* OBSOLETE void */
+/* OBSOLETE exec_file_command (filename, from_tty) */
+/* OBSOLETE char *filename; */
+/* OBSOLETE int from_tty; */
+/* OBSOLETE { */
+/* OBSOLETE int val; */
+/* OBSOLETE */
+/* OBSOLETE /* Eliminate all traces of old exec file. */
+/* OBSOLETE Mark text segment as empty. *x/ */
+/* OBSOLETE */
+/* OBSOLETE if (execfile) */
+/* OBSOLETE xfree (execfile); */
+/* OBSOLETE execfile = 0; */
+/* OBSOLETE data_start = 0; */
+/* OBSOLETE data_end -= exec_data_start; */
+/* OBSOLETE text_start = 0; */
+/* OBSOLETE unshared_text_start = 0; */
+/* OBSOLETE text_end = 0; */
+/* OBSOLETE exec_data_start = 0; */
+/* OBSOLETE exec_data_end = 0; */
+/* OBSOLETE if (execchan >= 0) */
+/* OBSOLETE close (execchan); */
+/* OBSOLETE execchan = -1; */
+/* OBSOLETE if (shlib) */
+/* OBSOLETE { */
+/* OBSOLETE close_shared_library (shlib); */
+/* OBSOLETE shlib = 0; */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE /* Now open and digest the file the user requested, if any. *x/ */
+/* OBSOLETE */
+/* OBSOLETE if (filename) */
+/* OBSOLETE { */
+/* OBSOLETE filename = tilde_expand (filename); */
+/* OBSOLETE make_cleanup (xfree, filename); */
+/* OBSOLETE */
+/* OBSOLETE execchan = openp (getenv ("PATH"), 1, filename, O_RDONLY, 0, */
+/* OBSOLETE &execfile); */
+/* OBSOLETE if (execchan < 0) */
+/* OBSOLETE perror_with_name (filename); */
+/* OBSOLETE */
+/* OBSOLETE { */
+/* OBSOLETE struct stat st_exec; */
+/* OBSOLETE */
+/* OBSOLETE #ifdef HEADER_SEEK_FD */
+/* OBSOLETE HEADER_SEEK_FD (execchan); */
+/* OBSOLETE #endif */
+/* OBSOLETE */
+/* OBSOLETE val = myread (execchan, &exec_header, sizeof exec_header); */
+/* OBSOLETE exec_aouthdr = exec_header.a_exec; */
+/* OBSOLETE */
+/* OBSOLETE if (val < 0) */
+/* OBSOLETE perror_with_name (filename); */
+/* OBSOLETE */
+/* OBSOLETE text_start = 0x8000; */
+/* OBSOLETE */
+/* OBSOLETE /* Look for shared library if needed *x/ */
+/* OBSOLETE if (exec_header.a_exec.a_magic & MF_USES_SL) */
+/* OBSOLETE shlib = open_shared_library (exec_header.a_shlibname, text_start); */
+/* OBSOLETE */
+/* OBSOLETE text_offset = N_TXTOFF (exec_aouthdr); */
+/* OBSOLETE exec_data_offset = N_TXTOFF (exec_aouthdr) + exec_aouthdr.a_text; */
+/* OBSOLETE */
+/* OBSOLETE if (shlib) */
+/* OBSOLETE { */
+/* OBSOLETE unshared_text_start = shared_text_end (shlib) & ~0x7fff; */
+/* OBSOLETE stack_start = shlib->header.a_exec.a_sldatabase; */
+/* OBSOLETE stack_end = STACK_END_ADDR; */
+/* OBSOLETE } */
+/* OBSOLETE else */
+/* OBSOLETE unshared_text_start = 0x8000; */
+/* OBSOLETE text_end = unshared_text_start + exec_aouthdr.a_text; */
+/* OBSOLETE */
+/* OBSOLETE exec_data_start = unshared_text_start + exec_aouthdr.a_text; */
+/* OBSOLETE exec_data_end = exec_data_start + exec_aouthdr.a_data; */
+/* OBSOLETE */
+/* OBSOLETE data_start = exec_data_start; */
+/* OBSOLETE data_end += exec_data_start; */
+/* OBSOLETE */
+/* OBSOLETE fstat (execchan, &st_exec); */
+/* OBSOLETE exec_mtime = st_exec.st_mtime; */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE validate_files (); */
+/* OBSOLETE } */
+/* OBSOLETE else if (from_tty) */
+/* OBSOLETE printf ("No executable file now.\n"); */
+/* OBSOLETE */
+/* OBSOLETE /* Tell display code (if any) about the changed file name. *x/ */
+/* OBSOLETE if (exec_file_display_hook) */
+/* OBSOLETE (*exec_file_display_hook) (filename); */
+/* OBSOLETE } */
+/* OBSOLETE #endif */
+/* OBSOLETE */
+/* OBSOLETE #if 0 */
+/* OBSOLETE /* Read from the program's memory (except for inferior processes). */
+/* OBSOLETE This function is misnamed, since it only reads, never writes; and */
+/* OBSOLETE since it will use the core file and/or executable file as necessary. */
+/* OBSOLETE */
+/* OBSOLETE It should be extended to write as well as read, FIXME, for patching files. */
+/* OBSOLETE */
+/* OBSOLETE Return 0 if address could be read, EIO if addresss out of bounds. *x/ */
+/* OBSOLETE */
+/* OBSOLETE int */
+/* OBSOLETE xfer_core_file (memaddr, myaddr, len) */
+/* OBSOLETE CORE_ADDR memaddr; */
+/* OBSOLETE char *myaddr; */
+/* OBSOLETE int len; */
+/* OBSOLETE { */
+/* OBSOLETE register int i; */
+/* OBSOLETE register int val; */
+/* OBSOLETE int xferchan; */
+/* OBSOLETE char **xferfile; */
+/* OBSOLETE int fileptr; */
+/* OBSOLETE int returnval = 0; */
+/* OBSOLETE */
+/* OBSOLETE while (len > 0) */
+/* OBSOLETE { */
+/* OBSOLETE xferfile = 0; */
+/* OBSOLETE xferchan = 0; */
+/* OBSOLETE */
+/* OBSOLETE /* Determine which file the next bunch of addresses reside in, */
+/* OBSOLETE and where in the file. Set the file's read/write pointer */
+/* OBSOLETE to point at the proper place for the desired address */
+/* OBSOLETE and set xferfile and xferchan for the correct file. */
+/* OBSOLETE */
+/* OBSOLETE If desired address is nonexistent, leave them zero. */
+/* OBSOLETE */
+/* OBSOLETE i is set to the number of bytes that can be handled */
+/* OBSOLETE along with the next address. */
+/* OBSOLETE */
+/* OBSOLETE We put the most likely tests first for efficiency. *x/ */
+/* OBSOLETE */
+/* OBSOLETE /* Note that if there is no core file */
+/* OBSOLETE data_start and data_end are equal. *x/ */
+/* OBSOLETE if (memaddr >= data_start && memaddr < data_end) */
+/* OBSOLETE { */
+/* OBSOLETE i = min (len, data_end - memaddr); */
+/* OBSOLETE fileptr = memaddr - data_start + data_offset; */
+/* OBSOLETE xferfile = &corefile; */
+/* OBSOLETE xferchan = corechan; */
+/* OBSOLETE } */
+/* OBSOLETE /* Note that if there is no core file */
+/* OBSOLETE stack_start and stack_end define the shared library data. *x/ */
+/* OBSOLETE else if (memaddr >= stack_start && memaddr < stack_end) */
+/* OBSOLETE { */
+/* OBSOLETE if (corechan < 0) */
+/* OBSOLETE { */
+/* OBSOLETE struct shared_library *lib; */
+/* OBSOLETE for (lib = shlib; lib; lib = lib->shares) */
+/* OBSOLETE if (memaddr >= lib->header.a_exec.a_sldatabase && */
+/* OBSOLETE memaddr < lib->header.a_exec.a_sldatabase + */
+/* OBSOLETE lib->header.a_exec.a_data) */
+/* OBSOLETE break; */
+/* OBSOLETE if (lib) */
+/* OBSOLETE { */
+/* OBSOLETE i = min (len, lib->header.a_exec.a_sldatabase + */
+/* OBSOLETE lib->header.a_exec.a_data - memaddr); */
+/* OBSOLETE fileptr = lib->data_offset + memaddr - */
+/* OBSOLETE lib->header.a_exec.a_sldatabase; */
+/* OBSOLETE xferfile = execfile; */
+/* OBSOLETE xferchan = lib->chan; */
+/* OBSOLETE } */
+/* OBSOLETE } */
+/* OBSOLETE else */
+/* OBSOLETE { */
+/* OBSOLETE i = min (len, stack_end - memaddr); */
+/* OBSOLETE fileptr = memaddr - stack_start + stack_offset; */
+/* OBSOLETE xferfile = &corefile; */
+/* OBSOLETE xferchan = corechan; */
+/* OBSOLETE } */
+/* OBSOLETE } */
+/* OBSOLETE else if (corechan < 0 */
+/* OBSOLETE && memaddr >= exec_data_start && memaddr < exec_data_end) */
+/* OBSOLETE { */
+/* OBSOLETE i = min (len, exec_data_end - memaddr); */
+/* OBSOLETE fileptr = memaddr - exec_data_start + exec_data_offset; */
+/* OBSOLETE xferfile = &execfile; */
+/* OBSOLETE xferchan = execchan; */
+/* OBSOLETE } */
+/* OBSOLETE else if (memaddr >= text_start && memaddr < text_end) */
+/* OBSOLETE { */
+/* OBSOLETE struct shared_library *lib; */
+/* OBSOLETE for (lib = shlib; lib; lib = lib->shares) */
+/* OBSOLETE if (memaddr >= lib->text_start && */
+/* OBSOLETE memaddr < lib->text_start + lib->header.a_exec.a_text) */
+/* OBSOLETE break; */
+/* OBSOLETE if (lib) */
+/* OBSOLETE { */
+/* OBSOLETE i = min (len, lib->header.a_exec.a_text + */
+/* OBSOLETE lib->text_start - memaddr); */
+/* OBSOLETE fileptr = memaddr - lib->text_start + text_offset; */
+/* OBSOLETE xferfile = &execfile; */
+/* OBSOLETE xferchan = lib->chan; */
+/* OBSOLETE } */
+/* OBSOLETE else */
+/* OBSOLETE { */
+/* OBSOLETE i = min (len, text_end - memaddr); */
+/* OBSOLETE fileptr = memaddr - unshared_text_start + text_offset; */
+/* OBSOLETE xferfile = &execfile; */
+/* OBSOLETE xferchan = execchan; */
+/* OBSOLETE } */
+/* OBSOLETE } */
+/* OBSOLETE else if (memaddr < text_start) */
+/* OBSOLETE { */
+/* OBSOLETE i = min (len, text_start - memaddr); */
+/* OBSOLETE } */
+/* OBSOLETE else if (memaddr >= text_end */
+/* OBSOLETE && memaddr < (corechan >= 0 ? data_start : exec_data_start)) */
+/* OBSOLETE { */
+/* OBSOLETE i = min (len, data_start - memaddr); */
+/* OBSOLETE } */
+/* OBSOLETE else if (corechan >= 0 */
+/* OBSOLETE && memaddr >= data_end && memaddr < stack_start) */
+/* OBSOLETE { */
+/* OBSOLETE i = min (len, stack_start - memaddr); */
+/* OBSOLETE } */
+/* OBSOLETE else if (corechan < 0 && memaddr >= exec_data_end) */
+/* OBSOLETE { */
+/* OBSOLETE i = min (len, -memaddr); */
+/* OBSOLETE } */
+/* OBSOLETE else if (memaddr >= stack_end && stack_end != 0) */
+/* OBSOLETE { */
+/* OBSOLETE i = min (len, -memaddr); */
+/* OBSOLETE } */
+/* OBSOLETE else */
+/* OBSOLETE { */
+/* OBSOLETE /* Address did not classify into one of the known ranges. */
+/* OBSOLETE This shouldn't happen; we catch the endpoints. *x/ */
+/* OBSOLETE internal_error ("Bad case logic in xfer_core_file."); */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE /* Now we know which file to use. */
+/* OBSOLETE Set up its pointer and transfer the data. *x/ */
+/* OBSOLETE if (xferfile) */
+/* OBSOLETE { */
+/* OBSOLETE if (*xferfile == 0) */
+/* OBSOLETE if (xferfile == &execfile) */
+/* OBSOLETE error ("No program file to examine."); */
+/* OBSOLETE else */
+/* OBSOLETE error ("No core dump file or running program to examine."); */
+/* OBSOLETE val = lseek (xferchan, fileptr, 0); */
+/* OBSOLETE if (val < 0) */
+/* OBSOLETE perror_with_name (*xferfile); */
+/* OBSOLETE val = myread (xferchan, myaddr, i); */
+/* OBSOLETE if (val < 0) */
+/* OBSOLETE perror_with_name (*xferfile); */
+/* OBSOLETE } */
+/* OBSOLETE /* If this address is for nonexistent memory, */
+/* OBSOLETE read zeros if reading, or do nothing if writing. */
+/* OBSOLETE Actually, we never right. *x/ */
+/* OBSOLETE else */
+/* OBSOLETE { */
+/* OBSOLETE memset (myaddr, '\0', i); */
+/* OBSOLETE returnval = EIO; */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE memaddr += i; */
+/* OBSOLETE myaddr += i; */
+/* OBSOLETE len -= i; */
+/* OBSOLETE } */
+/* OBSOLETE return returnval; */
+/* OBSOLETE } */
+/* OBSOLETE #endif */
void
free_agent_expr (struct agent_expr *x)
{
- free (x->buf);
- free (x);
+ xfree (x->buf);
+ xfree (x);
}
static void
if (ax->buf[i] > (sizeof (aop_map) / sizeof (aop_map[0])))
{
reqs->flaw = agent_flaw_bad_instruction;
- free (reg_mask);
+ xfree (reg_mask);
return;
}
if (!op->name)
{
reqs->flaw = agent_flaw_bad_instruction;
- free (reg_mask);
+ xfree (reg_mask);
return;
}
if (i + 1 + op->op_size > ax->len)
{
reqs->flaw = agent_flaw_incomplete_instruction;
- free (reg_mask);
+ xfree (reg_mask);
return;
}
if (targets[i] && (heights[i] != height))
{
reqs->flaw = agent_flaw_height_mismatch;
- free (reg_mask);
+ xfree (reg_mask);
return;
}
if (target < 0 || target >= ax->len)
{
reqs->flaw = agent_flaw_bad_jump;
- free (reg_mask);
+ xfree (reg_mask);
return;
}
/* Have we already found other jumps to the same location? */
if (heights[i] != height)
{
reqs->flaw = agent_flaw_height_mismatch;
- free (reg_mask);
+ xfree (reg_mask);
return;
}
}
if (!targets[i + 3])
{
reqs->flaw = agent_flaw_hole;
- free (reg_mask);
+ xfree (reg_mask);
return;
}
if (targets[i] && !boundary[i])
{
reqs->flaw = agent_flaw_bad_jump;
- free (reg_mask);
+ xfree (reg_mask);
return;
}
/* Plug in the new table. */
if (bcache->bucket)
- free (bcache->bucket);
+ xfree (bcache->bucket);
bcache->bucket = new_buckets;
bcache->num_buckets = new_num_buckets;
}
{
obstack_free (&bcache->cache, 0);
if (bcache->bucket)
- free (bcache->bucket);
+ xfree (bcache->bucket);
/* This isn't necessary, but at least the bcache is always in a
consistent state. */
if (INNER_THAN (dummy_frame->fp, fp)) /* stale -- destroy! */
{
dummy_frame_stack = dummy_frame->next;
- free (dummy_frame->registers);
- free (dummy_frame);
+ xfree (dummy_frame->registers);
+ xfree (dummy_frame);
dummy_frame = dummy_frame_stack;
}
else
write_register_bytes (0, dummy_frame->registers, REGISTER_BYTES);
flush_cached_frames ();
- free (dummy_frame->registers);
- free (dummy_frame);
+ xfree (dummy_frame->registers);
+ xfree (dummy_frame);
}
/* Function: frame_chain_valid
{
if (b->cond)
{
- free ((PTR) b->cond);
+ xfree (b->cond);
b->cond = 0;
}
if (b->cond_string != NULL)
- free ((PTR) b->cond_string);
+ xfree (b->cond_string);
if (*p == 0)
{
q = p->next;
if (p->old_val != NULL)
value_free (p->old_val);
- free ((PTR) p);
+ xfree (p);
p = q;
}
*bsp = NULL;
catchpoint triggers. Clients who may wish to know the name
later must get it from the catchpoint itself.) */
if (ep->triggered_dll_pathname != NULL)
- free (ep->triggered_dll_pathname);
+ xfree (ep->triggered_dll_pathname);
if (ep->type == bp_catch_load)
dll_pathname = SOLIB_LOADED_LIBRARY_PATHNAME (inferior_pid);
else
/* Make sure that all storage allocated in decode_line_1 gets freed
in case the following errors out. */
- old_chain = make_cleanup (free, sals.sals);
+ old_chain = make_cleanup (xfree, sals.sals);
if (canonical != (char **) NULL)
{
- make_cleanup (free, canonical);
+ make_cleanup (xfree, canonical);
canonical_strings_chain = make_cleanup (null_cleanup, 0);
if (canonical[0] != NULL)
- make_cleanup (free, canonical[0]);
+ make_cleanup (xfree, canonical[0]);
}
resolve_sal_pc (&sals.sals[0]);
old_chain = make_cleanup (null_cleanup, 0);
/* Make sure that all storage allocated to SALS gets freed. */
- make_cleanup (free, sals.sals);
+ make_cleanup (xfree, sals.sals);
/* Cleanup the addr_string array but not its contents. */
- make_cleanup (free, addr_string);
+ make_cleanup (xfree, addr_string);
/* Allocate space for all the cond expressions. */
cond = xcalloc (sals.nelts, sizeof (struct expression *));
- make_cleanup (free, cond);
+ make_cleanup (xfree, cond);
/* Allocate space for all the cond strings. */
cond_string = xcalloc (sals.nelts, sizeof (char **));
- make_cleanup (free, cond_string);
+ make_cleanup (xfree, cond_string);
/* ----------------------------- SNIP -----------------------------
Anything added to the cleanup chain beyond this point is assumed
for (i = 0; i < sals.nelts; i++)
{
if (addr_string[i] != NULL)
- make_cleanup (free, addr_string[i]);
+ make_cleanup (xfree, addr_string[i]);
}
/* Resolve all line numbers to PC's and verify that the addresses
{
tok = cond_start = end_tok + 1;
cond[i] = parse_exp_1 (&tok, block_for_pc (sals.sals[i].pc), 0);
- make_cleanup (free, cond[i]);
+ make_cleanup (xfree, cond[i]);
cond_end = tok;
cond_string[i] = savestring (cond_start, cond_end - cond_start);
- make_cleanup (free, cond_string[i]);
+ make_cleanup (xfree, cond_string[i]);
}
else if (toklen >= 1 && strncmp (tok, "thread", toklen) == 0)
{
old_chain = make_cleanup (null_cleanup, 0);
/* Always have a addr_string array, even if it is empty. */
- make_cleanup (free, addr_string);
+ make_cleanup (xfree, addr_string);
/* Make sure that all storage allocated to SALS gets freed. */
- make_cleanup (free, sals.sals);
+ make_cleanup (xfree, sals.sals);
/* Allocate space for all the cond expressions. */
cond = xcalloc (sals.nelts, sizeof (struct expression *));
- make_cleanup (free, cond);
+ make_cleanup (xfree, cond);
/* Allocate space for all the cond strings. */
cond_string = xcalloc (sals.nelts, sizeof (char **));
- make_cleanup (free, cond_string);
+ make_cleanup (xfree, cond_string);
/* ----------------------------- SNIP -----------------------------
Anything added to the cleanup chain beyond this point is assumed
for (i = 0; i < sals.nelts; i++)
{
if (addr_string[i] != NULL)
- make_cleanup (free, addr_string[i]);
+ make_cleanup (xfree, addr_string[i]);
}
/* Wait until now before checking for garbage at the end of the
cond[i] = parse_exp_1 (&tok, block_for_pc (sals.sals[i].pc), 0);
if (*tok != '\0')
error ("Garbage %s follows condition", tok);
- make_cleanup (free, cond[i]);
+ make_cleanup (xfree, cond[i]);
cond_string[i] = xstrdup (args->condition);
}
}
else
sprintf (addr_string, "*0x%s", paddr_nz (high));
break_command_1 (addr_string, flag, from_tty);
- free (addr_string);
+ xfree (addr_string);
}
else
error ("No function contains the specified address");
sals = decode_line_1 (&addr_string, 1, (struct symtab *) NULL, 0,
(char ***) NULL);
- free (beg_addr_string);
- old_chain = make_cleanup (free, sals.sals);
+ xfree (beg_addr_string);
+ old_chain = make_cleanup (xfree, sals.sals);
for (i = 0; (i < sals.nelts); i++)
{
sal = sals.sals[i];
else
sprintf (break_string, "*0x%s", paddr_nz (high));
break_command_1 (break_string, flag, from_tty);
- free (break_string);
+ xfree (break_string);
}
else
error ("No function contains the specified address");
error ("Couldn't get information on specified line.");
sal = sals.sals[0];
- free ((PTR) sals.sals); /* malloc'd, so freed */
+ xfree (sals.sals); /* malloc'd, so freed */
if (*arg)
error ("Junk at end of arguments.");
warning ("Multiple breakpoints were set.");
warning ("Use the \"delete\" command to delete unwanted breakpoints.");
}
- free ((PTR) sals.sals);
+ xfree (sals.sals);
}
#if 0
if (from_tty)
putchar_unfiltered ('\n');
}
- free ((PTR) sals.sals);
+ xfree (sals.sals);
}
\f
/* Delete breakpoint in BS if they are `delete' breakpoints and
free_command_lines (&bpt->commands);
if (bpt->cond)
- free (bpt->cond);
+ xfree (bpt->cond);
if (bpt->cond_string != NULL)
- free (bpt->cond_string);
+ xfree (bpt->cond_string);
if (bpt->addr_string != NULL)
- free (bpt->addr_string);
+ xfree (bpt->addr_string);
if (bpt->exp != NULL)
- free (bpt->exp);
+ xfree (bpt->exp);
if (bpt->exp_string != NULL)
- free (bpt->exp_string);
+ xfree (bpt->exp_string);
if (bpt->val != NULL)
value_free (bpt->val);
if (bpt->source_file != NULL)
- free (bpt->source_file);
+ xfree (bpt->source_file);
if (bpt->dll_pathname != NULL)
- free (bpt->dll_pathname);
+ xfree (bpt->dll_pathname);
if (bpt->triggered_dll_pathname != NULL)
- free (bpt->triggered_dll_pathname);
+ xfree (bpt->triggered_dll_pathname);
if (bpt->exec_pathname != NULL)
- free (bpt->exec_pathname);
+ xfree (bpt->exec_pathname);
/* Be sure no bpstat's are pointing at it after it's been freed. */
/* FIXME, how can we find all bpstat's?
bp, we mark it as deleted before freeing its storage. */
bpt->type = bp_none;
- free ((PTR) bpt);
+ xfree (bpt);
}
static void
{
s = b->cond_string;
if (b->cond)
- free ((PTR) b->cond);
+ xfree (b->cond);
b->cond = parse_exp_1 (&s, block_for_pc (sals.sals[i].pc), 0);
}
)
{
if (b->source_file != NULL)
- free (b->source_file);
+ xfree (b->source_file);
if (sals.sals[i].symtab == NULL)
b->source_file = NULL;
else
check_duplicates (b->address, b->section);
}
- free ((PTR) sals.sals);
+ xfree (sals.sals);
break;
case bp_watchpoint:
/* So for now, just use a global context. */
if (b->exp)
- free ((PTR) b->exp);
+ xfree (b->exp);
b->exp = parse_expression (b->exp_string);
b->exp_valid_block = innermost_block;
mark = value_mark ();
{
s = b->cond_string;
if (b->cond)
- free ((PTR) b->cond);
+ xfree (b->cond);
b->cond = parse_exp_1 (&s, (struct block *) 0, 0);
}
if (b->enable == enabled)
for (next = free_pendings; next; next = next1)
{
next1 = next->next;
- free ((void *) next);
+ xfree ((void *) next);
}
free_pendings = NULL;
for (next = file_symbols; next != NULL; next = next1)
{
next1 = next->next;
- free ((void *) next);
+ xfree ((void *) next);
}
file_symbols = NULL;
for (next = global_symbols; next != NULL; next = next1)
{
next1 = next->next;
- free ((void *) next);
+ xfree ((void *) next);
}
global_symbols = NULL;
}
for (bnext = pending_blocks; bnext; bnext = bnext1)
{
bnext1 = bnext->next;
- free ((void *) bnext);
+ xfree ((void *) bnext);
}
#endif
pending_blocks = NULL;
for (next = pending_blocks; next; next = next1)
{
next1 = next->next;
- free (next);
+ xfree (next);
}
#endif
pending_blocks = NULL;
}
name = link->name;
subfile_stack = link->next;
- free ((void *) link);
+ xfree ((void *) link);
return (name);
}
\f
}
if (subfile->name != NULL)
{
- free ((void *) subfile->name);
+ xfree ((void *) subfile->name);
}
if (subfile->dirname != NULL)
{
- free ((void *) subfile->dirname);
+ xfree ((void *) subfile->dirname);
}
if (subfile->line_vector != NULL)
{
- free ((void *) subfile->line_vector);
+ xfree ((void *) subfile->line_vector);
}
if (subfile->debugformat != NULL)
{
- free ((void *) subfile->debugformat);
+ xfree ((void *) subfile->debugformat);
}
nextsub = subfile->next;
- free ((void *) subfile);
+ xfree ((void *) subfile);
}
/* Set this for the main source file. */
strncpy (demangled_no_static, demangled_no_class, length);
*(demangled_no_static + length) = '\0';
fputs_filtered (demangled_no_static, stream);
- free (demangled_no_static);
+ xfree (demangled_no_static);
}
else
fputs_filtered (demangled_no_class, stream);
- free (demangled_name);
+ xfree (demangled_name);
}
if (TYPE_FN_FIELD_STUB (f, j))
- free (mangled_name);
+ xfree (mangled_name);
fprintf_filtered (stream, ";\n");
}
completion = line_completion_function (arg, ++i, arg, argpoint))
{
printf_unfiltered ("%s\n", completion);
- free (completion);
+ xfree (completion);
}
}
error_no_arg ("new working directory");
dir = tilde_expand (dir);
- make_cleanup (free, dir);
+ make_cleanup (xfree, dir);
if (chdir (dir) < 0)
perror_with_name (dir);
current_directory = concat (current_directory, dir, NULL);
else
current_directory = concat (current_directory, SLASH_STRING, dir, NULL);
- free (dir);
+ xfree (dir);
}
/* Now simplify any occurrences of `.' and `..' in the pathname. */
}
file = tilde_expand (file);
- old_cleanups = make_cleanup (free, file);
+ old_cleanups = make_cleanup (xfree, file);
stream = fopen (file, FOPEN_RT);
if (!stream)
if ((*list)->hookee_post)
(*list)->hookee_post->hook_post = 0; /* Hook slips out of its bottom */
p = (*list)->next;
- free ((PTR) * list);
+ xfree (* list);
*list = p;
}
c->next->hookee_post->hook_post = 0; /* remove post hook */
/* :( no fishing metaphore */
p = c->next->next;
- free ((PTR) c->next);
+ xfree (c->next);
c->next = p;
}
else
if (p - str > line_size - 1)
{
line_size = p - str + 1;
- free ((PTR) line_buffer);
+ xfree (line_buffer);
line_buffer = (char *) xmalloc (line_size);
}
strncpy (line_buffer, str, p - str);
if (matches == 0)
{
- free ((PTR) matchlist);
+ xfree (matchlist);
matchlist = 0;
}
else
if (matches == 0)
{
- free ((PTR) matchlist);
+ xfree (matchlist);
matchlist = 0;
}
else
internal_error ("Internal error, arg_cleanup called with no user args.\n");
user_args = user_args->next;
- free (oargs);
+ xfree (oargs);
}
/* Bind the incomming arguments for a user defined command to
memcpy (body_list, command->body_list, sizeof (struct command_line *) * n);
- free (command->body_list);
+ xfree (command->body_list);
command->body_list = body_list;
command->body_count = new_length;
}
free_command_lines (blist);
}
next = l->next;
- free (l->line);
- free ((PTR) l);
+ xfree (l->line);
+ xfree (l);
l = next;
}
}
doclines = read_command_lines (tmpbuf, from_tty);
if (c->doc)
- free (c->doc);
+ xfree (c->doc);
{
register struct command_line *cl1;
source_file_name = file;
source_pre_error = error_pre_print == NULL ? "" : error_pre_print;
source_pre_error = savestring (source_pre_error, strlen (source_pre_error));
- make_cleanup (free, source_pre_error);
+ make_cleanup (xfree, source_pre_error);
/* This will get set every time we read a line. So it won't stay "" for
long. */
error_pre_print = "";
*q++ = '\0';
new = (char *) xrealloc (new, q - new);
if (*(char **) c->var != NULL)
- free (*(char **) c->var);
+ xfree (*(char **) c->var);
*(char **) c->var = new;
}
break;
if (arg == NULL)
arg = "";
if (*(char **) c->var != NULL)
- free (*(char **) c->var);
+ xfree (*(char **) c->var);
*(char **) c->var = savestring (arg, strlen (arg));
break;
case var_filename:
if (arg == NULL)
error_no_arg ("filename to set it to.");
if (*(char **) c->var != NULL)
- free (*(char **) c->var);
+ xfree (*(char **) c->var);
*(char **) c->var = tilde_expand (arg);
break;
case var_boolean:
/* This will be run after coffstab_build_psymtabs is called
in coff_symfile_read, at which point we no longer need
the information. */
- make_cleanup (free, n);
+ make_cleanup (xfree, n);
}
}
}
complete_symtab (char *name, CORE_ADDR start_addr, unsigned int size)
{
if (last_source_file != NULL)
- free (last_source_file);
+ xfree (last_source_file);
last_source_file = savestring (name, strlen (name));
current_source_start_addr = start_addr;
current_source_end_addr = start_addr + size;
memset (opaque_type_chain, 0, sizeof opaque_type_chain);
if (type_vector) /* Get rid of previous one */
- free ((PTR) type_vector);
+ xfree (type_vector);
type_vector_length = 160;
type_vector = (struct type **)
xmalloc (type_vector_length * sizeof (struct type *));
free_stringtab (void)
{
if (stringtab)
- free (stringtab);
+ xfree (stringtab);
stringtab = NULL;
}
free_linetab (void)
{
if (linetab)
- free (linetab);
+ xfree (linetab);
linetab = NULL;
}
if (TYPE_NAME (real_target))
{
if (TYPE_NAME (target))
- free (TYPE_NAME (target));
+ xfree (TYPE_NAME (target));
TYPE_NAME (target) = concat (TYPE_NAME (real_target), NULL);
}
}
q = xmalloc (strlen (p) + 5);
strcpy (q, p + (word - text));
return_val[return_val_used++] = q;
- free (p);
+ xfree (p);
}
else
{
q[text - word] = '\0';
strcat (q, p);
return_val[return_val_used++] = q;
- free (p);
+ xfree (p);
}
}
}
{
/* Free the storage used by LIST, but not by the strings inside.
This is because rl_complete_internal () frees the strings. */
- free ((PTR) list);
+ xfree (list);
}
list = 0;
index = 0;
/* OBSOLETE Mark text segment as empty. *x/ */
/* OBSOLETE */
/* OBSOLETE if (execfile) */
-/* OBSOLETE free (execfile); */
+/* OBSOLETE xfree (execfile); */
/* OBSOLETE execfile = 0; */
/* OBSOLETE data_start = 0; */
/* OBSOLETE data_end = 0; */
/* OBSOLETE if (filename) */
/* OBSOLETE { */
/* OBSOLETE filename = tilde_expand (filename); */
-/* OBSOLETE make_cleanup (free, filename); */
+/* OBSOLETE make_cleanup (xfree, filename); */
/* OBSOLETE */
/* OBSOLETE execchan = openp (getenv ("PATH"), 1, filename, O_RDONLY, 0, */
/* OBSOLETE &execfile); */
/* OBSOLETE and mark data and stack spaces as empty. *x/ */
/* OBSOLETE */
/* OBSOLETE if (corefile) */
-/* OBSOLETE free (corefile); */
+/* OBSOLETE xfree (corefile); */
/* OBSOLETE corefile = 0; */
/* OBSOLETE */
/* OBSOLETE if (corechan >= 0) */
/* OBSOLETE if (filename) */
/* OBSOLETE { */
/* OBSOLETE filename = tilde_expand (filename); */
-/* OBSOLETE make_cleanup (free, filename); */
+/* OBSOLETE make_cleanup (xfree, filename); */
/* OBSOLETE */
/* OBSOLETE if (have_inferior_p ()) */
/* OBSOLETE error ("To look at a core file, you must kill the program with \"kill\"."); */
{
char *symfile_copy = xstrdup (symfile);
- make_cleanup (free, symfile_copy);
+ make_cleanup (xfree, symfile_copy);
symbol_file_command (symfile_copy, from_tty);
}
else
/* If the timestamp of the exec file has changed, reopen it. */
filename = xstrdup (bfd_get_filename (exec_bfd));
- make_cleanup (free, filename);
+ make_cleanup (xfree, filename);
mtime = bfd_get_mtime (exec_bfd);
res = stat (filename, &st);
set_gnutarget (char *newtarget)
{
if (gnutarget_string != NULL)
- free (gnutarget_string);
+ xfree (gnutarget_string);
gnutarget_string = savestring (newtarget, strlen (newtarget));
set_gnutarget_command (NULL, 0, NULL);
}
if (!bfd_close (core_bfd))
warning ("cannot close \"%s\": %s",
name, bfd_errmsg (bfd_get_error ()));
- free (name);
+ xfree (name);
core_bfd = NULL;
if (core_ops.to_sections)
{
- free ((PTR) core_ops.to_sections);
+ xfree (core_ops.to_sections);
core_ops.to_sections = NULL;
core_ops.to_sections_end = NULL;
}
if (filename[0] != '/')
{
temp = concat (current_directory, "/", filename, NULL);
- free (filename);
+ xfree (filename);
filename = temp;
}
- old_chain = make_cleanup (free, filename);
+ old_chain = make_cleanup (xfree, filename);
scratch_chan = open (filename, O_BINARY | ( write_files ? O_RDWR : O_RDONLY ), 0);
if (scratch_chan < 0)
else
{
fputs_filtered (demangled_name, stream);
- free (demangled_name);
+ xfree (demangled_name);
}
}
else
obstack_begin (&dont_print_vb_obstack, 32 * sizeof (struct type *));
obstack_specify_allocation (&dont_print_statmem_obstack,
32 * sizeof (CORE_ADDR), sizeof (CORE_ADDR),
- xmalloc, free);
+ xmalloc, xfree);
}
section_addrs.other[0].addr = lms.l_addr;
section_addrs.other[0].name = ".text";
symbol_file_add (path_name, 1, §ion_addrs, 0, 0);
- free (path_name);
+ xfree (path_name);
}
}
/* traverse links in reverse order so that we get the
{
struct stack_item *dead = si;
si = si->prev;
- free (dead->data);
- free (dead);
+ xfree (dead->data);
+ xfree (dead);
return si;
}
oldsize = trace_data.size;
trace_data.size += count;
- free (tmpspace);
+ xfree (tmpspace);
if (trace_display)
display_trace (oldsize, trace_data.size);
oldsize = trace_data.size;
trace_data.size += count;
- free (tmpspace);
+ xfree (tmpspace);
if (trace_display)
display_trace (oldsize, trace_data.size);
{
if (this_object_header_files)
{
- free ((PTR) this_object_header_files);
+ xfree (this_object_header_files);
this_object_header_files = NULL;
}
n_allocated_this_object_header_files = 0;
while (--i >= 0)
{
- free (hfiles[i].name);
- free (hfiles[i].vector);
+ xfree (hfiles[i].name);
+ xfree (hfiles[i].vector);
}
- free ((PTR) hfiles);
+ xfree (hfiles);
}
mfree (objfile->md, objfile->sym_stab_info);
}
return;
dynsyms = (asymbol **) xmalloc (dynsym_size);
- back_to = make_cleanup (free, dynsyms);
+ back_to = make_cleanup (xfree, dynsyms);
dynsym_count = bfd_canonicalize_dynamic_symtab (abfd, dynsyms);
if (dynsym_count < 0)
}
dynrels = (arelent **) xmalloc (dynrel_size);
- make_cleanup (free, dynrels);
+ make_cleanup (xfree, dynrels);
dynrel_count = bfd_canonicalize_dynamic_reloc (abfd, dynrels, dynsyms);
if (dynrel_count < 0)
if (last_cache == dcache)
last_cache = NULL;
- free (dcache->the_cache);
- free (dcache);
+ xfree (dcache->the_cache);
+ xfree (dcache);
}
/* Read or write LEN bytes from inferior memory at MEMADDR, transferring
extern void null_cleanup (void *);
+extern void xfree (void *);
+
extern int myread (int, char *, int);
extern int query (char *, ...) ATTR_FORMAT (printf, 1, 2);
dem->demangling_style_doc);
if (dem->demangling_style == current_demangling_style)
{
- free (current_demangling_style_string);
+ xfree (current_demangling_style_string);
current_demangling_style_string =
savestring (dem->demangling_style_name,
strlen (dem->demangling_style_name));
{
if (current_demangling_style_string != NULL)
{
- free (current_demangling_style_string);
+ xfree (current_demangling_style_string);
}
current_demangling_style_string = savestring (style, strlen (style));
set_demangling_command ((char *) NULL, 0, (struct cmd_list_element *) NULL);
/* Initialize the source file line number information for this file. */
if (line_vector) /* Unlikely, but maybe possible? */
- free ((PTR) line_vector);
+ xfree (line_vector);
line_vector_index = 0;
line_vector_length = 1000;
prev_line_number = -2; /* Force first line number to be explicit */
type = find_dst_structure (name);
if (type)
{
- free ((PTR) name);
+ xfree (name);
return type;
}
type = create_new_type (objfile);
TYPE_NAME (type) = obstack_copy0 (&objfile->symbol_obstack,
name, strlen (name));
- free ((PTR) name);
+ xfree (name);
TYPE_CODE (type) = code;
TYPE_LENGTH (type) = DST_record (entry).size;
TYPE_NFIELDS (type) = DST_record (entry).nfields;
block->sym[symnum] = symlist->symbol;
- free ((PTR) symlist);
+ xfree (symlist);
symlist = nextsym;
symnum++;
}
global_block->sym[symnum] =
dst_global_symbols->symbol;
- free ((PTR) dst_global_symbols);
+ xfree (dst_global_symbols);
dst_global_symbols = nextsym;
}
dst_global_symbols = NULL;
{
element = struct_list;
struct_list = element->next;
- free ((PTR) element);
+ xfree (element);
}
}
\f
buffer = (unsigned char *) xmalloc (section_size);
bfd_get_section_contents (abfd, s, buffer, 0, section_size);
process_read_request (buffer, section_size);
- free (buffer);
+ xfree (buffer);
}
}
/* Allocate a new field list entry and link it in. */
new_field = (struct nextfield *) xmalloc (sizeof (struct nextfield));
- make_cleanup (free, new_field);
+ make_cleanup (xfree, new_field);
memset (new_field, 0, sizeof (struct nextfield));
new_field->next = fip->fields;
fip->fields = new_field;
/* Create a new member function field and chain it to the field list
entry. */
new_fnfield = (struct nextfnfield *) xmalloc (sizeof (struct nextfnfield));
- make_cleanup (free, new_fnfield);
+ make_cleanup (xfree, new_fnfield);
memset (new_fnfield, 0, sizeof (struct nextfnfield));
new_fnfield->next = flp->head;
flp->head = new_fnfield;
TYPE_ALLOC (type, sizeof (struct field) * num_fields);
memcpy (TYPE_FIELDS (type), fields,
sizeof (struct field) * num_fields);
- free (fields);
+ xfree (fields);
}
if (unsigned_enum)
TYPE_FLAGS (type) |= TYPE_FLAG_UNSIGNED;
while (die)
{
next = die->next;
- free (die->attrs);
- free (die);
+ xfree (die->attrs);
+ xfree (die);
die = next;
}
}
while (abbrev)
{
next = abbrev->next;
- free (abbrev->attrs);
- free (abbrev);
+ xfree (abbrev->attrs);
+ xfree (abbrev);
abbrev = next;
}
dwarf2_abbrevs[i] = NULL;
if (STREQ (subfile->name, fullname))
{
current_subfile = subfile;
- free (fullname);
+ xfree (fullname);
return;
}
}
- free (fullname);
+ xfree (fullname);
}
start_subfile (filename, dirname);
}
if ((bfd_seek (abfd, dbfoff, SEEK_SET) != 0) ||
(bfd_read (dbbase, dbsize, 1, abfd) != dbsize))
{
- free (dbbase);
+ xfree (dbbase);
error ("can't read DWARF data from '%s'", bfd_get_filename (abfd));
}
- back_to = make_cleanup (free, dbbase);
+ back_to = make_cleanup (xfree, dbbase);
/* If we are reinitializing, or if we have never loaded syms yet, init.
Since we have no idea how many DIES we are looking at, we just guess
static void
free_utypes (PTR dummy)
{
- free (utypes);
+ xfree (utypes);
utypes = NULL;
numutypes = 0;
}
if (bfd_seek (abfd, foffset, SEEK_SET) ||
(bfd_read (dbbase, dbsize, 1, abfd) != dbsize))
{
- free (dbbase);
+ xfree (dbbase);
error ("can't read DWARF data");
}
- back_to = make_cleanup (free, dbbase);
+ back_to = make_cleanup (xfree, dbbase);
/* If there is a line number table associated with this compilation unit
then read the size of this fragment in bytes, from the fragment itself.
if (bfd_seek (abfd, LNFOFF (pst), SEEK_SET) ||
(bfd_read (lnbase, lnsize, 1, abfd) != lnsize))
{
- free (lnbase);
+ xfree (lnbase);
error ("can't read DWARF line numbers");
}
- make_cleanup (free, lnbase);
+ make_cleanup (xfree, lnbase);
}
process_dies (dbbase, dbbase + dbsize, pst->objfile);
if (storage_needed > 0)
{
symbol_table = (asymbol **) xmalloc (storage_needed);
- back_to = make_cleanup (free, symbol_table);
+ back_to = make_cleanup (xfree, symbol_table);
if (dynamic)
number_of_symbols = bfd_canonicalize_dynamic_symtab (objfile->obfd,
symbol_table);
register char **vector = e->vector;
while (*vector)
- free (*vector++);
+ xfree (*vector++);
- free (e);
+ xfree (e);
}
/* Copy the environment given to this process into E.
vector[i + 1] = 0;
}
else
- free (s);
+ xfree (s);
s = (char *) xmalloc (len + strlen (value) + 2);
strcpy (s, var);
{
if (STREQN (s, var, len) && s[len] == '=')
{
- free (s);
+ xfree (s);
/* Walk through the vector, shuffling args down by one, including
the NULL terminator. Can't use memcpy() here since the regions
overlap, and memmove() might not be available. */
if (event_ptr->next_event == NULL)
event_queue.last_event = prev_ptr;
}
- free ((char *) event_ptr);
+ xfree (event_ptr);
/* Now call the procedure associated with the event. */
(*proc) (fd);
j++;
}
}
- free (gdb_notifier.poll_fds);
+ xfree (gdb_notifier.poll_fds);
gdb_notifier.poll_fds = new_poll_fds;
gdb_notifier.num_fds--;
#else
;
prev_ptr->next_file = file_ptr->next_file;
}
- free ((char *) file_ptr);
+ xfree (file_ptr);
}
/* Handle the given event by calling the procedure associated to the
if (sighandler_list.last_handler == (*async_handler_ptr))
sighandler_list.last_handler = prev_ptr;
}
- free ((char *) (*async_handler_ptr));
+ xfree ((*async_handler_ptr));
(*async_handler_ptr) = NULL;
}
;
prev_timer->next = timer_ptr->next;
}
- free ((char *) timer_ptr);
+ xfree (timer_ptr);
gdb_notifier.timeout_valid = 0;
}
timer_ptr = timer_ptr->next;
/* Call the procedure associated with that timer. */
(*saved_timer->proc) (saved_timer->client_data);
- free (saved_timer);
+ xfree (saved_timer);
}
gdb_notifier.timeout_valid = 0;
in effect, until the user does another 'set prompt'. */
if (strcmp (PROMPT (0), PROMPT (-1)))
{
- free (PROMPT (-1));
+ xfree (PROMPT (-1));
PROMPT (-1) = savestring (PROMPT (0), strlen (PROMPT (0)));
}
- free (PREFIX (0));
- free (PROMPT (0));
- free (SUFFIX (0));
+ xfree (PREFIX (0));
+ xfree (PROMPT (0));
+ xfree (SUFFIX (0));
the_prompts.top--;
}
{
strcpy (linebuffer, readline_input_state.linebuffer);
p = readline_input_state.linebuffer_ptr;
- free (readline_input_state.linebuffer);
+ xfree (readline_input_state.linebuffer);
more_to_come = 0;
pop_prompt ();
}
while (*p1)
*p++ = *p1++;
- free (rl); /* Allocated in readline. */
+ xfree (rl); /* Allocated in readline. */
if (*(p - 1) == '\\')
{
/* If there was an error, call this function again. */
if (expanded < 0)
{
- free (history_value);
+ xfree (history_value);
return;
}
if (strlen (history_value) > linelength)
}
strcpy (linebuffer, history_value);
p = linebuffer + strlen (linebuffer);
- free (history_value);
+ xfree (history_value);
}
}
if we are called again fgetc will still return EOF and
we'll return NULL then. */
break;
- free (result);
+ xfree (result);
(*input_handler) (0);
}
FIXME-as-well: free_objfile already free'd vp->name, so it isn't
valid here. */
free_named_symtabs (vp->name);
- free (vp);
+ xfree (vp);
}
vmap = NULL;
if (!bfd_close (exec_bfd))
warning ("cannot close \"%s\": %s",
name, bfd_errmsg (bfd_get_error ()));
- free (name);
+ xfree (name);
exec_bfd = NULL;
}
if (exec_ops.to_sections)
{
- free ((PTR) exec_ops.to_sections);
+ xfree (exec_ops.to_sections);
exec_ops.to_sections = NULL;
exec_ops.to_sections_end = NULL;
}
error ("No executable file name was specified");
filename = tilde_expand (*argv);
- make_cleanup (free, filename);
+ make_cleanup (xfree, filename);
scratch_chan = openp (getenv ("PATH"), 1, filename,
write_files ? O_RDWR | O_BINARY : O_RDONLY | O_BINARY, 0,
via the exec_bfd->name pointer, so we need to make another copy and
leave exec_bfd as the new owner of the original copy. */
scratch_pathname = xstrdup (scratch_pathname);
- make_cleanup (free, scratch_pathname);
+ make_cleanup (xfree, scratch_pathname);
if (!bfd_check_format (exec_bfd, bfd_object))
{
count = bfd_count_sections (some_bfd);
if (*start)
- free ((PTR) * start);
+ xfree (* start);
*start = (struct section_table *) xmalloc (count * sizeof (**start));
*end = *start;
bfd_map_over_sections (some_bfd, add_to_section_table, (char *) end);
STREQ (name, BLANK_COMMON_NAME_MF77))
{
- free (name);
+ xfree (name);
name = alloca (strlen (BLANK_COMMON_NAME_LOCAL) + 1);
strcpy (name, BLANK_COMMON_NAME_LOCAL);
}
if ((STREQ (name, BLANK_COMMON_NAME_ORIGINAL)) ||
(STREQ (name, BLANK_COMMON_NAME_MF77)))
{
- free (name);
+ xfree (name);
name = alloca (strlen (BLANK_COMMON_NAME_LOCAL) + 1);
strcpy (name, BLANK_COMMON_NAME_LOCAL);
}
while (tmp != NULL)
{
next = tmp->next;
- free (tmp);
+ xfree (tmp);
tmp = next;
}
saved_bf_list = NULL;
while (tmp != NULL)
{
next = tmp->next;
- free (tmp);
+ xfree (tmp);
tmp = next;
}
{
struct event *event = delivering_events;
delivering_events = event->next;
- free (event);
+ xfree (event);
}
/* Process any pending events. Because one of the deliveries could
bail out we move everything off of the pending queue onto an
break;
}
delivering_events = event->next;
- free (event);
+ xfree (event);
}
}
gdbarch_free (struct gdbarch *arch)
{
/* At the moment, this is trivial. */
- free (arch);
+ xfree (arch);
}
printf ("add_mangled_type: %s\n", extras.str); /* FIXME */
arm_mangled_name = malloc (strlen (mangled_name) + extras.len);
sprintf (arm_mangled_name, "%s%s", mangled_name, extras.str);
- free (mangled_name);
+ xfree (mangled_name);
mangled_name = arm_mangled_name;
}
}
argtypes[argcount] = NULL; /* Ellist terminator */
}
- free (demangled_name);
+ xfree (demangled_name);
f = TYPE_FN_FIELDLIST1 (type, method_id);
while (tmp_vbase)
{
tmp_vbase = tmp_vbase->next;
- free (tmp_vbase_2);
+ xfree (tmp_vbase_2);
tmp_vbase_2 = tmp_vbase;
}
mach_port_deallocate (mach_task_self (), proc->port);
}
- free (proc);
+ xfree (proc);
return next;
}
get_saved_register (regbuf, NULL, NULL, selected_frame, regnum, NULL);
regval |= regbuf[0] << 8 | regbuf[1]; /* XXX host/target byte order */
- free (var->value); /* Free up old value */
+ xfree (var->value); /* Free up old value */
var->value = value_from_longest (builtin_type_unsigned_long, regval);
release_value (var->value); /* Unchain new value */
{
pst_syms_count = 0;
pst_syms_size = 0;
- free (pst_syms_array);
+ xfree (pst_syms_array);
pst_syms_array = 0;
}
/* Prepare for the next psymtab. */
global_syms = objfile->global_psymbols.next;
static_syms = objfile->static_psymbols.next;
- free (class_entered);
+ xfree (class_entered);
curr_fd++;
} /* Psymtab for file */
/* Prepare for the next psymtab. */
global_syms = objfile->global_psymbols.next;
static_syms = objfile->static_psymbols.next;
- free (class_entered);
+ xfree (class_entered);
curr_md++;
curr_fd++;
/* No, we still fail. Okay, time to punt. */
if ((pt_status == -1) && errno)
{
- free (buffer);
+ xfree (buffer);
return 0;
}
}
inferior_pid, (PTRACE_ARG3_TYPE) addr, 0);
if (errno)
{
- free (buffer);
+ xfree (buffer);
return 0;
}
QUIT;
/* Copy appropriate bytes out of the buffer. */
memcpy (myaddr, (char *) buffer + (memaddr & (sizeof (int) - 1)), len);
}
- free (buffer);
+ xfree (buffer);
return len;
}
if (args)
{
cmd = concat ("set args ", args, NULL);
- make_cleanup (free, cmd);
+ make_cleanup (xfree, cmd);
execute_command (cmd, from_tty);
}
}
}
sal = sals.sals[0];
- free ((PTR) sals.sals);
+ xfree (sals.sals);
if (sal.symtab == 0 && sal.pc == 0)
error ("No source file has been specified.");
}
else
set_in_environ (inferior_environ, var, val);
- free (var);
+ xfree (var);
}
static void
exec_path = strsave (env);
mod_path (dirname, &exec_path);
set_in_environ (inferior_environ, path_var_name, exec_path);
- free (exec_path);
+ xfree (exec_path);
if (from_tty)
path_info ((char *) NULL, from_tty);
}
/* We could just as well copy our_ttystate (if we felt like adding
a new function SERIAL_COPY_TTY_STATE). */
if (inferior_ttystate)
- free (inferior_ttystate);
+ xfree (inferior_ttystate);
inferior_ttystate = SERIAL_GET_TTY_STATE (stdin_serial);
#ifdef PROCESS_GROUP_TYPE
#endif
if (inferior_ttystate)
- free (inferior_ttystate);
+ xfree (inferior_ttystate);
inferior_ttystate = SERIAL_GET_TTY_STATE (stdin_serial);
#ifdef HAVE_TERMIOS
inferior_process_group = tcgetpgrp (0);
pending_follow.fork_event.saw_child_exec = 0;
pending_follow.kind = TARGET_WAITKIND_SPURIOUS;
follow_exec (inferior_pid, pending_follow.execd_pathname);
- free (pending_follow.execd_pathname);
+ xfree (pending_follow.execd_pathname);
}
}
/* This causes the eventpoints and symbol table to be reset. Must
do this now, before trying to determine whether to stop. */
follow_exec (inferior_pid, pending_follow.execd_pathname);
- free (pending_follow.execd_pathname);
+ xfree (pending_follow.execd_pathname);
stop_pc = read_pc_pid (ecs->pid);
ecs->saved_inferior_pid = inferior_pid;
else
printf_filtered ("Invalid signal handling flag.\n");
if (argBuf)
- free (argBuf);
+ xfree (argBuf);
}
}
do_cleanups (old_chain);
static void
free_inferior_status (struct inferior_status *inf_status)
{
- free (inf_status->registers);
- free (inf_status->stop_registers);
- free (inf_status);
+ xfree (inf_status->registers);
+ xfree (inf_status->stop_registers);
+ xfree (inf_status);
}
void
{
q = p;
p = p->next;
- free (q);
+ xfree (q);
}
thread_head.head = NULL;
{
q = p;
p = p->next;
- free (q);
+ xfree (q);
}
deleted_threads.head = NULL;
t = t->next;
}
- free (paranoia);
+ xfree (paranoia);
call_ttrace (TT_PROC_STOP,
inferior_pid,
memory_page_dictionary.page_count--;
- free (page);
+ xfree (page);
}
bfd *abfd;
filename = tilde_expand (so->so_name);
- old_chain = make_cleanup (free, filename);
+ old_chain = make_cleanup (xfree, filename);
scratch_chan = openp (getenv ("PATH"), 1, filename, O_RDONLY, 0,
&scratch_pathname);
{
if (so_list_head->sections)
{
- free ((PTR) so_list_head->sections);
+ xfree (so_list_head->sections);
}
if (so_list_head->abfd)
{
next = so_list_head->next;
if (bfd_filename)
- free ((PTR) bfd_filename);
- free (so_list_head->so_name);
- free ((PTR) so_list_head);
+ xfree (bfd_filename);
+ xfree (so_list_head->so_name);
+ xfree (so_list_head);
so_list_head = next;
}
debug_base = 0;
{ /* array type */
char *name = java_demangle_type_signature (TYPE_TAG_NAME (type));
fputs_filtered (name, stream);
- free (name);
+ xfree (name);
break;
}
}
fputs_filtered (demangled_no_class, stream);
- free (demangled_name);
+ xfree (demangled_name);
}
if (TYPE_FN_FIELD_STUB (f, j))
- free (mangled_name);
+ xfree (mangled_name);
fprintf_filtered (stream, ";\n");
}
/* Free memory. */
for (i = 0; i < sync_next; ++i)
- free (sync_ids[i]);
- free (sync_ids);
+ xfree (sync_ids[i]);
+ xfree (sync_ids);
}
if (old_operating_system)
{
delete_cmd (old_operating_system, &infolist);
- free (old_operating_system);
+ xfree (old_operating_system);
}
old_operating_system = xstrdup (operating_system);
p = "Unknown KOD library";
printf_filtered ("%s - %s\n", operating_system, p);
- free (kodlib);
+ xfree (kodlib);
}
}
/* Reset the language (esp. the global string "language") to the
correct values. */
err_lang = savestring (language, strlen (language));
- make_cleanup (free, err_lang); /* Free it after error */
+ make_cleanup (xfree, err_lang); /* Free it after error */
set_language (current_language->la_language);
error ("Unknown language `%s'.", err_lang);
}
char *prefix = "";
if (language)
- free (language);
+ xfree (language);
if (language_mode == language_mode_auto)
prefix = "auto; currently ";
char *tmp = NULL, *prefix = "";
if (type)
- free (type);
+ xfree (type);
if (type_mode == type_mode_auto)
prefix = "auto; currently ";
}
if (range)
- free (range);
+ xfree (range);
range = concat (pref, tmp, NULL);
}
error ("Unrecognized case-sensitive setting.");
}
- free (case_sensitive);
+ xfree (case_sensitive);
case_sensitive = concat (prefix, tmp, NULL);
}
for (lp = lwp_list; lp; lp = lpnext)
{
lpnext = lp->next;
- free (lp);
+ xfree (lp);
}
lwp_list = NULL;
else
lwp_list = lp->next;
- free (lp);
+ xfree (lp);
}
/* Return a pointer to the structure describing the LWP corresponding
{
int *saved_pid_ptr = arg;
inferior_pid = *saved_pid_ptr;
- free (arg);
+ xfree (arg);
}
static struct cleanup *
{
int *saved_pid_ptr = arg;
inferior_pid = *saved_pid_ptr;
- free (arg);
+ xfree (arg);
}
/*
field_counter);
phys_name = alloca (strlen (tmp_name) + 1);
strcpy (phys_name, tmp_name);
- free (tmp_name);
+ xfree (tmp_name);
}
else
phys_name = TYPE_FN_FIELD_PHYSNAME (f, field_counter);
alloca (nelts * sizeof (struct symtab_and_line));
return_values.sals = (struct symtab_and_line *)
xmalloc (nelts * sizeof (struct symtab_and_line));
- old_chain = make_cleanup (free, return_values.sals);
+ old_chain = make_cleanup (xfree, return_values.sals);
if (canonical)
{
canonical_arr = (char **) xmalloc (nelts * sizeof (char *));
- make_cleanup (free, canonical_arr);
+ make_cleanup (xfree, canonical_arr);
memset (canonical_arr, 0, nelts * sizeof (char *));
*canonical = canonical_arr;
}
if (canonical_arr)
{
symname = SYMBOL_NAME (sym_arr[num]);
- make_cleanup (free, symname);
+ make_cleanup (xfree, symname);
canonical_arr[i] = savestring (symname, strlen (symname));
}
return_values.sals[i++] = values.sals[num];
{
int *saved_pid_ptr = arg;
inferior_pid = *saved_pid_ptr;
- free (arg);
+ xfree (arg);
}
/* Register a cleanup to restore the value of inferior_pid. */
for (i = 0; i < ndir; i++)
catch_command_errors (directory_command, dirarg[i], 0, RETURN_MASK_ALL);
- free ((PTR) dirarg);
+ xfree (dirarg);
if (execarg != NULL
&& symarg != NULL
#endif
catch_command_errors (source_command, cmdarg[i], !batch, RETURN_MASK_ALL);
}
- free ((PTR) cmdarg);
+ xfree (cmdarg);
/* Read in the old history after all the command files have been read. */
init_history ();
if (demangled != NULL)
{
printf_unfiltered ("%s\n", demangled);
- free (demangled);
+ xfree (demangled);
}
else
{
{
if (alias->flags & MALLOCED_REPLACEMENT)
- free (alias->replacement);
+ xfree (alias->replacement);
if (deprecate)
alias->flags |= (DEPRECATED_WARN_USER | CMD_DEPRECATED);
else if (cmd)
{
if (cmd->flags & MALLOCED_REPLACEMENT)
- free (cmd->replacement);
+ xfree (cmd->replacement);
if (deprecate)
cmd->flags |= (DEPRECATED_WARN_USER | CMD_DEPRECATED);
Minor hack: -O3 images might claim some global data belongs
to FDR -1. We`ll go along with that */
fdr_to_pst = (struct pst_map *) xzalloc ((hdr->ifdMax + 1) * sizeof *fdr_to_pst);
- old_chain = make_cleanup (free, fdr_to_pst);
+ old_chain = make_cleanup (xfree, fdr_to_pst);
fdr_to_pst++;
{
struct partial_symtab *pst = new_psymtab ("", objfile);
/* Pass 0 over external syms: swap them in. */
ext_block = (EXTR *) xmalloc (hdr->iextMax * sizeof (EXTR));
- make_cleanup (free, ext_block);
+ make_cleanup (xfree, ext_block);
ext_out = (char *) debug_info->external_ext;
ext_out_end = ext_out + hdr->iextMax * external_ext_size;
if (stabstring
&& stabstring != debug_info->ss + fh->issBase + sh.iss)
- free (stabstring);
+ xfree (stabstring);
}
/* end - Handle continuation */
}
PDR *pdr_in_end;
pr_block = (PDR *) xmalloc (fh->cpd * sizeof (PDR));
- old_chain = make_cleanup (free, pr_block);
+ old_chain = make_cleanup (xfree, pr_block);
pdr_ptr = ((char *) debug_info->external_pdr
+ fh->ipdFirst * external_pdr_size);
pr_block = (PDR *) xmalloc (fh->cpd * sizeof (PDR));
- old_chain = make_cleanup (free, pr_block);
+ old_chain = make_cleanup (xfree, pr_block);
pdr_ptr = ((char *) debug_info->external_pdr
+ fh->ipdFirst * external_pdr_size);
ui_out_field_int (uiout, "offset", offset);
}
if (filename != NULL)
- free (filename);
+ xfree (filename);
if (name != NULL)
- free (name);
+ xfree (name);
ui_file_rewind (stb->stream);
pc += (*tm_print_insn) (pc, &di);
ui_out_field_int (uiout, "offset", offset);
}
if (filename != NULL)
- free (filename);
+ xfree (filename);
if (name != NULL)
- free (name);
+ xfree (name);
ui_file_rewind (stb->stream);
pc += (*tm_print_insn) (pc, &di);
old_cleanups = make_cleanup (free_current_contents, &name);
frame = xstrdup (argv[1]);
- old_cleanups = make_cleanup (free, frame);
+ old_cleanups = make_cleanup (xfree, frame);
expr = xstrdup (argv[2]);
if (strcmp (name, "-") == 0)
{
- free (name);
+ xfree (name);
name = varobj_gen_name ();
}
else if (!isalpha (*name))
else
{
ui_out_field_string (uiout, "type", type);
- free (type);
+ xfree (type);
}
do_cleanups (old_cleanups);
if (strcmp (name, "-c") != 0)
error ("mi_cmd_var_delete: Invalid option.");
children_only_p = 1;
- free (name);
+ xfree (name);
name = xstrdup (expr);
- free (expr);
+ xfree (expr);
}
/* If we didn't error out, now NAME contains the name of the
cc++;
}
ui_out_list_end (uiout);
- free (childlist);
+ xfree (childlist);
return MI_CMD_DONE;
}
varobj_update_one (*cr);
cr++;
}
- free (rootlist);
+ xfree (rootlist);
ui_out_list_end (uiout);
}
else
ui_out_field_string (uiout, "type_changed", "false");
cc++;
}
- free (changelist);
+ xfree (changelist);
return 1;
}
return 1;
struct mi_console_file *mi_console = ui_file_data (file);
if (mi_console->magic != &mi_console_file_magic)
internal_error ("mi_console_file_delete: bad magic number");
- free (mi_console);
+ xfree (mi_console);
}
static void
if (last_async_command)
fputs_unfiltered (last_async_command, raw_stdout);
fputs_unfiltered ("^done", raw_stdout);
- free (last_async_command);
+ xfree (last_async_command);
if (previous_async_command)
last_async_command = xstrdup (previous_async_command);
- free (previous_async_command);
+ xfree (previous_async_command);
previous_async_command = NULL;
mi_out_put (uiout, raw_stdout);
mi_out_rewind (uiout);
struct cleanup *old_cleanups = NULL;
xasprintf (&run, "load %s", args);
- old_cleanups = make_cleanup (free, run);
+ old_cleanups = make_cleanup (xfree, run);
execute_command (run, from_tty);
do_cleanups (old_cleanups);
struct cleanup *old_cleanups = NULL;
xasprintf (&run, "target %s", args);
- old_cleanups = make_cleanup (free, run);
+ old_cleanups = make_cleanup (xfree, run);
/* target-select is always synchronous. once the call has returned
we know that we are connected. */
/* create a buffer and read it in. */
total_bytes = word_size * nr_rows * nr_cols;
mbuf = calloc (total_bytes, 1);
- make_cleanup (free, mbuf);
+ make_cleanup (xfree, mbuf);
if (mbuf == NULL)
{
xasprintf (&mi_error_message,
fputs_unfiltered (context->token, raw_stdout);
fputs_unfiltered ("^error,msg=\"", raw_stdout);
fputstr_unfiltered (mi_error_message, '"', raw_stdout);
- free (mi_error_message);
+ xfree (mi_error_message);
fputs_unfiltered ("\"\n", raw_stdout);
}
mi_out_rewind (uiout);
if (rc == 0)
{
char *msg = error_last_message ();
- struct cleanup *cleanup = make_cleanup (free, msg);
+ struct cleanup *cleanup = make_cleanup (xfree, msg);
/* The command execution failed and error() was called
somewhere */
fputs_unfiltered (command->token, raw_stdout);
/* FIXME: gdb_???? */
fprintf_unfiltered (gdb_stdout, "cli=%s run=%s\n",
cli, run);
- old_cleanups = make_cleanup (free, run);
+ old_cleanups = make_cleanup (xfree, run);
execute_command ( /*ui */ run, 0 /*from_tty */ );
do_cleanups (old_cleanups);
return;
else
{
xasprintf (&run, "%s %s", mi, args);
- old_cleanups = make_cleanup (free, run);
+ old_cleanups = make_cleanup (xfree, run);
}
if (!target_can_async_p ())
strcmp (previous_sect_name, section_name) : 1);
if (new_section)
{
- free (previous_sect_name);
+ xfree (previous_sect_name);
previous_sect_name = xstrdup (section_name);
if (last_async_command)
if (parse == NULL)
return;
if (parse->command != NULL)
- free (parse->command);
+ xfree (parse->command);
if (parse->token != NULL)
- free (parse->token);
+ xfree (parse->token);
if (parse->args != NULL)
- free (parse->args);
+ xfree (parse->args);
if (parse->argv != NULL)
freeargv (parse->argv);
- free (parse);
+ xfree (parse);
}
while (msym_bunch != NULL)
{
next = msym_bunch->next;
- free ((PTR) msym_bunch);
+ xfree (msym_bunch);
msym_bunch = next;
}
}
else
linked_proc_desc_table = pi_ptr->next;
- free (pi_ptr);
+ xfree (pi_ptr);
write_register (HI_REGNUM,
read_memory_integer (new_sp - 2 * MIPS_SAVED_REGSIZE,
unpush_target (targ_ops);
if (dev_name)
- free (dev_name);
+ xfree (dev_name);
dev_name = strsave (args);
monitor_desc = SERIAL_OPEN (dev_name);
/* Free breakpoint memory */
if (breakaddr != NULL)
{
- free (breakaddr);
+ xfree (breakaddr);
breakaddr = NULL;
}
if (storage_needed > 0)
{
symbol_table = (asymbol **) xmalloc (storage_needed);
- back_to = make_cleanup (free, symbol_table);
+ back_to = make_cleanup (xfree, symbol_table);
number_of_symbols = bfd_canonicalize_symtab (abfd, symbol_table);
if (number_of_symbols < 0)
error ("Can't read symbols from %s: %s", bfd_get_filename (abfd),
memset (objfile, 0, sizeof (struct objfile));
objfile->md = NULL;
obstack_specify_allocation (&objfile->psymbol_cache.cache, 0, 0,
- xmalloc, free);
+ xmalloc, xfree);
obstack_specify_allocation (&objfile->psymbol_obstack, 0, 0, xmalloc,
- free);
+ xfree);
obstack_specify_allocation (&objfile->symbol_obstack, 0, 0, xmalloc,
- free);
+ xfree);
obstack_specify_allocation (&objfile->type_obstack, 0, 0, xmalloc,
- free);
+ xfree);
flags &= ~OBJF_MAPPED;
}
if (!bfd_close (objfile->obfd))
warning ("cannot close \"%s\": %s",
name, bfd_errmsg (bfd_get_error ()));
- free (name);
+ xfree (name);
}
/* Remove it from the chain of all objfiles. */
symsfilename = concat ("./", basename (filename), ".syms", (char *) NULL);
if ((fd = open_existing_mapped_file (symsfilename, mtime, flags)) < 0)
{
- free (symsfilename);
+ xfree (symsfilename);
symsfilename = concat (filename, ".syms", (char *) NULL);
fd = open_existing_mapped_file (symsfilename, mtime, flags);
}
if ((fd < 0) && (flags & OBJF_MAPPED))
{
- free (symsfilename);
+ xfree (symsfilename);
symsfilename = concat ("./", basename (filename), ".syms",
(char *) NULL);
if ((fd = open (symsfilename, O_RDWR | O_CREAT | O_TRUNC, 0666)) < 0)
}
}
- free (symsfilename);
+ xfree (symsfilename);
return (fd);
}
target_read_string (memaddr, &buffer, len, &result);
if (result == 0)
strcpy (myaddr, buffer);
- free (buffer);
+ xfree (buffer);
}
else
result = target_read_memory (memaddr, myaddr, len);
bfd *abfd;
filename = tilde_expand (so->so_name);
- old_chain = make_cleanup (free, filename);
+ old_chain = make_cleanup (xfree, filename);
scratch_chan = openp (getenv ("PATH"), 1, filename, O_RDONLY, 0,
&scratch_pathname);
error ("xfer_link_map_member: Can't read pathname for load map: %s\n",
safe_strerror (errcode));
strncpy (so_list_ptr->so_name, buffer, MAX_PATH_SIZE - 1);
- free (buffer);
+ xfree (buffer);
so_list_ptr->so_name[MAX_PATH_SIZE - 1] = '\0';
for (i = 0; i < lm->module_info.region_count; i++)
region_name = "??";
warning ("cannot handle shared library relocation for %s (%s)",
so_list_ptr->so_name, region_name);
- free (buffer);
+ xfree (buffer);
}
}
#endif
{
if (so_list_head->sections)
{
- free ((PTR) so_list_head->sections);
+ xfree (so_list_head->sections);
}
if (so_list_head->abfd)
{
next = so_list_head->next;
if (bfd_filename)
- free ((PTR) bfd_filename);
- free ((PTR) so_list_head);
+ xfree (bfd_filename);
+ xfree (so_list_head);
so_list_head = next;
}
}
else
{
fputs_filtered (demangled_name, stream);
- free (demangled_name);
+ xfree (demangled_name);
}
}
else
if (!abfd)
{
close (desc);
- make_cleanup (free, filename);
+ make_cleanup (xfree, filename);
error ("\"%s\": can't open to read symbols: %s.", filename,
bfd_errmsg (bfd_get_error ()));
}
if (!bfd_check_format (abfd, bfd_object))
{
bfd_close (abfd);
- make_cleanup (free, filename);
+ make_cleanup (xfree, filename);
error ("\"%s\": can't read symbols: %s.", filename,
bfd_errmsg (bfd_get_error ()));
}
}
bfd_close (abfd);
- free (filename);
+ xfree (filename);
/* Unfortunately, just summing the sizes of various debug info
sections isn't a very accurate measurement of how much heap
struct so_list *temp;
temp = so_list_head;
- free (so_list_head);
+ xfree (so_list_head);
so_list_head = temp->next;
}
clear_symtab_users ();
while (sl)
{
struct so_list *next_sl = sl->next;
- free (sl);
+ xfree (sl);
sl = next_sl;
}
so_list_head = NULL;
if (storage_needed > 0)
{
symbol_table = (asymbol **) xmalloc (storage_needed);
- back_to = make_cleanup (free, (PTR) symbol_table);
+ back_to = make_cleanup (xfree, (PTR) symbol_table);
number_of_symbols = bfd_canonicalize_symtab (abfd, symbol_table);
for (i = 0; i < number_of_symbols; i++)
register struct funcall *call = funcall_chain;
funcall_chain = call->next;
arglist_len = call->arglist_len;
- free ((PTR) call);
+ xfree (call);
return val;
}
for (call = funcall_chain; call; call = next)
{
next = call->next;
- free ((PTR) call);
+ xfree (call);
}
}
\f
static void
free_display (struct display *d)
{
- free ((PTR) d->exp);
- free ((PTR) d);
+ xfree (d->exp);
+ xfree (d);
}
/* Clear out the display_chain.
while ((d = display_chain) != NULL)
{
- free ((PTR) d->exp);
+ xfree (d->exp);
display_chain = d->next;
- free ((PTR) d);
+ xfree (d);
}
}
{
int *saved_pid_ptr = arg;
inferior_pid = *saved_pid_ptr;
- free (arg);
+ xfree (arg);
}
static struct cleanup *
close_procinfo_files (pi);
/* Step three: free the memory. */
- free (pi);
+ xfree (pi);
}
static void
malloc (sizeof (gdb_prstatus_t) * (nlwp + 1))) == 0)
perror_with_name ("procfs: malloc failed in update_threads");
- old_chain = make_cleanup (free, prstatus);
+ old_chain = make_cleanup (xfree, prstatus);
if (ioctl (pi->ctl_fd, PIOCLSTATUS, prstatus) < 0)
proc_error (pi, "update_threads (PIOCLSTATUS)", __LINE__);
-/* Low level Pyramid interface to ptrace, for GDB when running under Unix.
- Copyright (C) 1988, 1989, 1991 Free Software Foundation, Inc.
-
-This file is part of GDB.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include "defs.h"
-#include "frame.h"
-#include "inferior.h"
-
-#include <sys/param.h>
-#include <sys/dir.h>
-#include <signal.h>
-#include <sys/ioctl.h>
-/* #include <fcntl.h> Can we live without this? */
-
-#include "gdbcore.h"
-#include <sys/user.h> /* After a.out.h */
-#include <sys/file.h>
-#include "gdb_stat.h"
-
-\f
-void
-fetch_inferior_registers (regno)
- int regno;
-{
- register int datum;
- register unsigned int regaddr;
- int reg_buf[NUM_REGS+1];
- struct user u;
- register int skipped_frames = 0;
-
- registers_fetched ();
-
- for (regno = 0; regno < 64; regno++) {
- reg_buf[regno] = ptrace (3, inferior_pid, (PTRACE_ARG3_TYPE) regno, 0);
-
-#if defined(PYRAMID_CONTROL_FRAME_DEBUGGING)
- printf_unfiltered ("Fetching register %s, got %0x\n",
- REGISTER_NAME (regno),
- reg_buf[regno]);
-#endif /* PYRAMID_CONTROL_FRAME_DEBUGGING */
-
- if (reg_buf[regno] == -1 && errno == EIO) {
- printf_unfiltered("fetch_interior_registers: fetching register %s\n",
- REGISTER_NAME (regno));
- errno = 0;
- }
- supply_register (regno, reg_buf+regno);
- }
- /* that leaves regs 64, 65, and 66 */
- datum = ptrace (3, inferior_pid,
- (PTRACE_ARG3_TYPE) (((char *)&u.u_pcb.pcb_csp) -
- ((char *)&u)), 0);
-
-
-
- /* FIXME: Find the Current Frame Pointer (CFP). CFP is a global
- register (ie, NOT windowed), that gets saved in a frame iff
- the code for that frame has a prologue (ie, "adsf N"). If
- there is a prologue, the adsf insn saves the old cfp in
- pr13, cfp is set to sp, and N bytes of locals are allocated
- (sp is decremented by n).
- This makes finding CFP hard. I guess the right way to do it
- is:
- - If this is the innermost frame, believe ptrace() or
- the core area.
- - Otherwise:
- Find the first insn of the current frame.
- - find the saved pc;
- - find the call insn that saved it;
- - figure out where the call is to;
- - if the first insn is an adsf, we got a frame
- pointer. */
-
-
- /* Normal processors have separate stack pointers for user and
- kernel mode. Getting the last user mode frame on such
- machines is easy: the kernel context of the ptrace()'d
- process is on the kernel stack, and the USP points to what
- we want. But Pyramids only have a single cfp for both user and
- kernel mode. And processes being ptrace()'d have some
- kernel-context control frames on their stack.
- To avoid tracing back into the kernel context of an inferior,
- we skip 0 or more contiguous control frames where the pc is
- in the kernel. */
-
- while (1) {
- register int inferior_saved_pc;
- inferior_saved_pc = ptrace (1, inferior_pid,
- (PTRACE_ARG3_TYPE) (datum+((32+15)*4)), 0);
- if (inferior_saved_pc > 0) break;
-#if defined(PYRAMID_CONTROL_FRAME_DEBUGGING)
- printf_unfiltered("skipping kernel frame %08x, pc=%08x\n", datum,
- inferior_saved_pc);
-#endif /* PYRAMID_CONTROL_FRAME_DEBUGGING */
- skipped_frames++;
- datum -= CONTROL_STACK_FRAME_SIZE;
- }
-
- reg_buf[CSP_REGNUM] = datum;
- supply_register(CSP_REGNUM, reg_buf+CSP_REGNUM);
-#ifdef PYRAMID_CONTROL_FRAME_DEBUGGING
- if (skipped_frames) {
- fprintf_unfiltered (gdb_stderr,
- "skipped %d frames from %x to %x; cfp was %x, now %x\n",
- skipped_frames, reg_buf[CSP_REGNUM]);
- }
-#endif /* PYRAMID_CONTROL_FRAME_DEBUGGING */
-}
-
-/* Store our register values back into the inferior.
- If REGNO is -1, do this for all registers.
- Otherwise, REGNO specifies which register (so we can save time). */
-
-void
-store_inferior_registers (regno)
- int regno;
-{
- register unsigned int regaddr;
- char buf[80];
-
- if (regno >= 0)
- {
- if ((0 <= regno) && (regno < 64)) {
- /*regaddr = register_addr (regno, offset);*/
- regaddr = regno;
- errno = 0;
- ptrace (6, inferior_pid, (PTRACE_ARG3_TYPE) regaddr,
- read_register (regno));
- if (errno != 0)
- {
- sprintf (buf, "writing register number %d", regno);
- perror_with_name (buf);
- }
- }
- }
- else
- {
- for (regno = 0; regno < NUM_REGS; regno++)
- {
- /*regaddr = register_addr (regno, offset);*/
- regaddr = regno;
- errno = 0;
- ptrace (6, inferior_pid, (PTRACE_ARG3_TYPE) regaddr,
- read_register (regno));
- if (errno != 0)
- {
- sprintf (buf, "writing all regs, number %d", regno);
- perror_with_name (buf);
- }
- }
-}
-\f
-/*** Extensions to core and dump files, for GDB. */
-
-extern unsigned int last_frame_offset;
-
-#ifdef PYRAMID_CORE
-
-/* Can't make definitions here static, since corefile.c needs them
- to do bounds checking on the core-file areas. O well. */
-
-/* have two stacks: one for data, one for register windows. */
-extern CORE_ADDR reg_stack_start;
-extern CORE_ADDR reg_stack_end;
-
-/* need this so we can find the global registers: they never get saved. */
-CORE_ADDR global_reg_offset;
-static CORE_ADDR last_frame_address;
-CORE_ADDR last_frame_offset;
-
-
-/* Address in core file of start of register window stack area.
- Don't know if is this any of meaningful, useful or necessary. */
-extern int reg_stack_offset;
-
-#endif /* PYRAMID_CORE */
-
-\f
-/* Work with core dump and executable files, for GDB.
- This code would be in corefile.c if it weren't machine-dependent. */
-
-void
-core_file_command (filename, from_tty)
- char *filename;
- int from_tty;
-{
- int val;
- extern char registers[];
-
- /* Discard all vestiges of any previous core file
- and mark data and stack spaces as empty. */
-
- if (corefile)
- free (corefile);
- corefile = 0;
-
- if (corechan >= 0)
- close (corechan);
- corechan = -1;
-
- data_start = 0;
- data_end = 0;
- stack_start = STACK_END_ADDR;
- stack_end = STACK_END_ADDR;
-
-#ifdef PYRAMID_CORE
- reg_stack_start = CONTROL_STACK_ADDR;
- reg_stack_end = CONTROL_STACK_ADDR; /* this isn't strictly true...*/
-#endif /* PYRAMID_CORE */
-
- /* Now, if a new core file was specified, open it and digest it. */
-
- if (filename)
- {
- filename = tilde_expand (filename);
- make_cleanup (free, filename);
-
- if (have_inferior_p ())
- error ("To look at a core file, you must kill the program with \"kill\".");
- corechan = open (filename, O_RDONLY, 0);
- if (corechan < 0)
- perror_with_name (filename);
- /* 4.2-style (and perhaps also sysV-style) core dump file. */
- {
- struct user u;
-
- unsigned int reg_offset;
-
- val = myread (corechan, &u, sizeof u);
- if (val < 0)
- perror_with_name ("Not a core file: reading upage");
- if (val != sizeof u)
- error ("Not a core file: could only read %d bytes", val);
- data_start = exec_data_start;
-
- data_end = data_start + NBPG * u.u_dsize;
- data_offset = NBPG * UPAGES;
- stack_offset = NBPG * (UPAGES + u.u_dsize);
-
- /* find registers in core file */
-#ifdef PYRAMID_PTRACE
- stack_start = stack_end - NBPG * u.u_ussize;
- reg_stack_offset = stack_offset + (NBPG *u.u_ussize);
- reg_stack_end = reg_stack_start + NBPG * u.u_cssize;
-
- last_frame_address = ((int) u.u_pcb.pcb_csp);
- last_frame_offset = reg_stack_offset + last_frame_address
- - CONTROL_STACK_ADDR ;
- global_reg_offset = (char *)&u - (char *)&u.u_pcb.pcb_gr0 ;
-
- /* skip any control-stack frames that were executed in the
- kernel. */
-
- while (1) {
- char buf[4];
- val = lseek (corechan, last_frame_offset+(47*4), 0);
- if (val < 0)
- perror_with_name (filename);
- val = myread (corechan, buf, sizeof buf);
- if (val < 0)
- perror_with_name (filename);
-
- if (*(int *)buf >= 0)
- break;
- printf_unfiltered ("skipping frame %s\n", local_hex_string (last_frame_address));
- last_frame_offset -= CONTROL_STACK_FRAME_SIZE;
- last_frame_address -= CONTROL_STACK_FRAME_SIZE;
- }
- reg_offset = last_frame_offset;
-
-#if 1 || defined(PYRAMID_CONTROL_FRAME_DEBUGGING)
- printf_unfiltered ("Control stack pointer = %s\n",
- local_hex_string (u.u_pcb.pcb_csp));
- printf_unfiltered ("offset to control stack %d outermost frame %d (%s)\n",
- reg_stack_offset, reg_offset, local_hex_string (last_frame_address));
-#endif /* PYRAMID_CONTROL_FRAME_DEBUGGING */
-
-#else /* not PYRAMID_CORE */
- stack_start = stack_end - NBPG * u.u_ssize;
- reg_offset = (int) u.u_ar0 - KERNEL_U_ADDR;
-#endif /* not PYRAMID_CORE */
-
-#ifdef __not_on_pyr_yet
- /* Some machines put an absolute address in here and some put
- the offset in the upage of the regs. */
- reg_offset = (int) u.u_ar0;
- if (reg_offset > NBPG * UPAGES)
- reg_offset -= KERNEL_U_ADDR;
-#endif
-
- /* I don't know where to find this info.
- So, for now, mark it as not available. */
- N_SET_MAGIC (core_aouthdr, 0);
-
- /* Read the register values out of the core file and store
- them where `read_register' will find them. */
-
- {
- register int regno;
-
- for (regno = 0; regno < 64; regno++)
- {
- char buf[MAX_REGISTER_RAW_SIZE];
-
- val = lseek (corechan, register_addr (regno, reg_offset), 0);
- if (val < 0
- || (val = myread (corechan, buf, sizeof buf)) < 0)
- {
- char * buffer = (char *) alloca (strlen (REGISTER_NAME (regno))
- + 30);
- strcpy (buffer, "Reading register ");
- strcat (buffer, REGISTER_NAME (regno));
-
- perror_with_name (buffer);
- }
-
- if (val < 0)
- perror_with_name (filename);
-#ifdef PYRAMID_CONTROL_FRAME_DEBUGGING
- printf_unfiltered ("[reg %s(%d), offset in file %s=0x%0x, addr =0x%0x, =%0x]\n",
- REGISTER_NAME (regno), regno, filename,
- register_addr(regno, reg_offset),
- regno * 4 + last_frame_address,
- *((int *)buf));
-#endif /* PYRAMID_CONTROL_FRAME_DEBUGGING */
- supply_register (regno, buf);
- }
- }
- }
- if (filename[0] == '/')
- corefile = savestring (filename, strlen (filename));
- else
- {
- corefile = concat (current_directory, "/", filename, NULL);
- }
-
-#if 1 || defined(PYRAMID_CONTROL_FRAME_DEBUGGING)
- printf_unfiltered ("Providing CSP (%s) as nominal address of current frame.\n",
- local_hex_string(last_frame_address));
-#endif PYRAMID_CONTROL_FRAME_DEBUGGING
- /* FIXME: Which of the following is correct? */
-#if 0
- set_current_frame ( create_new_frame (read_register (FP_REGNUM),
- read_pc ()));
-#else
- set_current_frame ( create_new_frame (last_frame_address,
- read_pc ()));
-#endif
-
- select_frame (get_current_frame (), 0);
- validate_files ();
- }
- else if (from_tty)
- printf_unfiltered ("No core file now.\n");
-}
+/* OBSOLETE /* Low level Pyramid interface to ptrace, for GDB when running under Unix. */
+/* OBSOLETE Copyright (C) 1988, 1989, 1991 Free Software Foundation, Inc. */
+/* OBSOLETE */
+/* OBSOLETE This file is part of GDB. */
+/* OBSOLETE */
+/* OBSOLETE This program is free software; you can redistribute it and/or modify */
+/* OBSOLETE it under the terms of the GNU General Public License as published by */
+/* OBSOLETE the Free Software Foundation; either version 2 of the License, or */
+/* OBSOLETE (at your option) any later version. */
+/* OBSOLETE */
+/* OBSOLETE This program is distributed in the hope that it will be useful, */
+/* OBSOLETE but WITHOUT ANY WARRANTY; without even the implied warranty of */
+/* OBSOLETE MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
+/* OBSOLETE GNU General Public License for more details. */
+/* OBSOLETE */
+/* OBSOLETE You should have received a copy of the GNU General Public License */
+/* OBSOLETE along with this program; if not, write to the Free Software */
+/* OBSOLETE Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *x/ */
+/* OBSOLETE */
+/* OBSOLETE #include "defs.h" */
+/* OBSOLETE #include "frame.h" */
+/* OBSOLETE #include "inferior.h" */
+/* OBSOLETE */
+/* OBSOLETE #include <sys/param.h> */
+/* OBSOLETE #include <sys/dir.h> */
+/* OBSOLETE #include <signal.h> */
+/* OBSOLETE #include <sys/ioctl.h> */
+/* OBSOLETE /* #include <fcntl.h> Can we live without this? *x/ */
+/* OBSOLETE */
+/* OBSOLETE #include "gdbcore.h" */
+/* OBSOLETE #include <sys/user.h> /* After a.out.h *x/ */
+/* OBSOLETE #include <sys/file.h> */
+/* OBSOLETE #include "gdb_stat.h" */
+/* OBSOLETE */
+/* OBSOLETE \f */
+/* OBSOLETE void */
+/* OBSOLETE fetch_inferior_registers (regno) */
+/* OBSOLETE int regno; */
+/* OBSOLETE { */
+/* OBSOLETE register int datum; */
+/* OBSOLETE register unsigned int regaddr; */
+/* OBSOLETE int reg_buf[NUM_REGS+1]; */
+/* OBSOLETE struct user u; */
+/* OBSOLETE register int skipped_frames = 0; */
+/* OBSOLETE */
+/* OBSOLETE registers_fetched (); */
+/* OBSOLETE */
+/* OBSOLETE for (regno = 0; regno < 64; regno++) { */
+/* OBSOLETE reg_buf[regno] = ptrace (3, inferior_pid, (PTRACE_ARG3_TYPE) regno, 0); */
+/* OBSOLETE */
+/* OBSOLETE #if defined(PYRAMID_CONTROL_FRAME_DEBUGGING) */
+/* OBSOLETE printf_unfiltered ("Fetching register %s, got %0x\n", */
+/* OBSOLETE REGISTER_NAME (regno), */
+/* OBSOLETE reg_buf[regno]); */
+/* OBSOLETE #endif /* PYRAMID_CONTROL_FRAME_DEBUGGING *x/ */
+/* OBSOLETE */
+/* OBSOLETE if (reg_buf[regno] == -1 && errno == EIO) { */
+/* OBSOLETE printf_unfiltered("fetch_interior_registers: fetching register %s\n", */
+/* OBSOLETE REGISTER_NAME (regno)); */
+/* OBSOLETE errno = 0; */
+/* OBSOLETE } */
+/* OBSOLETE supply_register (regno, reg_buf+regno); */
+/* OBSOLETE } */
+/* OBSOLETE /* that leaves regs 64, 65, and 66 *x/ */
+/* OBSOLETE datum = ptrace (3, inferior_pid, */
+/* OBSOLETE (PTRACE_ARG3_TYPE) (((char *)&u.u_pcb.pcb_csp) - */
+/* OBSOLETE ((char *)&u)), 0); */
+/* OBSOLETE */
+/* OBSOLETE */
+/* OBSOLETE */
+/* OBSOLETE /* FIXME: Find the Current Frame Pointer (CFP). CFP is a global */
+/* OBSOLETE register (ie, NOT windowed), that gets saved in a frame iff */
+/* OBSOLETE the code for that frame has a prologue (ie, "adsf N"). If */
+/* OBSOLETE there is a prologue, the adsf insn saves the old cfp in */
+/* OBSOLETE pr13, cfp is set to sp, and N bytes of locals are allocated */
+/* OBSOLETE (sp is decremented by n). */
+/* OBSOLETE This makes finding CFP hard. I guess the right way to do it */
+/* OBSOLETE is: */
+/* OBSOLETE - If this is the innermost frame, believe ptrace() or */
+/* OBSOLETE the core area. */
+/* OBSOLETE - Otherwise: */
+/* OBSOLETE Find the first insn of the current frame. */
+/* OBSOLETE - find the saved pc; */
+/* OBSOLETE - find the call insn that saved it; */
+/* OBSOLETE - figure out where the call is to; */
+/* OBSOLETE - if the first insn is an adsf, we got a frame */
+/* OBSOLETE pointer. *x/ */
+/* OBSOLETE */
+/* OBSOLETE */
+/* OBSOLETE /* Normal processors have separate stack pointers for user and */
+/* OBSOLETE kernel mode. Getting the last user mode frame on such */
+/* OBSOLETE machines is easy: the kernel context of the ptrace()'d */
+/* OBSOLETE process is on the kernel stack, and the USP points to what */
+/* OBSOLETE we want. But Pyramids only have a single cfp for both user and */
+/* OBSOLETE kernel mode. And processes being ptrace()'d have some */
+/* OBSOLETE kernel-context control frames on their stack. */
+/* OBSOLETE To avoid tracing back into the kernel context of an inferior, */
+/* OBSOLETE we skip 0 or more contiguous control frames where the pc is */
+/* OBSOLETE in the kernel. *x/ */
+/* OBSOLETE */
+/* OBSOLETE while (1) { */
+/* OBSOLETE register int inferior_saved_pc; */
+/* OBSOLETE inferior_saved_pc = ptrace (1, inferior_pid, */
+/* OBSOLETE (PTRACE_ARG3_TYPE) (datum+((32+15)*4)), 0); */
+/* OBSOLETE if (inferior_saved_pc > 0) break; */
+/* OBSOLETE #if defined(PYRAMID_CONTROL_FRAME_DEBUGGING) */
+/* OBSOLETE printf_unfiltered("skipping kernel frame %08x, pc=%08x\n", datum, */
+/* OBSOLETE inferior_saved_pc); */
+/* OBSOLETE #endif /* PYRAMID_CONTROL_FRAME_DEBUGGING *x/ */
+/* OBSOLETE skipped_frames++; */
+/* OBSOLETE datum -= CONTROL_STACK_FRAME_SIZE; */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE reg_buf[CSP_REGNUM] = datum; */
+/* OBSOLETE supply_register(CSP_REGNUM, reg_buf+CSP_REGNUM); */
+/* OBSOLETE #ifdef PYRAMID_CONTROL_FRAME_DEBUGGING */
+/* OBSOLETE if (skipped_frames) { */
+/* OBSOLETE fprintf_unfiltered (gdb_stderr, */
+/* OBSOLETE "skipped %d frames from %x to %x; cfp was %x, now %x\n", */
+/* OBSOLETE skipped_frames, reg_buf[CSP_REGNUM]); */
+/* OBSOLETE } */
+/* OBSOLETE #endif /* PYRAMID_CONTROL_FRAME_DEBUGGING *x/ */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE /* Store our register values back into the inferior. */
+/* OBSOLETE If REGNO is -1, do this for all registers. */
+/* OBSOLETE Otherwise, REGNO specifies which register (so we can save time). *x/ */
+/* OBSOLETE */
+/* OBSOLETE void */
+/* OBSOLETE store_inferior_registers (regno) */
+/* OBSOLETE int regno; */
+/* OBSOLETE { */
+/* OBSOLETE register unsigned int regaddr; */
+/* OBSOLETE char buf[80]; */
+/* OBSOLETE */
+/* OBSOLETE if (regno >= 0) */
+/* OBSOLETE { */
+/* OBSOLETE if ((0 <= regno) && (regno < 64)) { */
+/* OBSOLETE /*regaddr = register_addr (regno, offset);*x/ */
+/* OBSOLETE regaddr = regno; */
+/* OBSOLETE errno = 0; */
+/* OBSOLETE ptrace (6, inferior_pid, (PTRACE_ARG3_TYPE) regaddr, */
+/* OBSOLETE read_register (regno)); */
+/* OBSOLETE if (errno != 0) */
+/* OBSOLETE { */
+/* OBSOLETE sprintf (buf, "writing register number %d", regno); */
+/* OBSOLETE perror_with_name (buf); */
+/* OBSOLETE } */
+/* OBSOLETE } */
+/* OBSOLETE } */
+/* OBSOLETE else */
+/* OBSOLETE { */
+/* OBSOLETE for (regno = 0; regno < NUM_REGS; regno++) */
+/* OBSOLETE { */
+/* OBSOLETE /*regaddr = register_addr (regno, offset);*x/ */
+/* OBSOLETE regaddr = regno; */
+/* OBSOLETE errno = 0; */
+/* OBSOLETE ptrace (6, inferior_pid, (PTRACE_ARG3_TYPE) regaddr, */
+/* OBSOLETE read_register (regno)); */
+/* OBSOLETE if (errno != 0) */
+/* OBSOLETE { */
+/* OBSOLETE sprintf (buf, "writing all regs, number %d", regno); */
+/* OBSOLETE perror_with_name (buf); */
+/* OBSOLETE } */
+/* OBSOLETE } */
+/* OBSOLETE } */
+/* OBSOLETE \f */
+/* OBSOLETE /*** Extensions to core and dump files, for GDB. *x/ */
+/* OBSOLETE */
+/* OBSOLETE extern unsigned int last_frame_offset; */
+/* OBSOLETE */
+/* OBSOLETE #ifdef PYRAMID_CORE */
+/* OBSOLETE */
+/* OBSOLETE /* Can't make definitions here static, since corefile.c needs them */
+/* OBSOLETE to do bounds checking on the core-file areas. O well. *x/ */
+/* OBSOLETE */
+/* OBSOLETE /* have two stacks: one for data, one for register windows. *x/ */
+/* OBSOLETE extern CORE_ADDR reg_stack_start; */
+/* OBSOLETE extern CORE_ADDR reg_stack_end; */
+/* OBSOLETE */
+/* OBSOLETE /* need this so we can find the global registers: they never get saved. *x/ */
+/* OBSOLETE CORE_ADDR global_reg_offset; */
+/* OBSOLETE static CORE_ADDR last_frame_address; */
+/* OBSOLETE CORE_ADDR last_frame_offset; */
+/* OBSOLETE */
+/* OBSOLETE */
+/* OBSOLETE /* Address in core file of start of register window stack area. */
+/* OBSOLETE Don't know if is this any of meaningful, useful or necessary. *x/ */
+/* OBSOLETE extern int reg_stack_offset; */
+/* OBSOLETE */
+/* OBSOLETE #endif /* PYRAMID_CORE *x/ */
+/* OBSOLETE */
+/* OBSOLETE \f */
+/* OBSOLETE /* Work with core dump and executable files, for GDB. */
+/* OBSOLETE This code would be in corefile.c if it weren't machine-dependent. *x/ */
+/* OBSOLETE */
+/* OBSOLETE void */
+/* OBSOLETE core_file_command (filename, from_tty) */
+/* OBSOLETE char *filename; */
+/* OBSOLETE int from_tty; */
+/* OBSOLETE { */
+/* OBSOLETE int val; */
+/* OBSOLETE */
+/* OBSOLETE /* Discard all vestiges of any previous core file */
+/* OBSOLETE and mark data and stack spaces as empty. *x/ */
+/* OBSOLETE */
+/* OBSOLETE if (corefile) */
+/* OBSOLETE xfree (corefile); */
+/* OBSOLETE corefile = 0; */
+/* OBSOLETE */
+/* OBSOLETE if (corechan >= 0) */
+/* OBSOLETE close (corechan); */
+/* OBSOLETE corechan = -1; */
+/* OBSOLETE */
+/* OBSOLETE data_start = 0; */
+/* OBSOLETE data_end = 0; */
+/* OBSOLETE stack_start = STACK_END_ADDR; */
+/* OBSOLETE stack_end = STACK_END_ADDR; */
+/* OBSOLETE */
+/* OBSOLETE #ifdef PYRAMID_CORE */
+/* OBSOLETE reg_stack_start = CONTROL_STACK_ADDR; */
+/* OBSOLETE reg_stack_end = CONTROL_STACK_ADDR; /* this isn't strictly true...*x/ */
+/* OBSOLETE #endif /* PYRAMID_CORE *x/ */
+/* OBSOLETE */
+/* OBSOLETE /* Now, if a new core file was specified, open it and digest it. *x/ */
+/* OBSOLETE */
+/* OBSOLETE if (filename) */
+/* OBSOLETE { */
+/* OBSOLETE filename = tilde_expand (filename); */
+/* OBSOLETE make_cleanup (xfree, filename); */
+/* OBSOLETE */
+/* OBSOLETE if (have_inferior_p ()) */
+/* OBSOLETE error ("To look at a core file, you must kill the program with \"kill\"."); */
+/* OBSOLETE corechan = open (filename, O_RDONLY, 0); */
+/* OBSOLETE if (corechan < 0) */
+/* OBSOLETE perror_with_name (filename); */
+/* OBSOLETE /* 4.2-style (and perhaps also sysV-style) core dump file. *x/ */
+/* OBSOLETE { */
+/* OBSOLETE struct user u; */
+/* OBSOLETE */
+/* OBSOLETE unsigned int reg_offset; */
+/* OBSOLETE */
+/* OBSOLETE val = myread (corechan, &u, sizeof u); */
+/* OBSOLETE if (val < 0) */
+/* OBSOLETE perror_with_name ("Not a core file: reading upage"); */
+/* OBSOLETE if (val != sizeof u) */
+/* OBSOLETE error ("Not a core file: could only read %d bytes", val); */
+/* OBSOLETE data_start = exec_data_start; */
+/* OBSOLETE */
+/* OBSOLETE data_end = data_start + NBPG * u.u_dsize; */
+/* OBSOLETE data_offset = NBPG * UPAGES; */
+/* OBSOLETE stack_offset = NBPG * (UPAGES + u.u_dsize); */
+/* OBSOLETE */
+/* OBSOLETE /* find registers in core file *x/ */
+/* OBSOLETE #ifdef PYRAMID_PTRACE */
+/* OBSOLETE stack_start = stack_end - NBPG * u.u_ussize; */
+/* OBSOLETE reg_stack_offset = stack_offset + (NBPG *u.u_ussize); */
+/* OBSOLETE reg_stack_end = reg_stack_start + NBPG * u.u_cssize; */
+/* OBSOLETE */
+/* OBSOLETE last_frame_address = ((int) u.u_pcb.pcb_csp); */
+/* OBSOLETE last_frame_offset = reg_stack_offset + last_frame_address */
+/* OBSOLETE - CONTROL_STACK_ADDR ; */
+/* OBSOLETE global_reg_offset = (char *)&u - (char *)&u.u_pcb.pcb_gr0 ; */
+/* OBSOLETE */
+/* OBSOLETE /* skip any control-stack frames that were executed in the */
+/* OBSOLETE kernel. *x/ */
+/* OBSOLETE */
+/* OBSOLETE while (1) { */
+/* OBSOLETE char buf[4]; */
+/* OBSOLETE val = lseek (corechan, last_frame_offset+(47*4), 0); */
+/* OBSOLETE if (val < 0) */
+/* OBSOLETE perror_with_name (filename); */
+/* OBSOLETE val = myread (corechan, buf, sizeof buf); */
+/* OBSOLETE if (val < 0) */
+/* OBSOLETE perror_with_name (filename); */
+/* OBSOLETE */
+/* OBSOLETE if (*(int *)buf >= 0) */
+/* OBSOLETE break; */
+/* OBSOLETE printf_unfiltered ("skipping frame %s\n", local_hex_string (last_frame_address)); */
+/* OBSOLETE last_frame_offset -= CONTROL_STACK_FRAME_SIZE; */
+/* OBSOLETE last_frame_address -= CONTROL_STACK_FRAME_SIZE; */
+/* OBSOLETE } */
+/* OBSOLETE reg_offset = last_frame_offset; */
+/* OBSOLETE */
+/* OBSOLETE #if 1 || defined(PYRAMID_CONTROL_FRAME_DEBUGGING) */
+/* OBSOLETE printf_unfiltered ("Control stack pointer = %s\n", */
+/* OBSOLETE local_hex_string (u.u_pcb.pcb_csp)); */
+/* OBSOLETE printf_unfiltered ("offset to control stack %d outermost frame %d (%s)\n", */
+/* OBSOLETE reg_stack_offset, reg_offset, local_hex_string (last_frame_address)); */
+/* OBSOLETE #endif /* PYRAMID_CONTROL_FRAME_DEBUGGING *x/ */
+/* OBSOLETE */
+/* OBSOLETE #else /* not PYRAMID_CORE *x/ */
+/* OBSOLETE stack_start = stack_end - NBPG * u.u_ssize; */
+/* OBSOLETE reg_offset = (int) u.u_ar0 - KERNEL_U_ADDR; */
+/* OBSOLETE #endif /* not PYRAMID_CORE *x/ */
+/* OBSOLETE */
+/* OBSOLETE #ifdef __not_on_pyr_yet */
+/* OBSOLETE /* Some machines put an absolute address in here and some put */
+/* OBSOLETE the offset in the upage of the regs. *x/ */
+/* OBSOLETE reg_offset = (int) u.u_ar0; */
+/* OBSOLETE if (reg_offset > NBPG * UPAGES) */
+/* OBSOLETE reg_offset -= KERNEL_U_ADDR; */
+/* OBSOLETE #endif */
+/* OBSOLETE */
+/* OBSOLETE /* I don't know where to find this info. */
+/* OBSOLETE So, for now, mark it as not available. *x/ */
+/* OBSOLETE N_SET_MAGIC (core_aouthdr, 0); */
+/* OBSOLETE */
+/* OBSOLETE /* Read the register values out of the core file and store */
+/* OBSOLETE them where `read_register' will find them. *x/ */
+/* OBSOLETE */
+/* OBSOLETE { */
+/* OBSOLETE register int regno; */
+/* OBSOLETE */
+/* OBSOLETE for (regno = 0; regno < 64; regno++) */
+/* OBSOLETE { */
+/* OBSOLETE char buf[MAX_REGISTER_RAW_SIZE]; */
+/* OBSOLETE */
+/* OBSOLETE val = lseek (corechan, register_addr (regno, reg_offset), 0); */
+/* OBSOLETE if (val < 0 */
+/* OBSOLETE || (val = myread (corechan, buf, sizeof buf)) < 0) */
+/* OBSOLETE { */
+/* OBSOLETE char * buffer = (char *) alloca (strlen (REGISTER_NAME (regno)) */
+/* OBSOLETE + 30); */
+/* OBSOLETE strcpy (buffer, "Reading register "); */
+/* OBSOLETE strcat (buffer, REGISTER_NAME (regno)); */
+/* OBSOLETE */
+/* OBSOLETE perror_with_name (buffer); */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE if (val < 0) */
+/* OBSOLETE perror_with_name (filename); */
+/* OBSOLETE #ifdef PYRAMID_CONTROL_FRAME_DEBUGGING */
+/* OBSOLETE printf_unfiltered ("[reg %s(%d), offset in file %s=0x%0x, addr =0x%0x, =%0x]\n", */
+/* OBSOLETE REGISTER_NAME (regno), regno, filename, */
+/* OBSOLETE register_addr(regno, reg_offset), */
+/* OBSOLETE regno * 4 + last_frame_address, */
+/* OBSOLETE *((int *)buf)); */
+/* OBSOLETE #endif /* PYRAMID_CONTROL_FRAME_DEBUGGING *x/ */
+/* OBSOLETE supply_register (regno, buf); */
+/* OBSOLETE } */
+/* OBSOLETE } */
+/* OBSOLETE } */
+/* OBSOLETE if (filename[0] == '/') */
+/* OBSOLETE corefile = savestring (filename, strlen (filename)); */
+/* OBSOLETE else */
+/* OBSOLETE { */
+/* OBSOLETE corefile = concat (current_directory, "/", filename, NULL); */
+/* OBSOLETE } */
+/* OBSOLETE */
+/* OBSOLETE #if 1 || defined(PYRAMID_CONTROL_FRAME_DEBUGGING) */
+/* OBSOLETE printf_unfiltered ("Providing CSP (%s) as nominal address of current frame.\n", */
+/* OBSOLETE local_hex_string(last_frame_address)); */
+/* OBSOLETE #endif PYRAMID_CONTROL_FRAME_DEBUGGING */
+/* OBSOLETE /* FIXME: Which of the following is correct? *x/ */
+/* OBSOLETE #if 0 */
+/* OBSOLETE set_current_frame ( create_new_frame (read_register (FP_REGNUM), */
+/* OBSOLETE read_pc ())); */
+/* OBSOLETE #else */
+/* OBSOLETE set_current_frame ( create_new_frame (last_frame_address, */
+/* OBSOLETE read_pc ())); */
+/* OBSOLETE #endif */
+/* OBSOLETE */
+/* OBSOLETE select_frame (get_current_frame (), 0); */
+/* OBSOLETE validate_files (); */
+/* OBSOLETE } */
+/* OBSOLETE else if (from_tty) */
+/* OBSOLETE printf_unfiltered ("No core file now.\n"); */
+/* OBSOLETE } */
/*EMPTY */ ;
if (prog_name != NULL)
- free (prog_name);
+ xfree (prog_name);
prog_name = savestring (p, strlen (p));
adapt_close (0);
gdb_flush (gdb_stdout);
}
printf_filtered ("\n");
- free (buffer);
+ xfree (buffer);
}
s = s->next;
}
/*EMPTY */ ;
if (prog_name != NULL)
- free (prog_name);
+ xfree (prog_name);
prog_name = savestring (p, strlen (p));
eb_close (0);
}
if (savename != NULL)
{
- free (savename);
+ xfree (savename);
}
savename = NULL;
}
filename = tilde_expand (filename);
- make_cleanup (free, filename);
+ make_cleanup (xfree, filename);
switch (es1800_load_format)
{
the user didn't specify a local name, assume it's the same
as the part of the remote name after the "host:". */
if (tftp_name)
- free (tftp_name);
+ xfree (tftp_name);
if (tftp_localname)
- free (tftp_localname);
+ xfree (tftp_localname);
if (local_name == NULL)
if ((local_name = strchr (remote_name, ':')) != NULL)
local_name++; /* skip over the colon */
set_current_frame (create_new_frame (read_fp (), stop_pc));
select_frame (get_current_frame (), 0);
print_stack_frame (selected_frame, -1, 1);
- free (serial_port_name);
+ xfree (serial_port_name);
}
static void
strcat (cmd, tftp_name);
strcat (cmd, "\r");
mips_send_command (cmd, 0);
- free (cmd);
+ xfree (cmd);
if (!mips_expect_download ("Downloading from "))
return;
if (!mips_expect_download (tftp_name))
/*EMPTY */ ;
if (prog_name != NULL)
- free (prog_name);
+ xfree (prog_name);
prog_name = savestring (p, strlen (p));
error ("The load command takes a file name");
arg_string = tilde_expand (arg_string);
- make_cleanup (free, arg_string);
+ make_cleanup (xfree, arg_string);
QUIT;
immediate_quit++;
error ("File loading is not yet supported for MiniMon.");
nindy_serial = NULL;
if (savename)
- free (savename);
+ xfree (savename);
savename = 0;
}
{
struct clean_up_tty_args *args = (struct clean_up_tty_args *) ptrarg;
SERIAL_SET_TTY_STATE (args->serial, args->state);
- free (args->state);
+ xfree (args->state);
warning ("\n\nYou may need to reset the 80960 and/or reload your program.\n");
}
clean_up_int (void)
{
SERIAL_SET_TTY_STATE (tty_args.serial, tty_args.state);
- free (tty_args.state);
+ xfree (tty_args.state);
signal (SIGINT, old_ctrlc);
#ifdef SIGTSTP
}
SERIAL_SET_TTY_STATE (tty_args.serial, tty_args.state);
- free (tty_args.state);
+ xfree (tty_args.state);
discard_cleanups (old_cleanups);
if (stop_exit)
s->_raw_size,
s->vma);
ninMemPut (s->vma, buffer, s->_raw_size);
- free (buffer);
+ xfree (buffer);
}
}
bfd_close (file);
for (entry = local_bp_list; entry != NULL; entry = entry->next)
{
if (preventry)
- free (preventry);
+ xfree (preventry);
}
}
{
preventry->next = entry->next;
}
- free (entry);
+ xfree (entry);
}
return 0;
}
}
if (log_filename)
- free (log_filename);
+ xfree (log_filename);
log_filename = xstrdup (arg);
*/
if (commandline != NULL)
- free (commandline);
+ xfree (commandline);
commandline = malloc (strlen (command) + strlen (args) + 2);
if (commandline != NULL)
if (execfile)
{
if (prog_name != NULL)
- free (prog_name);
+ xfree (prog_name);
prog_name = savestring (execfile, strlen (execfile));
}
else if (entry.Offset)
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");
error ("Must specify at least a file name with the load command");
filename = tilde_expand (filename);
- make_cleanup (free, filename);
+ make_cleanup (xfree, filename);
while (token = strtok (NULL, " \t"))
{
error ("The load command takes a file name");
arg_string = tilde_expand (arg_string);
- make_cleanup (free, arg_string);
+ make_cleanup (xfree, arg_string);
dont_repeat ();
push_target (&vx_run_ops);
if (vx_running)
- free (vx_running);
+ xfree (vx_running);
vx_running = 0;
}
{
inferior_pid = 0; /* No longer have a process. */
if (vx_running)
- free (vx_running);
+ xfree (vx_running);
vx_running = 0;
}
\f
pClient = 0;
if (vx_host)
- free (vx_host); /* The hostname */
+ xfree (vx_host); /* The hostname */
vx_host = 0;
}
/* be clever; compute the host_crc before waiting for target reply */
sectdata = xmalloc (size);
- old_chain = make_cleanup (free, sectdata);
+ old_chain = make_cleanup (xfree, sectdata);
bfd_get_section_contents (exec_bfd, s, sectdata, 0, size);
host_crc = crc32 ((unsigned char *) sectdata, size, 0xffffffff);
}
} while (rc == -1);
if (ldi)
- free (ldi);
+ xfree (ldi);
}
\f
/* Core file stuff. */
int pid = state->pid;
close (scb->fd);
scb->fd = -1;
- free (state);
+ xfree (state);
scb->state = NULL;
kill (pid, SIGTERM);
/* Might be useful to check that the child does die. */
if (scb->ops->open (scb, open_name))
{
- free (scb);
+ xfree (scb);
return NULL;
}
scb->ops->close (scb);
if (scb->name)
- free (scb->name);
+ xfree (scb->name);
if (scb_base == scb)
scb_base = scb_base->next;
break;
}
- free (scb);
+ xfree (scb);
}
void
vasprintf (&buf, format, args);
SERIAL_WRITE (desc, buf, strlen (buf));
- free (buf);
+ xfree (buf);
va_end (args);
}
{
printf_unfiltered ("\r\n[Exiting connect mode]\r\n");
SERIAL_SET_TTY_STATE (tty_desc, ttystate);
- free (ttystate);
+ xfree (ttystate);
SERIAL_CLOSE (tty_desc);
}
memset (objfile, 0, sizeof (struct objfile));
objfile->md = NULL;
obstack_specify_allocation (&objfile->psymbol_cache.cache, 0, 0,
- xmalloc, free);
+ xmalloc, xfree);
obstack_specify_allocation (&objfile->psymbol_obstack, 0, 0, xmalloc,
- free);
+ xfree);
obstack_specify_allocation (&objfile->symbol_obstack, 0, 0, xmalloc,
- free);
+ xfree);
obstack_specify_allocation (&objfile->type_obstack, 0, 0, xmalloc,
- free);
+ xfree);
objfile->name = mstrsave (objfile->md, "rt_common");
/* Add this file onto the tail of the linked list of other such files. */
{
obstack_free (&rt_common_objfile->symbol_obstack, 0);
obstack_specify_allocation (&rt_common_objfile->symbol_obstack, 0, 0,
- xmalloc, free);
+ xmalloc, xfree);
rt_common_objfile->minimal_symbol_count = 0;
rt_common_objfile->msymbols = NULL;
}
prim_record_minimal_symbol (name, inferior_rtc_nlist.n_value,
mst_bss, rt_common_objfile);
- free (name);
+ xfree (name);
}
rtc_symp = SOLIB_EXTRACT_ADDRESS (inferior_rtc_symb.rtc_next);
}
if (storage_needed > 0)
{
symbol_table = (asymbol **) xmalloc (storage_needed);
- back_to = make_cleanup (free, (PTR) symbol_table);
+ back_to = make_cleanup (xfree, (PTR) symbol_table);
number_of_symbols = bfd_canonicalize_symtab (abfd, symbol_table);
for (i = 0; i < number_of_symbols; i++)
if (storage_needed > 0)
{
symbol_table = (asymbol **) xmalloc (storage_needed);
- back_to = make_cleanup (free, (PTR) symbol_table);
+ back_to = make_cleanup (xfree, (PTR) symbol_table);
number_of_symbols = bfd_canonicalize_dynamic_symtab (abfd, symbol_table);
for (i = 0; i < number_of_symbols; i++)
#else /* SVR4_SHARED_LIBS */
struct link_map_offsets *lmo = SVR4_FETCH_LINK_MAP_OFFSETS ();
char *r_map_buf = xmalloc (lmo->r_map_size);
- struct cleanup *cleanups = make_cleanup (free, r_map_buf);
+ struct cleanup *cleanups = make_cleanup (xfree, r_map_buf);
read_memory (debug_base + lmo->r_map_offset, r_map_buf, lmo->r_map_size);
int from_tty = *(int *)from_ttyp;
struct link_map_offsets *lmo = SVR4_FETCH_LINK_MAP_OFFSETS ();
char *l_name_buf = xmalloc (lmo->l_name_size);
- struct cleanup *cleanups = make_cleanup (free, l_name_buf);
+ struct cleanup *cleanups = make_cleanup (xfree, l_name_buf);
if (symfile_objfile)
if (!query ("Attempt to reload symbols from process? "))
return 0;
}
- make_cleanup (free, filename);
+ make_cleanup (xfree, filename);
/* Have a pathname: read the symbol file. */
symbol_file_command (filename, from_tty);
struct link_map_offsets *lmo = SVR4_FETCH_LINK_MAP_OFFSETS ();
struct so_list *new
= (struct so_list *) xmalloc (sizeof (struct so_list));
- struct cleanup *old_chain = make_cleanup (free, new);
+ struct cleanup *old_chain = make_cleanup (xfree, new);
memset (new, 0, sizeof (*new));
new->lm_info = xmalloc (sizeof (struct lm_info));
- make_cleanup (free, new->lm_info);
+ make_cleanup (xfree, new->lm_info);
new->lm_info->lm = xmalloc (lmo->link_map_size);
- make_cleanup (free, new->lm_info->lm);
+ make_cleanup (xfree, new->lm_info->lm);
memset (new->lm_info->lm, 0, lmo->link_map_size);
read_memory (lm, new->lm_info->lm, lmo->link_map_size);
{
strncpy (new->so_name, buffer, SO_NAME_MAX_PATH_SIZE - 1);
new->so_name[SO_NAME_MAX_PATH_SIZE - 1] = '\0';
- free (buffer);
+ xfree (buffer);
strcpy (new->so_original_name, new->so_name);
}
new_offsets = xcalloc (sizeof (struct section_offsets),
symfile_objfile->num_sections);
- old_chain = make_cleanup (free, new_offsets);
+ old_chain = make_cleanup (xfree, new_offsets);
for (i = 0; i < symfile_objfile->num_sections; i++)
{
static void
svr4_free_so (struct so_list *so)
{
- free (so->lm_info->lm);
- free (so->lm_info);
+ xfree (so->lm_info->lm);
+ xfree (so->lm_info);
}
static void
filename = tilde_expand (so->so_name);
- old_chain = make_cleanup (free, filename);
+ old_chain = make_cleanup (xfree, filename);
scratch_chan = solib_open (filename, &scratch_pathname);
if (scratch_chan < 0)
char *bfd_filename = 0;
if (so->sections)
- free (so->sections);
+ xfree (so->sections);
if (so->abfd)
{
}
if (bfd_filename)
- free (bfd_filename);
+ xfree (bfd_filename);
TARGET_SO_FREE_SO (so);
- free (so);
+ xfree (so);
}
}
objfile->import_list_size = import_list_size;
- free (string_buffer);
+ xfree (string_buffer);
return import_list_size;
}
}
objfile->export_list_size = export_list_size;
- free (string_buffer);
+ xfree (string_buffer);
return export_list_size;
}
\f
if (!abfd)
{
close (desc);
- make_cleanup (free, filename);
+ make_cleanup (xfree, filename);
error ("\"%s\": can't open to read symbols: %s.", filename,
bfd_errmsg (bfd_get_error ()));
}
if (!bfd_check_format (abfd, bfd_object)) /* Reads in section info */
{
bfd_close (abfd); /* This also closes desc */
- make_cleanup (free, filename);
+ make_cleanup (xfree, filename);
error ("\"%s\": can't read symbols: %s.", filename,
bfd_errmsg (bfd_get_error ()));
}
st_size += (LONGEST) bfd_section_size (abfd, sect);
bfd_close (abfd); /* This also closes desc */
- free (filename);
+ xfree (filename);
/* Unfortunately, just summing the sizes of various debug info
sections isn't a very accurate measurement of how much heap
struct so_list *temp;
temp = so_list_head;
- free (so_list_head);
+ xfree (so_list_head);
so_list_head = temp->next;
}
clear_symtab_users ();
while (sl)
{
struct so_list *next_sl = sl->next;
- free (sl);
+ xfree (sl);
sl = next_sl;
}
so_list_head = NULL;
{
sals = decode_line_spec ("main", 1);
sal = sals.sals[0];
- free (sals.sals);
+ xfree (sals.sals);
current_source_symtab = sal.symtab;
current_source_line = max (sal.line - (lines_to_list - 1), 1);
if (current_source_symtab)
{
if (from_tty && query ("Reinitialize source path to empty? "))
{
- free (source_path);
+ xfree (source_path);
init_source_path ();
}
}
return;
dirname = strsave (dirname);
- make_cleanup (free, dirname);
+ make_cleanup (xfree, dirname);
do
{
name = concat (current_directory, SLASH_STRING, name, NULL);
else
name = savestring (name, p - name);
- make_cleanup (free, name);
+ make_cleanup (xfree, name);
/* Unless it's a variable, check existence. */
if (name[0] != '$')
old[prefix] = c;
*which_path = concat (temp, "", &old[prefix], NULL);
prefix = strlen (temp);
- free (temp);
+ xfree (temp);
}
else
{
*which_path = concat (name, (old[0] ? tinybuf : old), old, NULL);
prefix = strlen (name);
}
- free (old);
+ xfree (old);
old = *which_path;
}
}
{
fullname = s->fullname;
s->fullname = mstrsave (s->objfile->md, s->fullname);
- free (fullname);
+ xfree (fullname);
}
return result;
}
/* Use malloc, not alloca, because this may be pretty large, and we may
run into various kinds of limits on stack size. */
data = (char *) xmalloc (size);
- old_cleanups = make_cleanup (free, data);
+ old_cleanups = make_cleanup (xfree, data);
/* Reassign `size' to result of read for systems where \r\n -> \n. */
size = myread (desc, data, size);
if (sals.nelts > 1)
{
ambiguous_line_spec (&sals);
- free (sals.sals);
+ xfree (sals.sals);
return;
}
sal = sals.sals[0];
- free (sals.sals);
+ xfree (sals.sals);
}
/* Record whether the BEG arg is all digits. */
if (sals_end.nelts > 1)
{
ambiguous_line_spec (&sals_end);
- free (sals_end.sals);
+ xfree (sals_end.sals);
return;
}
sal_end = sals_end.sals[0];
- free (sals_end.sals);
+ xfree (sals_end.sals);
}
}
printf_filtered ("Line number %d is out of range for \"%s\".\n",
sal.line, sal.symtab->filename);
}
- free (sals.sals);
+ xfree (sals.sals);
}
\f
/* Commands to search the source file for a regexp. */
unpush_target (&sparclite_ops);
if (remote_target_name)
- free (remote_target_name);
+ xfree (remote_target_name);
remote_target_name = strsave (name);
for (i = 0; i < TYPE_N_BASECLASSES (type); i++)
{
new = (struct nextfield *) xmalloc (sizeof (struct nextfield));
- make_cleanup (free, new);
+ make_cleanup (xfree, new);
memset (new, 0, sizeof (struct nextfield));
new->next = fip->list;
fip->list = new;
new_fnlist = (struct next_fnfieldlist *)
xmalloc (sizeof (struct next_fnfieldlist));
- make_cleanup (free, new_fnlist);
+ make_cleanup (xfree, new_fnlist);
memset (new_fnlist, 0, sizeof (struct next_fnfieldlist));
/* The following is code to work around cfront generated stabs.
new_sublist =
(struct next_fnfield *) xmalloc (sizeof (struct next_fnfield));
- make_cleanup (free, new_sublist);
+ make_cleanup (xfree, new_sublist);
memset (new_sublist, 0, sizeof (struct next_fnfield));
/* eat 1; from :;2A.; */
new_fnlist = (struct next_fnfieldlist *)
xmalloc (sizeof (struct next_fnfieldlist));
- make_cleanup (free, new_fnlist);
+ make_cleanup (xfree, new_fnlist);
memset (new_fnlist, 0, sizeof (struct next_fnfieldlist));
if ((*pp)[0] == 'o' && (*pp)[1] == 'p' && is_cplus_marker ((*pp)[2]))
{
new_sublist =
(struct next_fnfield *) xmalloc (sizeof (struct next_fnfield));
- make_cleanup (free, new_sublist);
+ make_cleanup (xfree, new_sublist);
memset (new_sublist, 0, sizeof (struct next_fnfield));
/* Check for and handle cretinous dbx symbol name continuation! */
STABS_CONTINUE (pp, objfile);
/* Get space to record the next field's data. */
new = (struct nextfield *) xmalloc (sizeof (struct nextfield));
- make_cleanup (free, new);
+ make_cleanup (xfree, new);
memset (new, 0, sizeof (struct nextfield));
new->next = fip->list;
fip->list = new;
for (i = 0; i < TYPE_N_BASECLASSES (type); i++)
{
new = (struct nextfield *) xmalloc (sizeof (struct nextfield));
- make_cleanup (free, new);
+ make_cleanup (xfree, new);
memset (new, 0, sizeof (struct nextfield));
new->next = fip->list;
fip->list = new;
/* allocate a new fip */
new = (struct nextfield *) xmalloc (sizeof (struct nextfield));
- make_cleanup (free, new);
+ make_cleanup (xfree, new);
memset (new, 0, sizeof (struct nextfield));
new->next = fip->list;
fip->list = new;
{
/* allocate a new fip */
new = (struct nextfield *) xmalloc (sizeof (struct nextfield));
- make_cleanup (free, new);
+ make_cleanup (xfree, new);
memset (new, 0, sizeof (struct nextfield));
new->next = fip->list;
fip->list = new;
{
if (type_vector)
{
- free ((char *) type_vector);
+ xfree (type_vector);
}
type_vector = 0;
type_vector_length = 0;
if (global_stabs)
{
patch_block_stabs (global_symbols, global_stabs, objfile);
- free ((PTR) global_stabs);
+ xfree (global_stabs);
global_stabs = NULL;
}
}
addr_string = savestring (frame_exp, p - frame_exp);
{
- tmp_cleanup = make_cleanup (free, addr_string);
+ tmp_cleanup = make_cleanup (xfree, addr_string);
args[numargs++] = parse_and_eval_address (addr_string);
do_cleanups (tmp_cleanup);
}
backtrace_command_1 (argPtr, (argIndicatingFullTrace >= 0), from_tty);
if (argIndicatingFullTrace >= 0 && totArgLen > 0)
- free (argPtr);
+ xfree (argPtr);
if (old_chain)
do_cleanups (old_chain);
while (!found && level == 0);
if (func_bounds)
- free (func_bounds);
+ xfree (func_bounds);
if (!found)
printf_filtered ("'%s' not within current stack frame.\n", arg);
and mark data and stack spaces as empty. */
if (corefile)
- free (corefile);
+ xfree (corefile);
corefile = 0;
if (corechan >= 0)
if (filename)
{
filename = tilde_expand (filename);
- make_cleanup (free, filename);
+ make_cleanup (xfree, filename);
if (have_inferior_p ())
error ("To look at a core file, you must kill the program with \"kill\".");
for (idx = 0; idx < MAX_SECTIONS; idx++)
if (sap->other[idx].name)
- free (sap->other[idx].name);
- free (sap);
+ xfree (sap->other[idx].name);
+ xfree (sap);
}
#endif
if (desc < 0)
{
- make_cleanup (free, name);
+ make_cleanup (xfree, name);
perror_with_name (name);
}
- free (name); /* Free 1st new malloc'd copy */
+ xfree (name); /* Free 1st new malloc'd copy */
name = absolute_name; /* Keep 2nd malloc'd copy in bfd */
/* It'll be freed in free_objfile(). */
if (!sym_bfd)
{
close (desc);
- make_cleanup (free, name);
+ make_cleanup (xfree, name);
error ("\"%s\": can't open to read symbols: %s.", name,
bfd_errmsg (bfd_get_error ()));
}
on error it does not free all the storage associated with the
bfd). */
bfd_close (sym_bfd); /* This also closes desc */
- make_cleanup (free, name);
+ make_cleanup (xfree, name);
error ("\"%s\": can't read symbols: %s.", name,
bfd_errmsg (bfd_get_error ()));
}
/* Parse the input argument - the user can specify a load offset as
a second argument. */
filename = xmalloc (strlen (args) + 1);
- old_cleanups = make_cleanup (free, filename);
+ old_cleanups = make_cleanup (xfree, filename);
strcpy (filename, args);
offptr = strchr (filename, ' ');
if (offptr != NULL)
block_size = size;
buffer = xmalloc (size);
- old_chain = make_cleanup (free, buffer);
+ old_chain = make_cleanup (xfree, buffer);
/* Is this really necessary? I guess it gives the user something
to look at during a long download. */
that. remote.c could implement that method
using the ``qCRC'' packet. */
char *check = xmalloc (len);
- struct cleanup *verify_cleanups = make_cleanup (free, check);
+ struct cleanup *verify_cleanups = make_cleanup (xfree, check);
if (target_read_memory (lma, check, len) != 0)
error ("Download verify read failed at 0x%s",
paddr (lma));
{
/* The first argument is the file name. */
filename = tilde_expand (arg);
- my_cleanups = make_cleanup (free, filename);
+ my_cleanups = make_cleanup (xfree, filename);
}
else
if (argcnt == 1)
/* obstack_specify_allocation also initializes the obstack so
it is empty. */
obstack_specify_allocation (&objfile->psymbol_cache.cache, 0, 0,
- xmalloc, free);
+ xmalloc, xfree);
obstack_specify_allocation (&objfile->psymbol_obstack, 0, 0,
- xmalloc, free);
+ xmalloc, xfree);
obstack_specify_allocation (&objfile->symbol_obstack, 0, 0,
- xmalloc, free);
+ xmalloc, xfree);
obstack_specify_allocation (&objfile->type_obstack, 0, 0,
- xmalloc, free);
+ xmalloc, xfree);
if (build_objfile_section_table (objfile))
{
error ("Can't find the file sections in `%s': %s",
/* query ("Really make files of type %s '%s'?", */
/* ext_args, language_str (lang)); */
- free (filename_language_table[i].ext);
+ xfree (filename_language_table[i].ext);
filename_language_table[i].ext = strsave (ext_args);
filename_language_table[i].lang = lang;
}
simple_free_overlay_table (void)
{
if (cache_ovly_table)
- free (cache_ovly_table);
+ xfree (cache_ovly_table);
cache_novlys = 0;
cache_ovly_table = NULL;
cache_ovly_table_base = 0;
simple_free_overlay_region_table (void)
{
if (cache_ovly_region_table)
- free (cache_ovly_region_table);
+ xfree (cache_ovly_region_table);
cache_novly_regions = 0;
cache_ovly_region_table = NULL;
cache_ovly_region_table_base = 0;
}
filename = tilde_expand (filename);
- make_cleanup (free, filename);
+ make_cleanup (xfree, filename);
outfile = gdb_fopen (filename, FOPEN_WT);
if (outfile == 0)
}
filename = tilde_expand (filename);
- make_cleanup (free, filename);
+ make_cleanup (xfree, filename);
outfile = gdb_fopen (filename, FOPEN_WT);
if (outfile == 0)
}
filename = tilde_expand (filename);
- make_cleanup (free, filename);
+ make_cleanup (xfree, filename);
outfile = gdb_fopen (filename, FOPEN_WT);
if (outfile == 0)
returnval = lookup_symbol_aux (modified_name, block, namespace,
is_a_field_of_this, symtab);
if (needtofreename)
- free (modified_name2);
+ xfree (modified_name2);
return returnval;
}
for (p = symbols; p != NULL; p = next)
{
next = p->next;
- free (p);
+ xfree (p);
}
}
else
{
fputs_filtered (demangled_name, stream);
- free (demangled_name);
+ xfree (demangled_name);
}
#endif
}
{
if (STREQ (new, return_val[i]))
{
- free (new);
+ xfree (new);
return;
}
}
/* skip symbols that cannot match */
if (strcmp (sym_name, oload_name) != 0)
{
- free (sym_name);
+ xfree (sym_name);
return;
}
sym_return_val[sym_return_val_index++] = sym;
sym_return_val[sym_return_val_index] = NULL;
- free (sym_name);
+ xfree (sym_name);
}
/* Return a null-terminated list of pointers to function symbols that
}
}
- free (oload_name);
+ xfree (oload_name);
return (sym_return_val);
}
else
target_stack = cur->next; /* Unchain first on list */
tmp = cur->next;
- free (cur);
+ xfree (cur);
cur = tmp;
}
else
prev->next = cur->next;
- free (cur); /* Release the target_stack_item */
+ xfree (cur); /* Release the target_stack_item */
update_current_target ();
cleanup_target (¤t_target);
{
int *saved_pid_ptr = arg;
inferior_pid = *saved_pid_ptr;
- free (arg);
+ xfree (arg);
}
static struct cleanup *
/* FIXME: do I ever need to call the back-end to give it a
chance at this private data before deleting the thread? */
if (tp->private)
- free (tp->private);
+ xfree (tp->private);
- free (tp);
+ xfree (tp);
}
void
{
struct current_thread_cleanup *old = arg;
restore_current_thread (old->inferior_pid);
- free (old);
+ xfree (old);
}
static struct cleanup *
/* Save a copy of the command in case it is clobbered by
execute_command */
saved_cmd = strdup (cmd);
- saved_cmd_cleanup_chain = make_cleanup (free, (void *) saved_cmd);
+ saved_cmd_cleanup_chain = make_cleanup (xfree, (void *) saved_cmd);
for (tp = thread_list; tp; tp = tp->next)
if (thread_alive (tp))
{
/* Save a copy of the command in case it is clobbered by
execute_command */
saved_cmd = strdup (cmd);
- saved_cmd_cleanup_chain = make_cleanup (free, (void *) saved_cmd);
+ saved_cmd_cleanup_chain = make_cleanup (xfree, (void *) saved_cmd);
while (tidlist < cmd)
{
struct thread_info *tp;
do_chdir_cleanup (void *old_dir)
{
chdir (old_dir);
- free (old_dir);
+ xfree (old_dir);
}
#endif
if we are called again fgetc will still return EOF and
we'll return NULL then. */
break;
- free (result);
+ xfree (result);
return NULL;
}
while (*p1)
*p++ = *p1++;
- free (rl); /* Allocated in readline. */
+ xfree (rl); /* Allocated in readline. */
if (p == linebuffer || *(p - 1) != '\\')
break;
/* If there was an error, call this function again. */
if (expanded < 0)
{
- free (history_value);
+ xfree (history_value);
return command_line_input (prompt_arg, repeat, annotation_suffix);
}
if (strlen (history_value) > linelength)
}
strcpy (linebuffer, history_value);
p = linebuffer + strlen (linebuffer);
- free (history_value);
+ xfree (history_value);
}
}
from bad user-supplied format string? */
sprintf (outp, fmt[0] == 0 ? default_fmt : fmt,
tmp);
- free (tmp);
+ xfree (tmp);
}
else
{
/* ??rehrauer: I don't know why this fails, since it looks as though
assignments to prompt are wrapped in calls to savestring...
if (prompt != NULL)
- free (prompt);
+ xfree (prompt);
*/
if (event_loop_p)
PROMPT (0) = savestring (s, strlen (s));
struct cleanup *old_chain;
t = (struct tracepoint *) xmalloc (sizeof (struct tracepoint));
- old_chain = make_cleanup (free, t);
+ old_chain = make_cleanup (xfree, t);
memset (t, 0, sizeof (*t));
t->address = sal.pc;
if (sal.symtab == NULL)
delete_tracepoint_hook (t);
if (t->addr_string)
- free (t->addr_string);
+ xfree (t->addr_string);
if (t->source_file)
- free (t->source_file);
+ xfree (t->source_file);
if (t->actions)
free_actions (t);
- free (t);
+ xfree (t);
break;
}
}
error ("expression too complicated, try simplifying");
ax_reqs (aexpr, &areqs);
- (void) make_cleanup (free, areqs.reg_mask);
+ (void) make_cleanup (xfree, areqs.reg_mask);
if (areqs.flaw != agent_flaw_none)
error ("malformed expression");
{
next = line->next;
if (line->action)
- free (line->action);
- free (line);
+ xfree (line->action);
+ xfree (line);
}
t->actions = NULL;
}
return;
for (ndx = 0; actions_list[ndx]; ndx++)
- free (actions_list[ndx]);
+ xfree (actions_list[ndx]);
- free (actions_list);
+ xfree (actions_list);
}
/* render all actions into gdb protocol */
sal = sals.sals[0];
}
- old_chain = make_cleanup (free, sals.sals);
+ old_chain = make_cleanup (xfree, sals.sals);
if (sal.symtab == 0)
{
printf_filtered ("TFIND: No line number information available");
if ((tmpstream->ts_streamtype == astring) &&
(tmpstream->ts_strbuf != NULL))
{
- free (tmpstream->ts_strbuf);
+ xfree (tmpstream->ts_strbuf);
}
- free (tmpstream);
+ xfree (tmpstream);
}
struct ui_file *
{
if (ptr != (char *) NULL)
{
- free (ptr);
+ xfree (ptr);
}
return;
format = va_arg (args, char *);
#endif
vasprintf (&linebuffer, format, args);
- old_cleanups = make_cleanup (free, linebuffer);
+ old_cleanups = make_cleanup (xfree, linebuffer);
strcat_to_buf (buf, bufLen, linebuffer);
do_cleanups (old_cleanups);
va_end (args);
winInfo->generic.handle = (WINDOW *) NULL;
freeWinContent (&winInfo->generic);
}
- free (winInfo);
+ xfree (winInfo);
return;
} /* freeWindow */
newLayout = _prevLayout ();
else
status = TUI_FAILURE;
- free (bufPtr);
+ xfree (bufPtr);
tuiSetLayout (newLayout, dpyType);
}
ui_file_delete (struct ui_file *file)
{
file->to_delete (file);
- free (file);
+ xfree (file);
}
static int
if (stream->magic != &mem_file_magic)
internal_error ("mem_file_delete: bad magic number");
if (stream->buffer != NULL)
- free (stream->buffer);
- free (stream);
+ xfree (stream->buffer);
+ xfree (stream);
}
struct ui_file *
{
fclose (stdio->file);
}
- free (stdio);
+ xfree (stdio);
}
static void
uo_table_end (uiout);
if (uiout->table_id)
- free (uiout->table_id);
+ xfree (uiout->table_id);
clear_header_list (uiout);
}
{
long length;
char *buffer = ui_file_xstrdup (buf->stream, &length);
- struct cleanup *old_cleanup = make_cleanup (free, buffer);
+ struct cleanup *old_cleanup = make_cleanup (xfree, buffer);
if (length > 0)
ui_out_field_string (uiout, fldname, buffer);
else
ui_out_stream_delete (struct ui_stream *buf)
{
ui_file_delete (buf->stream);
- free (buf);
+ xfree (buf);
}
static void
uiout->headercurr = uiout->headerfirst;
uiout->headerfirst = uiout->headerfirst->next;
if (uiout->headercurr->colhdr != NULL)
- free (uiout->headercurr->colhdr);
- free (uiout->headercurr);
+ xfree (uiout->headercurr->colhdr);
+ xfree (uiout->headercurr);
}
uiout->headerlast = NULL;
uiout->headercurr = NULL;
and mark data and stack spaces as empty. */
if (corefile)
- free (corefile);
+ xfree (corefile);
corefile = 0;
if (corechan >= 0)
if (filename)
{
filename = tilde_expand (filename);
- make_cleanup (free, filename);
+ make_cleanup (xfree, filename);
if (have_inferior_p ())
error ("To look at a core file, you must kill the program with \"kill\".");
{
*pmy_chain = ptr->next; /* Do this first incase recursion */
(*ptr->function) (ptr->arg);
- free (ptr);
+ xfree (ptr);
}
}
while ((ptr = *pmy_chain) != old_chain)
{
*pmy_chain = ptr->next;
- free (ptr);
+ xfree (ptr);
}
}
internal_error ("free_current_contents: NULL pointer");
if (*location != NULL)
{
- free (*location);
+ xfree (*location);
*location = NULL;
}
}
(continuation_ptr->continuation_hook) (continuation_ptr->arg_list);
saved_continuation = continuation_ptr;
continuation_ptr = continuation_ptr->next;
- free (saved_continuation);
+ xfree (saved_continuation);
}
}
{
continuation_ptr = cmd_continuation;
cmd_continuation = continuation_ptr->next;
- free (continuation_ptr);
+ xfree (continuation_ptr);
}
}
(continuation_ptr->continuation_hook) (continuation_ptr->arg_list);
saved_continuation = continuation_ptr;
continuation_ptr = continuation_ptr->next;
- free (saved_continuation);
+ xfree (saved_continuation);
}
}
{
continuation_ptr = intermediate_continuation;
intermediate_continuation = continuation_ptr->next;
- free (continuation_ptr);
+ xfree (continuation_ptr);
}
}
vfprintf_filtered (gdb_lasterr, string, args);
/* Retrieve the last error and print it to gdb_stderr */
err_string = error_last_message ();
- err_string_cleanup = make_cleanup (free, err_string);
+ err_string_cleanup = make_cleanup (xfree, err_string);
fputs_filtered (err_string, gdb_stderr);
fprintf_filtered (gdb_stderr, "\n");
do_cleanups (err_string_cleanup);
{
long size;
char *msg = ui_file_xstrdup (stream, &size);
- make_cleanup (free, msg);
+ make_cleanup (xfree, msg);
error ("%s", msg);
}
void
mfree (PTR md, PTR ptr)
{
- free (ptr);
+ xfree (ptr);
}
#endif /* USE_MMALLOC */
{
return (xmrealloc ((PTR) NULL, ptr, size));
}
+
+/* Free up space allocated by one of xmalloc(), xcalloc(), or
+ xrealloc(). */
+
+void
+xfree (void *ptr)
+{
+ if (ptr != NULL)
+ free (ptr);
+}
\f
/* Like asprintf/vasprintf but get an internal_error if the call
else
async_request_quit (0);
}
- free (ignore);
+ xfree (ignore);
}
immediate_quit--;
struct cleanup *old_cleanups;
xvasprintf (&linebuffer, format, args);
- old_cleanups = make_cleanup (free, linebuffer);
+ old_cleanups = make_cleanup (xfree, linebuffer);
fputs_maybe_filtered (linebuffer, stream, filter);
do_cleanups (old_cleanups);
}
struct cleanup *old_cleanups;
xvasprintf (&linebuffer, format, args);
- old_cleanups = make_cleanup (free, linebuffer);
+ old_cleanups = make_cleanup (xfree, linebuffer);
fputs_unfiltered (linebuffer, stream);
do_cleanups (old_cleanups);
}
if (n > max_spaces)
{
if (spaces)
- free (spaces);
+ xfree (spaces);
spaces = (char *) xmalloc (n + 1);
for (t = spaces + n; t != spaces;)
*--t = ' ';
fputs_filtered (demangled ? demangled : name, stream);
if (demangled != NULL)
{
- free (demangled);
+ xfree (demangled);
}
}
}
default:
break;
}
- free (parm_types);
+ xfree (parm_types);
if (overload_debug)
{
if (method)
else
{
*symp = oload_syms[oload_champ];
- free (func_name);
+ xfree (func_name);
}
return oload_incompatible ? 100 : (oload_non_standard ? 10 : 0);
{
fprintf_filtered (stream, "%1d", digits[i]);
}
- free (digits);
+ xfree (digits);
fprintf_filtered (stream, local_decimal_format_suffix ());
}
{
buffer = (char *) xmalloc (len * width);
bufptr = buffer;
- old_chain = make_cleanup (free, buffer);
+ old_chain = make_cleanup (xfree, buffer);
nfetch = partial_memory_read (addr, bufptr, len * width, &errcode)
/ width;
buffer = (char *) xrealloc (buffer, (nfetch + bufsize) * width);
}
- old_chain = make_cleanup (free, buffer);
+ old_chain = make_cleanup (xfree, buffer);
bufptr = buffer + bufsize * width;
bufsize += nfetch;
{
for (i = 0; i < VALUE_HISTORY_CHUNK; i++)
if ((val = value_history_chain->values[i]) != NULL)
- free ((PTR) val);
+ xfree (val);
next = value_history_chain->next;
- free ((PTR) value_history_chain);
+ xfree (value_history_chain);
value_history_chain = next;
}
value_history_count = 0;
something in the value chain (i.e., before release_value is
called), because after the error free_all_values will get called before
long. */
- free ((PTR) var->value);
+ xfree (var->value);
var->value = newval;
release_value (newval);
/* End code which must not call error(). */
{
var = internalvars;
internalvars = var->next;
- free ((PTR) var->name);
- free ((PTR) var->value);
- free ((PTR) var);
+ xfree (var->name);
+ xfree (var->value);
+ xfree (var);
}
}
vc->child->parent = NULL;
delete_variable_1 (resultp, delcountp, vc->child, 0, only_children_p);
next = vc->next;
- free (vc);
+ xfree (vc);
}
/* if we were called to delete only the children we are done here */
else
prev->next = cv->next;
- free (cv);
+ xfree (cv);
/* If root, remove varobj from root list */
if (var->root->rootvar == var)
s = *pstack;
v = s->var;
*pstack = (*pstack)->next;
- free (s);
+ xfree (s);
return v;
}
s = *pstack;
v = s->name;
*pstack = (*pstack)->next;
- free (s);
+ xfree (s);
return v;
}
thread_info *here = th->next;
th->next = here->next;
(void) CloseHandle (here->h);
- free (here);
+ xfree (here);
}
}
thread_info *here = th->next;
th->next = here->next;
CloseHandle (here->h);
- free (here);
+ xfree (here);
}
}
while ((so = so1) != NULL)
{
so1 = so->next;
- free (so);
+ xfree (so);
}
solib_start.next = NULL;
ourstatus->kind = TARGET_WAITKIND_STOPPED;
}
- free (s);
+ xfree (s);
return gotasig;
}
out:
if (buf)
- free (buf);
+ xfree (buf);
if (dll_name)
- free (dll_name);
+ xfree (dll_name);
return;
}
thread_info *here = th->next;
th->next = here->next;
(void) close_handle (here->h);
- free (here);
+ xfree (here);
}
}
thread_info *here = th->next;
th->next = here->next;
close_handle (here->h);
- free (here);
+ xfree (here);
}
}
if (function_count == 0)
{
- free (fentry);
+ xfree (fentry);
return oldLineTb;
}
else if (function_count > 1)
++jj, ++newline)
newLineTb->item[newline] = oldLineTb->item[jj];
}
- free (fentry);
+ xfree (fentry);
newLineTb->nitems = oldLineTb->nitems - function_count;
return newLineTb;
}
}
else
{
- free (lv);
+ xfree (lv);
current_subfile->line_vector = lineTb;
}
if (fakename == NULL)
fakename = " ?";
start_subfile (fakename, (char *) 0);
- free (current_subfile->name);
+ xfree (current_subfile->name);
}
current_subfile->name = xstrdup (inclTable[ii].name);
#endif
}
else
{
- free (lv);
+ xfree (lv);
current_subfile->line_vector = lineTb;
}
/* Start with a fresh include table for the next objfile. */
if (inclTable)
{
- free (inclTable);
+ xfree (inclTable);
inclTable = NULL;
}
inclIndx = inclLength = inclDepth = 0;