Skip to content

Commit

Permalink
Add -H to start halted.
Browse files Browse the repository at this point in the history
  • Loading branch information
timsifive committed May 23, 2016
1 parent 38b8c09 commit bd17c7e
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
1 change: 1 addition & 0 deletions riscv/gdbserver.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "disasm.h"
#include "sim.h"
#include "gdbserver.h"
#include "mmu.h"

template <typename T>
unsigned int circular_buffer_t<T>::size() const
Expand Down
6 changes: 4 additions & 2 deletions riscv/sim.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ static void handle_signal(int sig)
signal(sig, &handle_signal);
}

sim_t::sim_t(const char* isa, size_t nprocs, size_t mem_mb,
sim_t::sim_t(const char* isa, size_t nprocs, size_t mem_mb, bool halted,
const std::vector<std::string>& args)
: htif(new htif_isasim_t(this, args)), procs(std::max(nprocs, size_t(1))),
current_step(0), current_proc(0), debug(false)
Expand All @@ -43,8 +43,10 @@ sim_t::sim_t(const char* isa, size_t nprocs, size_t mem_mb,

debug_mmu = new mmu_t(this, NULL);

for (size_t i = 0; i < procs.size(); i++)
for (size_t i = 0; i < procs.size(); i++) {
procs[i] = new processor_t(isa, this, i);
procs[i]->set_halted(halted);
}

rtc.reset(new rtc_t(procs));
make_config_string();
Expand Down
2 changes: 1 addition & 1 deletion riscv/sim.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class mmu_t;
class sim_t
{
public:
sim_t(const char* isa, size_t _nprocs, size_t mem_mb,
sim_t(const char* isa, size_t _nprocs, size_t mem_mb, bool halted,
const std::vector<std::string>& htif_args);
~sim_t();

Expand Down
7 changes: 5 additions & 2 deletions spike_main/spike.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#include <fesvr/option_parser.h>
#include <stdio.h>
#include <stdlib.h>
#include <getopt.h>
#include <vector>
#include <string>
#include <memory>
Expand All @@ -25,6 +24,7 @@ static void help()
fprintf(stderr, " -g Track histogram of PCs\n");
fprintf(stderr, " -l Generate a log of execution\n");
fprintf(stderr, " -h Print this help message\n");
fprintf(stderr, " -H Start halted, allowing a debugger to connect\n");
fprintf(stderr, " --isa=<name> RISC-V ISA string [default %s]\n", DEFAULT_ISA);
fprintf(stderr, " --ic=<S>:<W>:<B> Instantiate a cache model with S sets,\n");
fprintf(stderr, " --dc=<S>:<W>:<B> W ways, and B-byte blocks (with S and\n");
Expand All @@ -38,6 +38,7 @@ static void help()
int main(int argc, char** argv)
{
bool debug = false;
bool halted = false;
bool histogram = false;
bool log = false;
bool dump_config_string = false;
Expand Down Expand Up @@ -70,10 +71,12 @@ int main(int argc, char** argv)
exit(-1);
}
});
// I wanted to use --halted, but for some reason that doesn't work.
parser.option('H', 0, 0, [&](const char* s){halted = true;});

auto argv1 = parser.parse(argv);
std::vector<std::string> htif_args(argv1, (const char*const*)argv + argc);
sim_t s(isa, nprocs, mem_mb, htif_args);
sim_t s(isa, nprocs, mem_mb, halted, htif_args);
gdbserver_t gdbserver(9824, &s);
s.set_gdbserver(&gdbserver);

Expand Down

0 comments on commit bd17c7e

Please sign in to comment.