X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fsim%2Fdebug.cc;h=bf46a51b26a270e4c6fa5dcb20584ec255fc4b6c;hb=ca867678a6d63f454fcf5d4c751b44a0224b3c76;hp=b82219f7d76a6932bee22ef9402cfd1fb8e63f72;hpb=cb0cf2dd8ab1cd60ef13de925ac862268c07297f;p=gem5.git diff --git a/src/sim/debug.cc b/src/sim/debug.cc index b82219f7d..bf46a51b2 100644 --- a/src/sim/debug.cc +++ b/src/sim/debug.cc @@ -24,57 +24,40 @@ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * Authors: Nathan Binkert - * Steve Reinhardt */ -#include -#include -#include +#include "sim/debug.hh" #include #include -#include "sim/debug.hh" -#include "sim/eventq.hh" -#include "sim/param.hh" +#include "base/debug.hh" +#include "cpu/pc_event.hh" +#include "sim/eventq_impl.hh" +#include "sim/global_event.hh" #include "sim/sim_events.hh" +#include "sim/sim_exit.hh" +#include "sim/system.hh" using namespace std; -void -debug_break() -{ -#ifndef NDEBUG - kill(getpid(), SIGTRAP); -#else - cprintf("debug_break suppressed, compiled with NDEBUG\n"); -#endif -} - // // Debug event: place a breakpoint on the process function and // schedule the event to break at a particular cycle // -class DebugBreakEvent : public Event +struct DebugBreakEvent : public GlobalEvent { - public: - - DebugBreakEvent(EventQueue *q, Tick _when); - - void process(); // process event - virtual const char *description(); + DebugBreakEvent(Tick when); + void process(); // process event + virtual const char *description() const; }; // // constructor: schedule at specified time // -DebugBreakEvent::DebugBreakEvent(EventQueue *q, Tick _when) - : Event(q, Debug_Break_Pri) +DebugBreakEvent::DebugBreakEvent(Tick when) + : GlobalEvent(when, Debug_Break_Pri, AutoDelete) { - setFlags(AutoDelete); - schedule(_when); } // @@ -83,57 +66,65 @@ DebugBreakEvent::DebugBreakEvent(EventQueue *q, Tick _when) void DebugBreakEvent::process() { - debug_break(); + Debug::breakpoint(); } const char * -DebugBreakEvent::description() +DebugBreakEvent::description() const { - return "debug break"; + return "debug breakpoint"; } // -// Parameter context for global debug options +// handy function to schedule DebugBreakEvent on main event queue +// (callable from debugger) // -class DebugContext : public ParamContext +void +schedBreak(Tick when) { - public: - DebugContext(const string &_iniSection) - : ParamContext(_iniSection) {} - void checkParams(); -}; - -DebugContext debugParams("debug"); - -VectorParam break_cycles(&debugParams, "break_cycles", - "cycle(s) to create breakpoint events"); + new DebugBreakEvent(when); + warn("need to stop all queues"); +} void -DebugContext::checkParams() +schedRelBreak(Tick delta) { - if (break_cycles.isValid()) { - vector &cycles = break_cycles; + schedBreak(curTick() + delta); +} - vector::iterator i = cycles.begin(); - vector::iterator end = cycles.end(); +/// +/// Function to cause the simulator to take a checkpoint from the debugger +/// +void +takeCheckpoint(Tick when) +{ + if (!when) + when = curTick() + 1; + exitSimLoop("checkpoint", 0, when, 0); +} - for (; i < end; ++i) - new DebugBreakEvent(&mainEventQueue, *i); +void +eventqDump() +{ + for (uint32_t i = 0; i < numMainEventQueues; ++i) { + mainEventQueue[i]->dump(); } } -// -// handy function to schedule DebugBreakEvent on main event queue -// (callable from debugger) -// -extern "C" void sched_break_cycle(Tick when) +int remote_gdb_base_port = 7000; + +int +getRemoteGDBPort() { - new DebugBreakEvent(&mainEventQueue, when); + return remote_gdb_base_port; } -extern "C" void eventq_dump() +// Set remote GDB base port. 0 means disable remote GDB. +// Callable from python. +void +setRemoteGDBPort(int port) { - mainEventQueue.dump(); + remote_gdb_base_port = port; }