Add d flag for debugging mode

This commit is contained in:
rkx1209 2018-04-21 16:02:41 +09:00
parent 51f61166ce
commit 8925f1d464
6 changed files with 27 additions and 8 deletions

View file

@ -970,7 +970,7 @@ static bool DisasLdstCompute64bit(unsigned int size, bool is_signed, unsigned in
/* Load/Store exclusive ... literal means PC-relative immediate value */
static void DisasLdstExcl(uint32_t insn, DisasCallback *cb) {
unsigned int rt = extract32(insn, 0, 5);
unsigned int rn = extract32(insn, 5, 5);
unsigned int rn = ARMv8::HandleAsSP(extract32(insn, 5, 5));
unsigned int rt2 = extract32(insn, 10, 5);
unsigned int is_lasr = extract32(insn, 15, 1);
unsigned int rs = extract32(insn, 16, 5);
@ -1003,6 +1003,8 @@ static void DisasLdstExcl(uint32_t insn, DisasCallback *cb) {
} else {
cb->StoreRegI64(rt, rn, size, false, false);
}
/* Set status code (success = 0) */
cb->MoviI64(rs, 0, true);
}
} else {
bool sf = DisasLdstCompute64bit(size, false, 0);

View file

@ -39,9 +39,10 @@ void Interpreter::Run() {
if (counter >= estimate){
Cpu::DumpMachine ();
}
if (counter >= estimate + mx)
if (counter >= estimate + mx) {
break;
SingleStep ();
}
SingleStep ();
counter++;
}
}

View file

@ -29,7 +29,9 @@ State GetState() {
}
void DumpMachine() {
//ARMv8::Dump ();
if (is_debug()) {
ARMv8::Dump ();
}
if (TraceOut)
ARMv8::DumpJson (TraceOut);
}

View file

@ -77,7 +77,7 @@ void Banner() {
}
enum optionIndex {
UNKNOWN, HELP, ENABLE_TRACE, ENABLE_GDB,
UNKNOWN, HELP, ENABLE_TRACE, ENABLE_GDB, ENABLE_DEBUG,
};
const option::Descriptor usage[] =
{
@ -86,6 +86,7 @@ const option::Descriptor usage[] =
{ HELP, 0, "", "help", Arg::None, " --help \tPrint help message" },
{ ENABLE_TRACE, 0, "t","enable-trace", Arg::None, " --enable-trace, -t \tEnable Trace" },
{ ENABLE_GDB, 0, "s","enable-gdb", Arg::None, " --enable-gdb -s \tEnable GDBServer" },
{ ENABLE_DEBUG, 0, "d","enable-debug", Arg::None, " --enable-debug -d \tEnable debug mode" },
{ 0, 0, nullptr, nullptr, nullptr, nullptr }
};
@ -121,7 +122,11 @@ printUsage:
}
if (options[ENABLE_GDB].count () > 0) {
GdbStub::Init();
}
}
if (options[ENABLE_DEBUG].count () > 0) {
enable_debug();
}
#if 0
if (options[NSO].count () > 0) {
if (options[NSO].count () != 1) {

View file

@ -1 +1,3 @@
/* nsemu - LGPL - Copyright 2017 rkx1209<rkx1209dev@gmail.com> */
#include "Nsemu.hpp"
RunLevel curlevel;

View file

@ -14,8 +14,15 @@ enum RunLevel {
RUN_LEVEL_DEBUG,
};
//static RunLevel curlevel = RUN_LEVEL_DEBUG;
static RunLevel curlevel = RUN_LEVEL_RELEASE;
extern RunLevel curlevel;
inline void enable_debug() {
curlevel = RUN_LEVEL_DEBUG;
}
inline bool is_debug() {
return curlevel == RUN_LEVEL_DEBUG;
}
static void util_print(RunLevel level, FILE *fp, const char *format, ...) {
if (curlevel >= level) {