Mode déboguage depuis des arguments de la ligne de commande
This commit is contained in:
parent
9cb767d1ec
commit
0b3d5eef47
11
Makefile
11
Makefile
|
@ -4,7 +4,7 @@ OPTIONS=-std=c++17
|
||||||
DOCKER=docker run --name maker --rm -v $$(pwd):/data maker
|
DOCKER=docker run --name maker --rm -v $$(pwd):/data maker
|
||||||
START=./start.sh
|
START=./start.sh
|
||||||
|
|
||||||
all: dockerfile files run
|
all: dockerfile run
|
||||||
|
|
||||||
clean: dockerclean
|
clean: dockerclean
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ dockerfile:
|
||||||
|
|
||||||
dockerfile_force: dockerclean dockerfile
|
dockerfile_force: dockerclean dockerfile
|
||||||
|
|
||||||
files: ./ia86
|
compile: ./ia86
|
||||||
|
|
||||||
ia86: ./ia86.cpp
|
ia86: ./ia86.cpp
|
||||||
$(DOCKER) $(CC) $(OPTIONS) -o $@ $^ $(LFLAGS)
|
$(DOCKER) $(CC) $(OPTIONS) -o $@ $^ $(LFLAGS)
|
||||||
|
@ -29,7 +29,12 @@ ia86: ./ia86.cpp
|
||||||
rerun:
|
rerun:
|
||||||
$(START)
|
$(START)
|
||||||
|
|
||||||
run: clear delete files rerun
|
redebug:
|
||||||
|
$(START) debug
|
||||||
|
|
||||||
|
run: clear delete compile rerun
|
||||||
|
|
||||||
|
debug: clear delete compile redebug
|
||||||
|
|
||||||
stop:
|
stop:
|
||||||
docker stop maker
|
docker stop maker
|
||||||
|
|
60
ia86.cpp
60
ia86.cpp
|
@ -67,7 +67,7 @@ Scenario scenario;
|
||||||
Level level;
|
Level level;
|
||||||
Unasm unasm;
|
Unasm unasm;
|
||||||
int marker;
|
int marker;
|
||||||
bool debug=true;
|
bool debugnow;
|
||||||
uc_hook uh_mem;
|
uc_hook uh_mem;
|
||||||
uc_hook uh_code;
|
uc_hook uh_code;
|
||||||
uc_hook uh_call;
|
uc_hook uh_call;
|
||||||
|
@ -323,7 +323,8 @@ Desassembler::Desassembler(Menu *widget) : widget(widget)
|
||||||
err = cs_open(CS_ARCH_X86, CS_MODE_16, &handle);
|
err = cs_open(CS_ARCH_X86, CS_MODE_16, &handle);
|
||||||
if (err != CS_ERR_OK)
|
if (err != CS_ERR_OK)
|
||||||
throw Error("Désassembleur - initialisation....................[ERREUR]");
|
throw Error("Désassembleur - initialisation....................[ERREUR]");
|
||||||
widget->tolog("Désassembleur - initialisation....................[ OK ]");
|
if (debugnow)
|
||||||
|
widget->tolog("Désassembleur - initialisation....................[ OK ]");
|
||||||
}
|
}
|
||||||
catch(exception const& e)
|
catch(exception const& e)
|
||||||
{
|
{
|
||||||
|
@ -346,7 +347,7 @@ void Desassembler::Desassemble(uint8_t *content, uint32_t address,uint32_t size,
|
||||||
throw Error("Désassembleur - désassemblage.....................[ERREUR]");
|
throw Error("Désassembleur - désassemblage.....................[ERREUR]");
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (debug) widget->tolog("Désassemblage - désassemblage.....................[ "+to_string(srcsize)+"l ]");
|
if (debugnow) widget->tolog("Désassemblage - désassemblage.....................[ "+to_string(srcsize)+"l ]");
|
||||||
unasm->src.clear();
|
unasm->src.clear();
|
||||||
unasm->pos.clear();
|
unasm->pos.clear();
|
||||||
for (size_t j = 0; j < srcsize; j++)
|
for (size_t j = 0; j < srcsize; j++)
|
||||||
|
@ -384,7 +385,8 @@ Assembler::Assembler(Menu *widget) : widget(widget)
|
||||||
err = ks_open(KS_ARCH_X86, KS_MODE_16, &ks);
|
err = ks_open(KS_ARCH_X86, KS_MODE_16, &ks);
|
||||||
if (err != KS_ERR_OK)
|
if (err != KS_ERR_OK)
|
||||||
throw Error("Assembleur - initialisation.......................[ERREUR]");
|
throw Error("Assembleur - initialisation.......................[ERREUR]");
|
||||||
widget->tolog("Assembleur - initialisation.......................[ OK ]");
|
if (debugnow)
|
||||||
|
widget->tolog("Assembleur - initialisation.......................[ OK ]");
|
||||||
}
|
}
|
||||||
catch(exception const& e)
|
catch(exception const& e)
|
||||||
{
|
{
|
||||||
|
@ -675,7 +677,8 @@ void VMEngine::Init()
|
||||||
err = uc_open(UC_ARCH_X86, UC_MODE_16, &uc);
|
err = uc_open(UC_ARCH_X86, UC_MODE_16, &uc);
|
||||||
if (err != UC_ERR_OK)
|
if (err != UC_ERR_OK)
|
||||||
throw Error("VM IA86 - initilisation...........................[ERREUR]");
|
throw Error("VM IA86 - initilisation...........................[ERREUR]");
|
||||||
widget->tolog("VM IA86 - initilisation...........................[ OK ]");
|
if (debugnow)
|
||||||
|
widget->tolog("VM IA86 - initilisation...........................[ OK ]");
|
||||||
}
|
}
|
||||||
catch(exception const& e)
|
catch(exception const& e)
|
||||||
{
|
{
|
||||||
|
@ -959,7 +962,7 @@ void VMEngine::Configure(State *init, std::string code)
|
||||||
SetMem(&mcode[i]);
|
SetMem(&mcode[i]);
|
||||||
else
|
else
|
||||||
throw Error("VM IA86 - code non assemblé...................[ERREUR]");
|
throw Error("VM IA86 - code non assemblé...................[ERREUR]");
|
||||||
if (debug) widget->tolog("Section N°"+std::to_string(i)+" : "+intToHexString(mcode[i].address,8)+" -> "+to_string(mcode[i].size)+" octets");
|
if (debugnow) widget->tolog("Section N°"+std::to_string(i)+" : "+intToHexString(mcode[i].address,8)+" -> "+to_string(mcode[i].size)+" octets");
|
||||||
}
|
}
|
||||||
status=verify();
|
status=verify();
|
||||||
if (status==0)
|
if (status==0)
|
||||||
|
@ -1184,7 +1187,8 @@ void VMEngine::SetRegs(State *init)
|
||||||
out << " AX=" << std::uppercase << std::setfill('0') << std::setw(4) << std::hex << init->dump.regs.ax << " ";
|
out << " AX=" << std::uppercase << std::setfill('0') << std::setw(4) << std::hex << init->dump.regs.ax << " ";
|
||||||
else
|
else
|
||||||
out << "EAX=" << std::uppercase << std::setfill('0') << std::setw(8) << std::hex << init->dump.regs.eax << " ";
|
out << "EAX=" << std::uppercase << std::setfill('0') << std::setw(8) << std::hex << init->dump.regs.eax << " ";
|
||||||
widget->tolog(out.str());
|
if (debugnow)
|
||||||
|
widget->tolog(out.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void VMEngine::Run(bool astep, bool acall, uint64_t timeout)
|
void VMEngine::Run(bool astep, bool acall, uint64_t timeout)
|
||||||
|
@ -1233,6 +1237,8 @@ Menu::Menu (finalcut::FWidget* parent)
|
||||||
initMenusCallBack();
|
initMenusCallBack();
|
||||||
loadScenario("./scenarios.json");
|
loadScenario("./scenarios.json");
|
||||||
addTimer(50);
|
addTimer(50);
|
||||||
|
if (debugnow)
|
||||||
|
tolog("DEBOGUAGE ACTIVE !");
|
||||||
}
|
}
|
||||||
|
|
||||||
void Menu::initWindows()
|
void Menu::initWindows()
|
||||||
|
@ -1557,7 +1563,8 @@ void Menu::loadScenario(std::string file)
|
||||||
{
|
{
|
||||||
scenar.Load(scenario.levels);
|
scenar.Load(scenario.levels);
|
||||||
scenario.loaded=true;
|
scenario.loaded=true;
|
||||||
tolog("Application - charge scénarios....................[ OK ]");
|
if (debugnow)
|
||||||
|
tolog("Application - charge scénarios....................[ OK ]");
|
||||||
tolog("-={ "+ scenario.title+" }=-");
|
tolog("-={ "+ scenario.title+" }=-");
|
||||||
loadLevel(0);
|
loadLevel(0);
|
||||||
}
|
}
|
||||||
|
@ -1571,19 +1578,23 @@ void Menu::loadScenario(std::string file)
|
||||||
|
|
||||||
void Menu::loadLevel(int alevel)
|
void Menu::loadLevel(int alevel)
|
||||||
{
|
{
|
||||||
vm.Unconfigure();
|
if (scenario.levels[alevel].title!=level.title)
|
||||||
level=scenario.levels[alevel];
|
{
|
||||||
tolog("Application - charge niveau.......................[ INFO ]");
|
vm.Unconfigure();
|
||||||
view.setText("Objectif: "+level.title);
|
level=scenario.levels[alevel];
|
||||||
view.clear();
|
if (debugnow)
|
||||||
view.append(level.description);
|
tolog("Application - charge niveau.......................[ INFO ]");
|
||||||
tuto.clear();
|
view.setText("Objectif: "+level.title);
|
||||||
tuto.append(level.tutorial);
|
view.clear();
|
||||||
edit.set(level.code);
|
view.append(level.description);
|
||||||
debug.clear();
|
tuto.clear();
|
||||||
vm.setRights(level.rights);
|
tuto.append(level.tutorial);
|
||||||
AdjustWindows();
|
edit.set(level.code);
|
||||||
showInstr();
|
debug.clear();
|
||||||
|
vm.setRights(level.rights);
|
||||||
|
AdjustWindows();
|
||||||
|
showInstr();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Menu::end()
|
void Menu::end()
|
||||||
|
@ -1738,7 +1749,8 @@ void Menu::addbp()
|
||||||
if (vm.isInitialized())
|
if (vm.isInitialized())
|
||||||
{
|
{
|
||||||
std::string address=debug.getaddress();
|
std::string address=debug.getaddress();
|
||||||
tolog("VM IA86 - ajout breakpoint.....................["+address+"]");
|
if (debugnow)
|
||||||
|
tolog("VM IA86 - ajout breakpoint.....................["+address+"]");
|
||||||
vm.addbreakpoint(vm.getCS(),stoi(address,nullptr,16));
|
vm.addbreakpoint(vm.getCS(),stoi(address,nullptr,16));
|
||||||
showInstr();
|
showInstr();
|
||||||
}
|
}
|
||||||
|
@ -1750,6 +1762,10 @@ void Menu::addbp()
|
||||||
int main (int argc, char* argv[])
|
int main (int argc, char* argv[])
|
||||||
{
|
{
|
||||||
mapping();
|
mapping();
|
||||||
|
std::vector<std::string> args(argv, argv+argc);
|
||||||
|
for (size_t i = 1; i < args.size(); ++i) {
|
||||||
|
debugnow=(args[i] == "debug");
|
||||||
|
}
|
||||||
finalcut::FApplication app {argc, argv};
|
finalcut::FApplication app {argc, argv};
|
||||||
Menu main_dlg {&app};
|
Menu main_dlg {&app};
|
||||||
finalcut::FWidget::setMainWidget (&main_dlg);
|
finalcut::FWidget::setMainWidget (&main_dlg);
|
||||||
|
|
4
start.sh
4
start.sh
|
@ -5,7 +5,7 @@ KITTY=$(kitty -v|grep created)
|
||||||
if [ "${KITTY}" != "" ]; then
|
if [ "${KITTY}" != "" ]; then
|
||||||
echo "Kitty installé"
|
echo "Kitty installé"
|
||||||
if [ ${X} -ge 1920 ]; then
|
if [ ${X} -ge 1920 ]; then
|
||||||
kitty --start-as fullscreen ./ia86
|
kitty --start-as fullscreen ./ia86 $1
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
@ -22,4 +22,4 @@ elif [ ${X} -ge 1280 ]; then
|
||||||
else
|
else
|
||||||
SIZE=6
|
SIZE=6
|
||||||
fi
|
fi
|
||||||
xterm -fullscreen -fa monaco -fs ${SIZE} -bg black -fg green -e ./ia86
|
xterm -fullscreen -fa monaco -fs ${SIZE} -bg black -fg green -e "sleep 0.4;./ia86 $1"
|
||||||
|
|
Loading…
Reference in New Issue