From: Tim Newsome Date: Thu, 24 Mar 2016 00:42:17 +0000 (-0700) Subject: Only halt on ebreak if a debugger is attached. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=d6d23ae8479c246f801e88a9d8401a7f6b01b4e7;p=riscv-isa-sim.git Only halt on ebreak if a debugger is attached. --- diff --git a/riscv/gdbserver.h b/riscv/gdbserver.h index 0c92372..7e7ccbc 100644 --- a/riscv/gdbserver.h +++ b/riscv/gdbserver.h @@ -80,6 +80,8 @@ public: void handle_register_write(const std::vector &packet); void handle_step(const std::vector &packet); + bool connected() const { return client_fd > 0; } + private: sim_t *sim; int socket_fd; diff --git a/riscv/processor.cc b/riscv/processor.cc index 4537c18..b12efe8 100644 --- a/riscv/processor.cc +++ b/riscv/processor.cc @@ -209,8 +209,8 @@ void processor_t::take_trap(trap_t& t, reg_t epc) fprintf(stderr, "core %3d: exception %s, epc 0x%016" PRIx64 "\n", id, t.name(), epc); - if (t.cause() == CAUSE_BREAKPOINT) { - // TODO: Only do this if there is a debugger attached. + if (t.cause() == CAUSE_BREAKPOINT && + sim->gdbserver && sim->gdbserver->connected()) { set_halted(true, HR_SWBP); return; } diff --git a/tests/ebreak.py b/tests/ebreak.py index 6c3ffdb..4b41f7d 100755 --- a/tests/ebreak.py +++ b/tests/ebreak.py @@ -10,12 +10,17 @@ class EbreakTest(unittest.TestCase): def setUp(self): self.binary = testlib.compile("ebreak.s") - def test_ebreak(self): - """Make sure that we can run past ebreak without halting when a - debugger isn't attached.""" + def test_noport(self): + """Make sure that we can run past ebreak when --gdb-port isn't used.""" spike = testlib.spike(self.binary, with_gdb=False, timeout=10) result = spike.wait() self.assertEqual(result, 0) + def test_nogdb(self): + """Make sure that we can run past ebreak when gdb isn't attached.""" + spike, port = testlib.spike(self.binary, timeout=10) + result = spike.wait() + self.assertEqual(result, 0) + if __name__ == '__main__': unittest.main()