Changeset View
Changeset View
Standalone View
Standalone View
head/devel/gdb/files/kgdb/fbsd-kvm.c
Show All 21 Lines | |||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | ||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||||
*/ | */ | ||||
#include <sys/cdefs.h> | #include <sys/cdefs.h> | ||||
__FBSDID("$FreeBSD$"); | __FBSDID("$FreeBSD$"); | ||||
#include <sys/param.h> | #include "defs.h" | ||||
#include <sys/proc.h> | #include "command.h" | ||||
#include <sys/sysctl.h> | |||||
#include <sys/user.h> | |||||
#include <err.h> | |||||
#include <fcntl.h> | |||||
#include <kvm.h> | |||||
#include <defs.h> | |||||
#include <readline/readline.h> | |||||
#include <readline/tilde.h> | |||||
#include <command.h> | |||||
#include "elf-bfd.h" | #include "elf-bfd.h" | ||||
#include <exec.h> | |||||
#include "filenames.h" | #include "filenames.h" | ||||
#include <frame-unwind.h> | #include "gdbcore.h" | ||||
#include <gdb.h> | #include "gdbthread.h" | ||||
#include <gdbcore.h> | |||||
#include <gdbthread.h> | |||||
#include "gdb_obstack.h" | #include "gdb_obstack.h" | ||||
#include <inferior.h> | #include "inferior.h" | ||||
#include <language.h> | |||||
#include "objfiles.h" | #include "objfiles.h" | ||||
#include "osabi.h" | #include "osabi.h" | ||||
#include <regcache.h> | #include "solib.h" | ||||
#include <solib.h> | #include "target.h" | ||||
#include <target.h> | #include "value.h" | ||||
#include <ui-out.h> | #include "readline/tilde.h" | ||||
#include <sys/user.h> | |||||
#include <fcntl.h> | |||||
#include <kvm.h> | |||||
#include "kgdb.h" | #include "kgdb.h" | ||||
static CORE_ADDR stoppcbs; | static CORE_ADDR stoppcbs; | ||||
static LONGEST pcb_size; | static LONGEST pcb_size; | ||||
static void kgdb_core_cleanup(void *); | static void kgdb_core_cleanup(void *); | ||||
static char *vmcore; | static char *vmcore; | ||||
▲ Show 20 Lines • Show All 431 Lines • ▼ Show 20 Lines | |||||
kgdb_trgt_remove_breakpoint(struct target_ops *ops, struct gdbarch *gdbarch, | kgdb_trgt_remove_breakpoint(struct target_ops *ops, struct gdbarch *gdbarch, | ||||
struct bp_target_info *bp_tgt, enum remove_bp_reason reason) | struct bp_target_info *bp_tgt, enum remove_bp_reason reason) | ||||
{ | { | ||||
return 0; | return 0; | ||||
} | } | ||||
static void | static void | ||||
kgdb_switch_to_thread(int tid) | kgdb_switch_to_thread(const char *arg, int tid) | ||||
{ | { | ||||
char buf[16]; | struct thread_info *tp; | ||||
int thread_id; | |||||
thread_id = ptid_to_global_thread_id(fbsd_vmcore_ptid(tid)); | tp = find_thread_ptid (fbsd_vmcore_ptid (tid)); | ||||
if (thread_id == 0) | if (tp == NULL) | ||||
error ("invalid tid"); | error ("invalid tid"); | ||||
snprintf(buf, sizeof(buf), "%d", thread_id); | thread_select (arg, tp); | ||||
gdb_thread_select(current_uiout, buf, NULL); | |||||
} | } | ||||
static void | static void | ||||
kgdb_set_proc_cmd (char *arg, int from_tty) | kgdb_set_proc_cmd (const char *arg, int from_tty) | ||||
{ | { | ||||
CORE_ADDR addr; | CORE_ADDR addr; | ||||
struct kthr *thr; | struct kthr *thr; | ||||
if (!arg) | if (!arg) | ||||
error_no_arg ("proc address for the new context"); | error_no_arg ("proc address for the new context"); | ||||
if (kvm == NULL) | if (kvm == NULL) | ||||
error ("only supported for core file target"); | error ("only supported for core file target"); | ||||
addr = parse_and_eval_address (arg); | addr = parse_and_eval_address (arg); | ||||
if (addr < kernstart) { | if (addr < kernstart) { | ||||
thr = kgdb_thr_lookup_pid((int)addr); | thr = kgdb_thr_lookup_pid((int)addr); | ||||
if (thr == NULL) | if (thr == NULL) | ||||
error ("invalid pid"); | error ("invalid pid"); | ||||
} else { | } else { | ||||
thr = kgdb_thr_lookup_paddr(addr); | thr = kgdb_thr_lookup_paddr(addr); | ||||
if (thr == NULL) | if (thr == NULL) | ||||
error("invalid proc address"); | error("invalid proc address"); | ||||
} | } | ||||
kgdb_switch_to_thread(thr->tid); | kgdb_switch_to_thread(arg, thr->tid); | ||||
} | } | ||||
static void | static void | ||||
kgdb_set_tid_cmd (char *arg, int from_tty) | kgdb_set_tid_cmd (const char *arg, int from_tty) | ||||
{ | { | ||||
CORE_ADDR addr; | CORE_ADDR addr; | ||||
struct kthr *thr; | struct kthr *thr; | ||||
if (!arg) | if (!arg) | ||||
error_no_arg ("TID or thread address for the new context"); | error_no_arg ("TID or thread address for the new context"); | ||||
addr = (CORE_ADDR) parse_and_eval_address (arg); | addr = (CORE_ADDR) parse_and_eval_address (arg); | ||||
if (kvm != NULL && addr >= kernstart) { | if (kvm != NULL && addr >= kernstart) { | ||||
thr = kgdb_thr_lookup_taddr(addr); | thr = kgdb_thr_lookup_taddr(addr); | ||||
if (thr == NULL) | if (thr == NULL) | ||||
error("invalid thread address"); | error("invalid thread address"); | ||||
addr = thr->tid; | addr = thr->tid; | ||||
} | } | ||||
kgdb_switch_to_thread(addr); | kgdb_switch_to_thread(arg, addr); | ||||
} | } | ||||
static int | static int | ||||
kgdb_trgt_return_one(struct target_ops *ops) | kgdb_trgt_return_one(struct target_ops *ops) | ||||
{ | { | ||||
return 1; | return 1; | ||||
} | } | ||||
void _initialize_kgdb_target(void); | |||||
void | void | ||||
_initialize_kgdb_target(void) | _initialize_kgdb_target(void) | ||||
{ | { | ||||
kgdb_trgt_ops.to_magic = OPS_MAGIC; | kgdb_trgt_ops.to_magic = OPS_MAGIC; | ||||
kgdb_trgt_ops.to_shortname = "vmcore"; | kgdb_trgt_ops.to_shortname = "vmcore"; | ||||
kgdb_trgt_ops.to_longname = "kernel core dump file"; | kgdb_trgt_ops.to_longname = "kernel core dump file"; | ||||
Show All 39 Lines |