X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=base%2Fremote_gdb.cc;h=67d745d437305fe84c896c68ed5e863b8952c3b8;hb=71bf22165acb4a330a98e183f96188daf49d078f;hp=7b73d60e9a9f754371fbb20f5e6926514d3a0e20;hpb=59a6e9d705dd6d143534a42822634f67046ff16c;p=gem5.git diff --git a/base/remote_gdb.cc b/base/remote_gdb.cc index 7b73d60e9..67d745d43 100644 --- a/base/remote_gdb.cc +++ b/base/remote_gdb.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003 The Regents of The University of Michigan + * Copyright (c) 2002-2005 The Regents of The University of Michigan * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -116,33 +116,37 @@ #include -#include - #include #include +#include -#include "cpu/exec_context.hh" #include "base/intmath.hh" #include "base/kgdb.h" - -#include "mem/functional_mem/physical_memory.hh" #include "base/remote_gdb.hh" #include "base/socket.hh" #include "base/trace.hh" -#include "targetarch/vtophys.hh" -#include "sim/system.hh" +#include "cpu/exec_context.hh" #include "cpu/static_inst.hh" +#include "mem/functional/physical.hh" +#include "sim/system.hh" +#include "targetarch/vtophys.hh" using namespace std; -#ifdef DEBUG -RemoteGDB *theDebugger = NULL; +#ifndef NDEBUG +vector debuggers; +int current_debugger = -1; void debugger() { - if (theDebugger) - theDebugger->trap(ALPHA_KENTRY_IF); + if (current_debugger >= 0 && current_debugger < debuggers.size()) { + RemoteGDB *gdb = debuggers[current_debugger]; + if (!gdb->isattached()) + gdb->listener->accept(); + if (gdb->isattached()) + gdb->trap(ALPHA_KENTRY_IF); + } } #endif @@ -163,7 +167,10 @@ GDBListener::Event::process(int revent) GDBListener::GDBListener(RemoteGDB *g, int p) : event(NULL), gdb(g), port(p) -{} +{ + assert(!gdb->listener); + gdb->listener = this; +} GDBListener::~GDBListener() { @@ -185,9 +192,21 @@ GDBListener::listen() port++; } - cerr << "Listening for remote gdb connection on port " << port << endl; event = new Event(this, listener.getfd(), POLLIN); pollQueue.schedule(event); + +#ifndef NDEBUG + gdb->number = debuggers.size(); + debuggers.push_back(gdb); +#endif + +#ifndef NDEBUG + ccprintf(cerr, "%d: %s: listening for remote gdb #%d on port %d\n", + curTick, name(), gdb->number, port); +#else + ccprintf(cerr, "%d: %s: listening for remote gdb on port %d\n", + curTick, name(), port); +#endif } void @@ -230,7 +249,8 @@ RemoteGDB::Event::process(int revent) } RemoteGDB::RemoteGDB(System *_system, ExecContext *c) - : event(NULL), fd(-1), active(false), attached(false), + : event(NULL), listener(NULL), number(-1), fd(-1), + active(false), attached(false), system(_system), pmem(_system->physmem), context(c) { memset(gdbregs, 0, sizeof(gdbregs)); @@ -262,9 +282,6 @@ RemoteGDB::attach(int f) attached = true; DPRINTFN("remote gdb attached\n"); -#ifdef DEBUG - theDebugger = this; -#endif } void @@ -326,14 +343,13 @@ bool RemoteGDB::acc(Addr va, size_t len) { Addr last_va; - Addr pte; - va = alpha_trunc_page(va); - last_va = alpha_round_page(va + len); + va = TheISA::TruncPage(va); + last_va = TheISA::RoundPage(va + len); do { - if (va >= ALPHA_K0SEG_BASE && va < ALPHA_K1SEG_BASE) { - if (va < (ALPHA_K0SEG_BASE + pmem->size())) { + if (TheISA::IsK0Seg(va)) { + if (va < (TheISA::K0SegBase + pmem->size())) { DPRINTF(GDBAcc, "acc: Mapping is valid K0SEG <= " "%#x < K0SEG + size\n", va); return true; @@ -344,16 +360,23 @@ RemoteGDB::acc(Addr va, size_t len) } } - if (PC_PAL(va) || va < 0x10000) + /** + * This code says that all accesses to palcode (instruction and data) + * are valid since there isn't a va->pa mapping because palcode is + * accessed physically. At some point this should probably be cleaned up + * but there is no easy way to do it. + */ + + if (AlphaISA::PcPAL(va) || va < 0x10000) return true; Addr ptbr = context->regs.ipr[AlphaISA::IPR_PALtemp20]; - pte = kernel_pte_lookup(pmem, ptbr, va); - if (!pte || !entry_valid(pmem->phys_read_qword(pte))) { + TheISA::PageTableEntry pte = kernel_pte_lookup(pmem, ptbr, va); + if (!pte.valid()) { DPRINTF(GDBAcc, "acc: %#x pte is invalid\n", va); return false; } - va += ALPHA_PGBYTES; + va += TheISA::PageBytes; } while (va < last_va); DPRINTF(GDBAcc, "acc: %#x mapping is valid\n", va); @@ -709,7 +732,6 @@ RemoteGDB::HardBreakpoint::HardBreakpoint(RemoteGDB *_gdb, Addr pc) gdb(_gdb), refcount(0) { DPRINTF(GDBMisc, "creating hardware breakpoint at %#x\n", evpc); - schedule(); } void @@ -830,7 +852,7 @@ RemoteGDB::trap(int type) active = true; else // Tell remote host that an exception has occurred. - sprintf((char *)buffer, "S%02x", signal(type)); + snprintf((char *)buffer, sizeof(buffer), "S%02x", signal(type)); send(buffer); // Stick frame regs into our reg cache. @@ -848,7 +870,7 @@ RemoteGDB::trap(int type) // if this command came from a running gdb, answer it -- // the other guy has no way of knowing if we're in or out // of this loop when he issues a "remote-signal". - sprintf((char *)buffer, "S%02x", signal(type)); + snprintf((char *)buffer, sizeof(buffer), "S%02x", signal(type)); send(buffer); continue;