Add cast in python.c
[deliverable/binutils-gdb.git] / gdb / linux-tdep.c
index 982599e397262101bc3082724ee696f9b7e56ab7..7c24eaab6e1252471c785a90384fdbc6a730dbe6 100644 (file)
@@ -171,7 +171,8 @@ init_linux_gdbarch_data (struct gdbarch *gdbarch)
 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.  */
@@ -203,7 +204,7 @@ invalidate_linux_cache_inf (struct inferior *inf)
 {
   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);
@@ -230,7 +231,7 @@ get_linux_inferior_data (void)
   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);
@@ -997,7 +998,7 @@ linux_core_info_proc_mappings (struct gdbarch *gdbarch, const char *args)
   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"));
@@ -1098,10 +1099,6 @@ linux_core_info_proc (struct gdbarch *gdbarch, const char *args,
     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,
@@ -1109,22 +1106,43 @@ typedef int linux_find_memory_region_ftype (ULONGEST vaddr, ULONGEST size,
                                            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);
@@ -1139,7 +1157,6 @@ linux_find_memory_regions_full (pid_t pid, enum filterflags filterflags,
     {
       struct cleanup *cleanup = make_cleanup (xfree, data);
       char *line, *t;
-      int retval = 0;
 
       line = strtok_r (data, "\n", &t);
       while (line != NULL)
@@ -1254,20 +1271,17 @@ linux_find_memory_regions_full (pid_t pid, enum filterflags filterflags,
 
          /* 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
@@ -1281,7 +1295,7 @@ struct linux_find_memory_regions_data
 
   /* The original datum.  */
 
-  void *data;
+  void *obfd;
 };
 
 /* A callback for linux_find_memory_regions that converts between the
@@ -1293,50 +1307,10 @@ linux_find_memory_regions_thunk (ULONGEST vaddr, ULONGEST size,
                                 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
@@ -1344,15 +1318,16 @@ linux_find_memory_regions_gdb (struct gdbarch *gdbarch,
 
 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.  */
@@ -1481,7 +1456,8 @@ linux_make_mappings_callback (ULONGEST vaddr, ULONGEST size,
                              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)
@@ -1534,8 +1510,8 @@ linux_make_mappings_corefile_notes (struct gdbarch *gdbarch, bfd *obfd,
   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)
     {
@@ -1582,14 +1558,15 @@ linux_collect_regset_section_cb (const char *sect_name, int size,
                                 const char *human_name, void *cb_data)
 {
   char *buf;
-  struct linux_collect_regset_section_cb_data *data = cb_data;
+  struct linux_collect_regset_section_cb_data *data
+    = (struct linux_collect_regset_section_cb_data *) cb_data;
 
   if (data->abort_iteration)
     return;
 
   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.  */
@@ -1657,7 +1634,7 @@ linux_get_siginfo_data (struct gdbarch *gdbarch, LONGEST *size)
   
   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 (&current_target, TARGET_OBJECT_SIGNAL_INFO, NULL,
@@ -1692,7 +1669,8 @@ struct linux_corefile_thread_data
 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.  */
@@ -2279,7 +2257,7 @@ find_mapping_size (CORE_ADDR vaddr, unsigned long size,
                   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)
     {
This page took 0.029183 seconds and 4 git commands to generate.