From: Michael Snyder Date: Thu, 19 Jun 2003 22:52:04 +0000 (+0000) Subject: 2003-06-19 Michael Snyder X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=0274a8cedbd446865a1e5fdec8057f4a327e19aa;p=binutils-gdb.git 2003-06-19 Michael Snyder * linux-nat.h: New file. * linux-nat.c: Include linux-nat.h. * lin-lwp.c: Include linux-nat.h. Move struct lwp_info def to linux-nat.h. * linux-proc.c: Include linux-nat.h. (linux_make_note_section): Iterate over lwps instead of threads. (linux_do_thread_registers): Use lwp instead of merged pid. * config/nm-linux.h: Move miscelaneous def'ns to linux-nat.h. * Makefile.in (lin-lwp.o, linux-proc.o, linux-nat.o): Add dependency on linux_nat_h. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 1e07f8b4e1e..c43feaa9638 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,16 @@ +2003-06-19 Michael Snyder + + * linux-nat.h: New file. + * linux-nat.c: Include linux-nat.h. + * lin-lwp.c: Include linux-nat.h. + Move struct lwp_info def to linux-nat.h. + * linux-proc.c: Include linux-nat.h. + (linux_make_note_section): Iterate over lwps instead of threads. + (linux_do_thread_registers): Use lwp instead of merged pid. + * config/nm-linux.h: Move miscelaneous def'ns to linux-nat.h. + * Makefile.in (lin-lwp.o, linux-proc.o, linux-nat.o): + Add dependency on linux_nat_h. + 2003-06-19 Theodore A. Roth * avr-tdep.c (avr_extract_return_value): Delete debugging fprintf. diff --git a/gdb/Makefile.in b/gdb/Makefile.in index 6dcd7b7fb04..bd4f6cd9af0 100644 --- a/gdb/Makefile.in +++ b/gdb/Makefile.in @@ -685,6 +685,7 @@ jv_lang_h = jv-lang.h kod_h = kod.h language_h = language.h linespec_h = linespec.h +linux_nat_h = linux-nat.h m2_lang_h = m2-lang.h m68k_tdep_h = m68k-tdep.h macroexp_h = macroexp.h @@ -1912,14 +1913,16 @@ language.o: language.c $(defs_h) $(gdb_string_h) $(symtab_h) $(gdbtypes_h) \ $(value_h) $(gdbcmd_h) $(expression_h) $(language_h) $(target_h) \ $(parser_defs_h) $(jv_lang_h) $(demangle_h) lin-lwp.o: lin-lwp.c $(defs_h) $(gdb_assert_h) $(gdb_string_h) $(gdb_wait_h) \ - $(gdbthread_h) $(inferior_h) $(target_h) $(regcache_h) $(gdbcmd_h) + $(gdbthread_h) $(inferior_h) $(target_h) $(regcache_h) $(gdbcmd_h) \ + $(linux_nat_h) linespec.o: linespec.c $(defs_h) $(symtab_h) $(frame_h) $(command_h) \ $(symfile_h) $(objfiles_h) $(source_h) $(demangle_h) $(value_h) \ $(completer_h) $(cp_abi_h) $(parser_defs_h) $(block_h) $(objc_lang_h) -linux-nat.o: linux-nat.c $(defs_h) $(inferior_h) $(target_h) $(gdb_wait_h) +linux-nat.o: linux-nat.c $(defs_h) $(inferior_h) $(target_h) $(gdb_wait_h) \ + $(linux_nat_h) linux-proc.o: linux-proc.c $(defs_h) $(inferior_h) $(regcache_h) \ $(gregset_h) $(gdbcore_h) $(gdbthread_h) $(elf_bfd_h) \ - $(cli_decode_h) $(gdb_string_h) + $(cli_decode_h) $(gdb_string_h) $(linux_nat_h) lynx-nat.o: lynx-nat.c $(defs_h) $(frame_h) $(inferior_h) $(target_h) \ $(gdbcore_h) $(regcache_h) m2-lang.o: m2-lang.c $(defs_h) $(symtab_h) $(gdbtypes_h) $(expression_h) \ diff --git a/gdb/config/nm-linux.h b/gdb/config/nm-linux.h index e4ac629aad4..9a04cf71cf1 100644 --- a/gdb/config/nm-linux.h +++ b/gdb/config/nm-linux.h @@ -70,13 +70,6 @@ extern void lin_thread_get_thread_signals (sigset_t *mask); /* Override child_pid_to_exec_file in 'inftarg.c'. */ #define CHILD_PID_TO_EXEC_FILE -struct mem_attrib; -extern int linux_proc_xfer_memory (CORE_ADDR addr, char *myaddr, int len, - int write, struct mem_attrib *attrib, - struct target_ops *target); - -extern void linux_record_stopped_pid (int pid); - #define CHILD_INSERT_FORK_CATCHPOINT #define CHILD_INSERT_VFORK_CATCHPOINT #define CHILD_INSERT_EXEC_CATCHPOINT diff --git a/gdb/lin-lwp.c b/gdb/lin-lwp.c index 30dbd96f7ce..a82adb7ea2a 100644 --- a/gdb/lin-lwp.c +++ b/gdb/lin-lwp.c @@ -40,6 +40,8 @@ static int debug_lin_lwp; extern char *strsignal (int sig); +#include "linux-nat.h" + /* On GNU/Linux there are no real LWP's. The closest thing to LWP's are processes sharing the same VM space. A multi-threaded process is basically a group of such processes. However, such a grouping @@ -73,43 +75,6 @@ extern char *strsignal (int sig); threads will run out of processes, even if the threads exit, because the "zombies" stay around. */ -/* Structure describing a LWP. */ -struct lwp_info -{ - /* The process id of the LWP. This is a combination of the LWP id - and overall process id. */ - ptid_t ptid; - - /* Non-zero if this LWP is cloned. In this context "cloned" means - that the LWP is reporting to its parent using a signal other than - SIGCHLD. */ - int cloned; - - /* Non-zero if we sent this LWP a SIGSTOP (but the LWP didn't report - it back yet). */ - int signalled; - - /* Non-zero if this LWP is stopped. */ - int stopped; - - /* Non-zero if this LWP will be/has been resumed. Note that an LWP - can be marked both as stopped and resumed at the same time. This - happens if we try to resume an LWP that has a wait status - pending. We shouldn't let the LWP run until that wait status has - been processed, but we should not report that wait status if GDB - didn't try to let the LWP run. */ - int resumed; - - /* If non-zero, a pending wait status. */ - int status; - - /* Non-zero if we were stepping this LWP. */ - int step; - - /* Next LWP in list. */ - struct lwp_info *next; -}; - /* List of known LWPs. */ static struct lwp_info *lwp_list; diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c index bef737b92a9..61931c6d58f 100644 --- a/gdb/linux-nat.c +++ b/gdb/linux-nat.c @@ -25,6 +25,8 @@ #include "gdb_wait.h" #include +#include "linux-nat.h" + /* If the system headers did not provide the constants, hard-code the normal values. */ #ifndef PTRACE_EVENT_FORK diff --git a/gdb/linux-nat.h b/gdb/linux-nat.h new file mode 100644 index 00000000000..78312d71b31 --- /dev/null +++ b/gdb/linux-nat.h @@ -0,0 +1,70 @@ +/* Native debugging support for GNU/Linux (LWP layer). + Copyright 2000, 2001, 2002, 2003 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. */ + +/* Structure describing an LWP. */ + +struct lwp_info +{ + /* The process id of the LWP. This is a combination of the LWP id + and overall process id. */ + ptid_t ptid; + + /* Non-zero if this LWP is cloned. In this context "cloned" means + that the LWP is reporting to its parent using a signal other than + SIGCHLD. */ + int cloned; + + /* Non-zero if we sent this LWP a SIGSTOP (but the LWP didn't report + it back yet). */ + int signalled; + + /* Non-zero if this LWP is stopped. */ + int stopped; + + /* Non-zero if this LWP will be/has been resumed. Note that an LWP + can be marked both as stopped and resumed at the same time. This + happens if we try to resume an LWP that has a wait status + pending. We shouldn't let the LWP run until that wait status has + been processed, but we should not report that wait status if GDB + didn't try to let the LWP run. */ + int resumed; + + /* If non-zero, a pending wait status. */ + int status; + + /* Non-zero if we were stepping this LWP. */ + int step; + + /* Next LWP in list. */ + struct lwp_info *next; +}; + +/* Read/write to target memory via Linux's "proc file system". */ +struct mem_attrib; +extern int linux_proc_xfer_memory (CORE_ADDR addr, char *myaddr, int len, + int write, struct mem_attrib *attrib, + struct target_ops *target); + +extern void linux_record_stopped_pid (int pid); + +/* Iterator function for lin-lwp's lwp list. */ +struct lwp_info *iterate_over_lwps (int (*callback) (struct lwp_info *, + void *), + void *data); diff --git a/gdb/linux-proc.c b/gdb/linux-proc.c index a9512964dab..e4ea747008b 100644 --- a/gdb/linux-proc.c +++ b/gdb/linux-proc.c @@ -35,6 +35,8 @@ #include "cli/cli-decode.h" /* for add_info */ #include "gdb_string.h" +#include "linux-nat.h" + #ifndef O_LARGEFILE #define O_LARGEFILE 0 #endif @@ -171,13 +173,13 @@ linux_do_thread_registers (bfd *obfd, ptid_t ptid, #ifdef FILL_FPXREGSET gdb_fpxregset_t fpxregs; #endif - unsigned long merged_pid = ptid_get_tid (ptid) << 16 | ptid_get_pid (ptid); + unsigned long lwp = ptid_get_lwp (ptid); fill_gregset (&gregs, -1); note_data = (char *) elfcore_write_prstatus (obfd, note_data, note_size, - merged_pid, + lwp, stop_signal, &gregs); fill_fpregset (&fpregs, -1); @@ -210,7 +212,7 @@ struct linux_corefile_thread_data */ static int -linux_corefile_thread_callback (struct thread_info *ti, void *data) +linux_corefile_thread_callback (struct lwp_info *ti, void *data) { struct linux_corefile_thread_data *args = data; ptid_t saved_ptid = inferior_ptid; @@ -268,7 +270,7 @@ linux_make_note_section (bfd *obfd, int *note_size) thread_args.note_data = note_data; thread_args.note_size = note_size; thread_args.num_notes = 0; - iterate_over_threads (linux_corefile_thread_callback, &thread_args); + iterate_over_lwps (linux_corefile_thread_callback, &thread_args); if (thread_args.num_notes == 0) { /* iterate_over_threads didn't come up with any threads;