static struct linux_gdbarch_data *
get_linux_gdbarch_data (struct gdbarch *gdbarch)
{
- return gdbarch_data (gdbarch, linux_gdbarch_data_handle);
+ return ((struct linux_gdbarch_data *)
+ gdbarch_data (gdbarch, linux_gdbarch_data_handle));
}
/* Per-inferior data key. */
{
struct linux_info *info;
- info = inferior_data (inf, linux_inferior_data);
+ info = (struct linux_info *) inferior_data (inf, linux_inferior_data);
if (info != NULL)
{
xfree (info);
struct linux_info *info;
struct inferior *inf = current_inferior ();
- info = inferior_data (inf, linux_inferior_data);
+ info = (struct linux_info *) inferior_data (inf, linux_inferior_data);
if (info == NULL)
{
info = XCNEW (struct linux_info);
if (note_size < 2 * addr_size)
error (_("malformed core note - too short for header"));
- contents = xmalloc (note_size);
+ contents = (unsigned char *) xmalloc (note_size);
cleanup = make_cleanup (xfree, contents);
if (!bfd_get_section_contents (core_bfd, section, contents, 0, note_size))
error (_("could not get core note contents"));
error (_("unable to handle request"));
}
-/* Callback function for linux_find_memory_regions_full. If it returns
- non-zero linux_find_memory_regions_full returns immediately with that
- value. */
-
typedef int linux_find_memory_region_ftype (ULONGEST vaddr, ULONGEST size,
ULONGEST offset, ULONGEST inode,
int read, int write,
const char *filename,
void *data);
-/* List memory regions in the inferior PID matched to FILTERFLAGS for
- a corefile. Call FUNC with FUNC_DATA for each such region. Return
- immediately with the value returned by FUNC if it is non-zero.
- *MEMORY_TO_FREE_PTR should be registered to be freed automatically if
- called FUNC throws an exception. MEMORY_TO_FREE_PTR can be also
- passed as NULL if it is not used. Return -1 if error occurs, 0 if
- all memory regions have been processed or return the value from FUNC
- if FUNC returns non-zero. */
+/* List memory regions in the inferior for a corefile. */
static int
-linux_find_memory_regions_full (pid_t pid, enum filterflags filterflags,
+linux_find_memory_regions_full (struct gdbarch *gdbarch,
linux_find_memory_region_ftype *func,
- void *func_data)
+ void *obfd)
{
char mapsfilename[100];
- char *data;
+ char coredumpfilter_name[100];
+ char *data, *coredumpfilterdata;
+ pid_t pid;
+ /* Default dump behavior of coredump_filter (0x33), according to
+ Documentation/filesystems/proc.txt from the Linux kernel
+ tree. */
+ enum filterflags filterflags = (COREFILTER_ANON_PRIVATE
+ | COREFILTER_ANON_SHARED
+ | COREFILTER_ELF_HEADERS
+ | COREFILTER_HUGETLB_PRIVATE);
+
+ /* We need to know the real target PID to access /proc. */
+ if (current_inferior ()->fake_pid_p)
+ return 1;
+
+ pid = current_inferior ()->pid;
+
+ if (use_coredump_filter)
+ {
+ xsnprintf (coredumpfilter_name, sizeof (coredumpfilter_name),
+ "/proc/%d/coredump_filter", pid);
+ coredumpfilterdata = target_fileio_read_stralloc (NULL,
+ coredumpfilter_name);
+ if (coredumpfilterdata != NULL)
+ {
+ sscanf (coredumpfilterdata, "%x", &filterflags);
+ xfree (coredumpfilterdata);
+ }
+ }
xsnprintf (mapsfilename, sizeof mapsfilename, "/proc/%d/smaps", pid);
data = target_fileio_read_stralloc (NULL, mapsfilename);
{
struct cleanup *cleanup = make_cleanup (xfree, data);
char *line, *t;
- int retval = 0;
line = strtok_r (data, "\n", &t);
while (line != NULL)
/* Invoke the callback function to create the corefile segment. */
if (should_dump_p)
- retval = func (addr, endaddr - addr, offset, inode,
- read, write, exec,
- 1, /* MODIFIED is true because we want to dump the
- mapping. */
- filename, func_data);
- if (retval != 0)
- break;
+ func (addr, endaddr - addr, offset, inode,
+ read, write, exec, 1, /* MODIFIED is true because we
+ want to dump the mapping. */
+ filename, obfd);
}
do_cleanups (cleanup);
- return retval;
+ return 0;
}
- return -1;
+ return 1;
}
/* A structure for passing information through
/* The original datum. */
- void *data;
+ void *obfd;
};
/* A callback for linux_find_memory_regions that converts between the
int read, int write, int exec, int modified,
const char *filename, void *arg)
{
- struct linux_find_memory_regions_data *data = arg;
-
- return data->func (vaddr, size, read, write, exec, modified, data->data);
-}
-
-/* Wrapper of linux_find_memory_regions_full handling FAKE_PID_P in GDB. */
-
-static int
-linux_find_memory_regions_gdb (struct gdbarch *gdbarch,
- linux_find_memory_region_ftype *func,
- void *func_data)
-{
- pid_t pid;
- /* Default dump behavior of coredump_filter (0x33), according to
- Documentation/filesystems/proc.txt from the Linux kernel
- tree. */
- enum filterflags filterflags = (COREFILTER_ANON_PRIVATE
- | COREFILTER_ANON_SHARED
- | COREFILTER_ELF_HEADERS
- | COREFILTER_HUGETLB_PRIVATE);
-
- /* We need to know the real target PID so
- linux_find_memory_regions_full can access /proc. */
- if (current_inferior ()->fake_pid_p)
- return -1;
-
- pid = current_inferior ()->pid;
-
- if (use_coredump_filter)
- {
- char coredumpfilter_name[100], *coredumpfilterdata;
-
- xsnprintf (coredumpfilter_name, sizeof (coredumpfilter_name),
- "/proc/%d/coredump_filter", pid);
- coredumpfilterdata = target_fileio_read_stralloc (NULL,
- coredumpfilter_name);
- if (coredumpfilterdata != NULL)
- {
- sscanf (coredumpfilterdata, "%x", &filterflags);
- xfree (coredumpfilterdata);
- }
- }
+ struct linux_find_memory_regions_data *data
+ = (struct linux_find_memory_regions_data *) arg;
- return linux_find_memory_regions_full (pid, filterflags, func, func_data);
+ return data->func (vaddr, size, read, write, exec, modified, data->obfd);
}
/* A variant of linux_find_memory_regions_full that is suitable as the
static int
linux_find_memory_regions (struct gdbarch *gdbarch,
- find_memory_region_ftype func, void *func_data)
+ find_memory_region_ftype func, void *obfd)
{
struct linux_find_memory_regions_data data;
data.func = func;
- data.data = func_data;
+ data.obfd = obfd;
- return linux_find_memory_regions_gdb (gdbarch,
- linux_find_memory_regions_thunk, &data);
+ return linux_find_memory_regions_full (gdbarch,
+ linux_find_memory_regions_thunk,
+ &data);
}
/* Determine which signal stopped execution. */
int read, int write, int exec, int modified,
const char *filename, void *data)
{
- struct linux_make_mappings_data *map_data = data;
+ struct linux_make_mappings_data *map_data
+ = (struct linux_make_mappings_data *) data;
gdb_byte buf[sizeof (ULONGEST)];
if (*filename == '\0' || inode == 0)
pack_long (buf, long_type, 1);
obstack_grow (&data_obstack, buf, TYPE_LENGTH (long_type));
- linux_find_memory_regions_gdb (gdbarch, linux_make_mappings_callback,
- &mapping_data);
+ linux_find_memory_regions_full (gdbarch, linux_make_mappings_callback,
+ &mapping_data);
if (mapping_data.file_count != 0)
{
gdb_assert (regset && regset->collect_regset);
- buf = xmalloc (size);
+ buf = (char *) xmalloc (size);
regset->collect_regset (regset, data->regcache, -1, buf, size);
/* PRSTATUS still needs to be treated specially. */
siginfo_type = gdbarch_get_siginfo_type (gdbarch);
- buf = xmalloc (TYPE_LENGTH (siginfo_type));
+ buf = (gdb_byte *) xmalloc (TYPE_LENGTH (siginfo_type));
cleanups = make_cleanup (xfree, buf);
bytes_read = target_read (¤t_target, TARGET_OBJECT_SIGNAL_INFO, NULL,
static int
linux_corefile_thread_callback (struct thread_info *info, void *data)
{
- struct linux_corefile_thread_data *args = data;
+ struct linux_corefile_thread_data *args
+ = (struct linux_corefile_thread_data *) data;
/* It can be current thread
which cannot be removed by update_thread_list. */
int read, int write, int exec, int modified,
void *data)
{
- struct mem_range *range = data;
+ struct mem_range *range = (struct mem_range *) data;
if (vaddr == range->start)
{