Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(94)

Unified Diff: gdb/corelow.c

Issue 11969036: Merge GDB 7.5.1 (Closed) Base URL: http://git.chromium.org/native_client/nacl-gdb.git@master
Patch Set: Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « gdb/corefile.c ('k') | gdb/cp-abi.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gdb/corelow.c
diff --git a/gdb/corelow.c b/gdb/corelow.c
index bbfb8ee51fad9fa4de3c345880f9979b23e1802c..dd625604c935b2642c2be40c1dd870f431ad4eb9 100644
--- a/gdb/corelow.c
+++ b/gdb/corelow.c
@@ -46,8 +46,6 @@
#include "filenames.h"
#include "progspace.h"
#include "objfiles.h"
-#include "wrapper.h"
-
#ifndef O_LARGEFILE
#define O_LARGEFILE 0
@@ -77,9 +75,6 @@ struct gdbarch *core_gdbarch = NULL;
unix child targets. */
static struct target_section_table *core_data;
-/* True if we needed to fake the pid of the loaded core inferior. */
-static int core_has_fake_pid = 0;
-
static void core_files_info (struct target_ops *);
static struct core_fns *sniff_core_bfd (bfd *);
@@ -131,8 +126,7 @@ default_core_sniffer (struct core_fns *our_fns, bfd *abfd)
}
/* Walk through the list of core functions to find a set that can
- handle the core file open on ABFD. Default to the first one in the
- list if nothing matches. Returns pointer to set that is
+ handle the core file open on ABFD. Returns pointer to set that is
selected. */
static struct core_fns *
@@ -161,15 +155,9 @@ sniff_core_bfd (bfd *abfd)
bfd_get_filename (abfd), matches);
}
else if (matches == 0)
- {
- warning (_("\"%s\": no core file handler "
- "recognizes format, using default"),
- bfd_get_filename (abfd));
- }
- if (yummy == NULL)
- {
- yummy = core_file_fns;
- }
+ error (_("\"%s\": no core file handler recognizes format"),
+ bfd_get_filename (abfd));
+
return (yummy);
}
@@ -213,16 +201,19 @@ core_close (int quitting)
int pid = ptid_get_pid (inferior_ptid);
inferior_ptid = null_ptid; /* Avoid confusion from thread
stuff. */
- exit_inferior_silent (pid);
+ if (pid != 0)
+ exit_inferior_silent (pid);
/* Clear out solib state while the bfd is still open. See
comments in clear_solib in solib.c. */
clear_solib ();
- xfree (core_data->sections);
- xfree (core_data);
- core_data = NULL;
- core_has_fake_pid = 0;
+ if (core_data)
+ {
+ xfree (core_data->sections);
+ xfree (core_data);
+ core_data = NULL;
+ }
name = bfd_get_filename (core_bfd);
gdb_bfd_close_or_warn (core_bfd);
@@ -249,6 +240,8 @@ add_to_thread_list (bfd *abfd, asection *asect, void *reg_sect_arg)
int core_tid;
int pid, lwpid;
asection *reg_sect = (asection *) reg_sect_arg;
+ int fake_pid_p = 0;
+ struct inferior *inf;
if (strncmp (bfd_section_name (abfd, asect), ".reg/", 5) != 0)
return;
@@ -258,14 +251,18 @@ add_to_thread_list (bfd *abfd, asection *asect, void *reg_sect_arg)
pid = bfd_core_file_pid (core_bfd);
if (pid == 0)
{
- core_has_fake_pid = 1;
+ fake_pid_p = 1;
pid = CORELOW_PID;
}
lwpid = core_tid;
- if (current_inferior ()->pid == 0)
- inferior_appeared (current_inferior (), pid);
+ inf = current_inferior ();
+ if (inf->pid == 0)
+ {
+ inferior_appeared (inf, pid);
+ inf->fake_pid_p = fake_pid_p;
+ }
ptid = ptid_build (pid, lwpid, 0);
@@ -290,6 +287,7 @@ core_open (char *filename, int from_tty)
bfd *temp_bfd;
int scratch_chan;
int flags;
+ volatile struct gdb_exception except;
target_preopen (from_tty);
if (!filename)
@@ -386,7 +384,6 @@ core_open (char *filename, int from_tty)
init_thread_list ();
inferior_ptid = null_ptid;
- core_has_fake_pid = 0;
/* Need to flush the register cache (and the frame cache) from a
previous debug session. If inferior_ptid ends up the same as the
@@ -428,7 +425,13 @@ core_open (char *filename, int from_tty)
may be a thread_stratum target loaded on top of target core by
now. The layer above should claim threads found in the BFD
sections. */
- gdb_target_find_new_threads ();
+ TRY_CATCH (except, RETURN_MASK_ERROR)
+ {
+ target_find_new_threads ();
+ }
+
+ if (except.reason < 0)
+ exception_print (gdb_stderr, except);
p = bfd_core_file_failing_command (core_bfd);
if (p)
@@ -437,17 +440,20 @@ core_open (char *filename, int from_tty)
siggy = bfd_core_file_failing_signal (core_bfd);
if (siggy > 0)
{
- /* NOTE: target_signal_from_host() converts a target signal
- value into gdb's internal signal value. Unfortunately gdb's
- internal value is called ``target_signal'' and this function
- got the name ..._from_host(). */
- enum target_signal sig = (core_gdbarch != NULL
- ? gdbarch_target_signal_from_host (core_gdbarch,
- siggy)
- : target_signal_from_host (siggy));
+ /* If we don't have a CORE_GDBARCH to work with, assume a native
+ core (map gdb_signal from host signals). If we do have
+ CORE_GDBARCH to work with, but no gdb_signal_from_target
+ implementation for that gdbarch, as a fallback measure,
+ assume the host signal mapping. It'll be correct for native
+ cores, but most likely incorrect for cross-cores. */
+ enum gdb_signal sig = (core_gdbarch != NULL
+ && gdbarch_gdb_signal_from_target_p (core_gdbarch)
+ ? gdbarch_gdb_signal_from_target (core_gdbarch,
+ siggy)
+ : gdb_signal_from_host (siggy));
printf_filtered (_("Program terminated with signal %d, %s.\n"),
- siggy, target_signal_to_string (sig));
+ siggy, gdb_signal_to_string (sig));
}
/* Fetch all registers from core file. */
@@ -847,6 +853,7 @@ static char *
core_pid_to_str (struct target_ops *ops, ptid_t ptid)
{
static char buf[64];
+ struct inferior *inf;
int pid;
/* The preferred way is to have a gdbarch/OS specific
@@ -865,7 +872,8 @@ core_pid_to_str (struct target_ops *ops, ptid_t ptid)
/* Otherwise, this isn't a "threaded" core -- use the PID field, but
only if it isn't a fake PID. */
- if (!core_has_fake_pid)
+ inf = find_inferior_pid (ptid_get_pid (ptid));
+ if (inf != NULL && !inf->fake_pid_p)
return normal_pid_to_str (ptid);
/* No luck. We simply don't have a valid PID to print. */
« no previous file with comments | « gdb/corefile.c ('k') | gdb/cp-abi.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698