Segfault stabilisé, ajout de breakpoints
This commit is contained in:
parent
0f4754939f
commit
751f9ea3a6
86
ia86.cpp
86
ia86.cpp
|
@ -158,11 +158,26 @@ void InstructionWindow::clear()
|
||||||
listview.redraw();
|
listview.redraw();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
string InstructionWindow::getaddress()
|
||||||
|
{
|
||||||
|
return listview.getCurrentItem()->getText(0).c_str();
|
||||||
|
}
|
||||||
|
|
||||||
void InstructionWindow::setmark(int index)
|
void InstructionWindow::setmark(int index)
|
||||||
{
|
{
|
||||||
listview.setmark(index);
|
listview.setmark(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int InstructionWindow::getindex()
|
||||||
|
{
|
||||||
|
return listview.getindex();
|
||||||
|
}
|
||||||
|
|
||||||
|
void InstructionWindow::setmultimark(std::vector<int> mark)
|
||||||
|
{
|
||||||
|
listview.setmultimark(mark);
|
||||||
|
}
|
||||||
|
|
||||||
int InstructionWindow::getsize()
|
int InstructionWindow::getsize()
|
||||||
{
|
{
|
||||||
return listview.getCount();
|
return listview.getCount();
|
||||||
|
@ -643,6 +658,7 @@ void VMEngine::Halt()
|
||||||
|
|
||||||
void VMEngine::Unconfigure()
|
void VMEngine::Unconfigure()
|
||||||
{
|
{
|
||||||
|
this->clearbreakpoints();
|
||||||
this->Halt();
|
this->Halt();
|
||||||
if (initialized)
|
if (initialized)
|
||||||
widget->tolog("VM IA86 - déconfiguration.........................[ INFO ]");
|
widget->tolog("VM IA86 - déconfiguration.........................[ INFO ]");
|
||||||
|
@ -735,17 +751,17 @@ void VMEngine::clearbreakpoints()
|
||||||
breakpoints.clear();
|
breakpoints.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void VMEngine::addbreakpoint(int address)
|
void VMEngine::addbreakpoint(std::string address)
|
||||||
{
|
{
|
||||||
for(int item: breakpoints)
|
for(std::string item: breakpoints)
|
||||||
if (item==address) return;
|
if (item==address) return;
|
||||||
breakpoints.push_back(address);
|
breakpoints.push_back(address);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VMEngine::removebreakpoint(int address)
|
void VMEngine::removebreakpoint(std::string address)
|
||||||
{
|
{
|
||||||
int i=0;
|
int i=0;
|
||||||
for(int item: breakpoints)
|
for(std::string item: breakpoints)
|
||||||
if (item==address)
|
if (item==address)
|
||||||
{
|
{
|
||||||
breakpoints.erase(breakpoints.begin()+i);
|
breakpoints.erase(breakpoints.begin()+i);
|
||||||
|
@ -756,8 +772,21 @@ void VMEngine::removebreakpoint(int address)
|
||||||
std::vector<int> VMEngine::getBreapoints()
|
std::vector<int> VMEngine::getBreapoints()
|
||||||
{
|
{
|
||||||
std::vector<int> list;
|
std::vector<int> list;
|
||||||
for(int item: breakpoints)
|
std::vector<std::array<std::string, 4>> items=((Menu*)widget)->getsrc();
|
||||||
widget->tolog(to_string(item));
|
for(std::string bpaddress: breakpoints)
|
||||||
|
{
|
||||||
|
int line=0;
|
||||||
|
for(std::array<std::string, 4> item: items)
|
||||||
|
{
|
||||||
|
if (item[0]==bpaddress)
|
||||||
|
{
|
||||||
|
((Menu*)widget)->tolog(to_string(line));
|
||||||
|
list.push_back(line++);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1124,7 +1153,7 @@ void Menu::initWindows()
|
||||||
|
|
||||||
void Menu::AdjustWindows()
|
void Menu::AdjustWindows()
|
||||||
{
|
{
|
||||||
this->setGeometry ( FPoint { 63, 45 }, FSize{60, 11} );
|
//this->setGeometry ( FPoint { 63, 45 }, FSize{60, 11} );
|
||||||
edit.setGeometry ( FPoint { 01, 17 }, FSize{39, 27} );
|
edit.setGeometry ( FPoint { 01, 17 }, FSize{39, 27} );
|
||||||
view.setGeometry ( FPoint { 01, 45 }, FSize{60, 11} );
|
view.setGeometry ( FPoint { 01, 45 }, FSize{60, 11} );
|
||||||
regs.setGeometry ( FPoint { 01, 01 }, FSize{40, 15} );
|
regs.setGeometry ( FPoint { 01, 01 }, FSize{40, 15} );
|
||||||
|
@ -1136,7 +1165,7 @@ void Menu::AdjustWindows()
|
||||||
debug.setGeometry ( FPoint { 42, 17 }, FSize{60, 27} );
|
debug.setGeometry ( FPoint { 42, 17 }, FSize{60, 27} );
|
||||||
scenar.setGeometry ( FPoint { 187, 01 }, FSize{25, 55} );
|
scenar.setGeometry ( FPoint { 187, 01 }, FSize{25, 55} );
|
||||||
info.setGeometry (FPoint { 55, 25 }, FSize{50, 14});
|
info.setGeometry (FPoint { 55, 25 }, FSize{50, 14});
|
||||||
this->show();
|
//this->show();
|
||||||
info.hide();
|
info.hide();
|
||||||
flags.hide();
|
flags.hide();
|
||||||
stack.hide();
|
stack.hide();
|
||||||
|
@ -1159,11 +1188,11 @@ void Menu::AdjustWindows()
|
||||||
mem.show();
|
mem.show();
|
||||||
if (level.rights > 6)
|
if (level.rights > 6)
|
||||||
screen.show();
|
screen.show();
|
||||||
Options.setEnable();
|
/*Options.setEnable();
|
||||||
Tools.setEnable();
|
Tools.setEnable();
|
||||||
Window.setEnable();
|
Window.setEnable();
|
||||||
Debug.setEnable();
|
Debug.setEnable();
|
||||||
Breakpoint.setEnable();
|
Breakpoint.setEnable();*/
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1173,11 +1202,11 @@ void Menu::AdjustWindows()
|
||||||
tuto.hide();
|
tuto.hide();
|
||||||
debug.hide();
|
debug.hide();
|
||||||
scenar.hide();
|
scenar.hide();
|
||||||
Options.setDisable();
|
/*Options.setDisable();
|
||||||
Tools.setDisable();
|
Tools.setDisable();
|
||||||
Window.setDisable();
|
Window.setDisable();
|
||||||
Debug.setDisable();
|
Debug.setDisable();
|
||||||
Breakpoint.setDisable();
|
Breakpoint.setDisable();*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1281,11 +1310,11 @@ void Menu::initMenusCallBack()
|
||||||
this,
|
this,
|
||||||
&Menu::end
|
&Menu::end
|
||||||
);
|
);
|
||||||
About.addCallback
|
AddBp.addCallback
|
||||||
(
|
(
|
||||||
"clicked",
|
"clicked",
|
||||||
this,
|
this,
|
||||||
&Menu::about
|
&Menu::addbreakpoint
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1308,16 +1337,15 @@ Episode 1 : Apprendre l'assembleur X86");
|
||||||
|
|
||||||
void Menu::initLayout()
|
void Menu::initLayout()
|
||||||
{
|
{
|
||||||
Log.setGeometry (FPoint{1, 2}, FSize{getWidth(), getHeight() - 1});
|
this->setGeometry ( FPoint { 63, 45 }, FSize{60, 11}, false);
|
||||||
|
this->setTopPadding(1);
|
||||||
|
this->setLeftPadding(0);
|
||||||
|
this->setRightPadding(0);
|
||||||
|
this->setBottomPadding(0);
|
||||||
|
Log.setGeometry (FPoint{0, 0}, FSize{getWidth(), getHeight()},false);
|
||||||
FDialog::initLayout();
|
FDialog::initLayout();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Menu::adjustSize()
|
|
||||||
{
|
|
||||||
finalcut::FDialog::adjustSize();
|
|
||||||
Log.setGeometry (FPoint{1, 2}, FSize(getWidth(), getHeight() - 1));
|
|
||||||
}
|
|
||||||
|
|
||||||
void Menu::onClose (finalcut::FCloseEvent* ev)
|
void Menu::onClose (finalcut::FCloseEvent* ev)
|
||||||
{
|
{
|
||||||
finalcut::FApplication::closeConfirmationDialog (this, ev);
|
finalcut::FApplication::closeConfirmationDialog (this, ev);
|
||||||
|
@ -1386,6 +1414,7 @@ void Menu::compile()
|
||||||
void Menu::tolog(std::string str)
|
void Menu::tolog(std::string str)
|
||||||
{
|
{
|
||||||
this->Log.append(str);
|
this->Log.append(str);
|
||||||
|
this->Log.scrollBy (0, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Menu::about()
|
void Menu::about()
|
||||||
|
@ -1408,6 +1437,11 @@ void Menu::about()
|
||||||
AdjustWindows();
|
AdjustWindows();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<std::array<std::string, 4>> Menu::getsrc()
|
||||||
|
{
|
||||||
|
return debug.get();
|
||||||
|
}
|
||||||
|
|
||||||
void Menu::showInstr()
|
void Menu::showInstr()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
@ -1416,6 +1450,7 @@ void Menu::showInstr()
|
||||||
{
|
{
|
||||||
debug.set(vm.getInstr(vm.getCS(),vm.getEIP(),debug.getHeight()-3));
|
debug.set(vm.getInstr(vm.getCS(),vm.getEIP(),debug.getHeight()-3));
|
||||||
debug.setmark(vm.getLine());
|
debug.setmark(vm.getLine());
|
||||||
|
debug.setmultimark(vm.getBreapoints());
|
||||||
mem.set(vm.getRam(vm.getDS(), 0x0000, mem.getHeight(),mem.getWidth()));
|
mem.set(vm.getRam(vm.getDS(), 0x0000, mem.getHeight(),mem.getWidth()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1487,6 +1522,12 @@ void Menu::step()
|
||||||
showInstr();
|
showInstr();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Menu::addbreakpoint()
|
||||||
|
{
|
||||||
|
vm.addbreakpoint(debug.getaddress());
|
||||||
|
showInstr();
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
// Fonction Main
|
// Fonction Main
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
|
@ -1495,9 +1536,6 @@ int main (int argc, char* argv[])
|
||||||
mapping();
|
mapping();
|
||||||
finalcut::FApplication app {argc, argv};
|
finalcut::FApplication app {argc, argv};
|
||||||
Menu main_dlg {&app};
|
Menu main_dlg {&app};
|
||||||
/*main_dlg.setText ("Journaux");
|
|
||||||
main_dlg.setGeometry ( FPoint { 63, 45 }, FSize{60, 11} );
|
|
||||||
main_dlg.show();*/
|
|
||||||
finalcut::FWidget::setMainWidget (&main_dlg);
|
finalcut::FWidget::setMainWidget (&main_dlg);
|
||||||
return app.exec();
|
return app.exec();
|
||||||
}
|
}
|
||||||
|
|
22
ia86.h
22
ia86.h
|
@ -201,8 +201,11 @@ class InstructionWindow final : public finalcut::FDialog
|
||||||
std::vector<std::array<std::string, 4>> get();
|
std::vector<std::array<std::string, 4>> get();
|
||||||
void set(std::vector<std::array<std::string, 4>> src);
|
void set(std::vector<std::array<std::string, 4>> src);
|
||||||
void clear();
|
void clear();
|
||||||
|
int getindex();
|
||||||
|
void setmultimark(std::vector<int> mark);
|
||||||
void setmark(int index);
|
void setmark(int index);
|
||||||
int getsize();
|
int getsize();
|
||||||
|
string getaddress();
|
||||||
private:
|
private:
|
||||||
// Method
|
// Method
|
||||||
std::vector<std::array<std::string, 4>> content;
|
std::vector<std::array<std::string, 4>> content;
|
||||||
|
@ -315,8 +318,8 @@ class VMEngine
|
||||||
bool isInitialized();
|
bool isInitialized();
|
||||||
void setRights(int rights);
|
void setRights(int rights);
|
||||||
void clearbreakpoints();
|
void clearbreakpoints();
|
||||||
void addbreakpoint(int address);
|
void addbreakpoint(std::string address);
|
||||||
void removebreakpoint(int address);
|
void removebreakpoint(std::string address);
|
||||||
std::vector<int> getBreapoints();
|
std::vector<int> getBreapoints();
|
||||||
int getLine();
|
int getLine();
|
||||||
uint32_t getEIP();
|
uint32_t getEIP();
|
||||||
|
@ -325,7 +328,7 @@ class VMEngine
|
||||||
uint16_t getES();
|
uint16_t getES();
|
||||||
uint16_t getSS();
|
uint16_t getSS();
|
||||||
private:
|
private:
|
||||||
std::vector<int> breakpoints;
|
std::vector<std::string> breakpoints;
|
||||||
int rights;
|
int rights;
|
||||||
void Init();
|
void Init();
|
||||||
void Close();
|
void Close();
|
||||||
|
@ -356,6 +359,7 @@ class Menu final : public finalcut::FDialog
|
||||||
void loadLevel(int alevel);
|
void loadLevel(int alevel);
|
||||||
void closeLevel();
|
void closeLevel();
|
||||||
void tolog(std::string str);
|
void tolog(std::string str);
|
||||||
|
std::vector<std::array<std::string, 4>> getsrc();
|
||||||
void SetScreen(uint16_t x, uint16_t y, char value);
|
void SetScreen(uint16_t x, uint16_t y, char value);
|
||||||
private:
|
private:
|
||||||
void onTimer (finalcut::FTimerEvent*) override;
|
void onTimer (finalcut::FTimerEvent*) override;
|
||||||
|
@ -368,6 +372,7 @@ class Menu final : public finalcut::FDialog
|
||||||
void end();
|
void end();
|
||||||
void loadScenario(std::string file);
|
void loadScenario(std::string file);
|
||||||
void showInstr();
|
void showInstr();
|
||||||
|
void addbreakpoint();
|
||||||
void exec();
|
void exec();
|
||||||
void trace();
|
void trace();
|
||||||
void step();
|
void step();
|
||||||
|
@ -376,13 +381,12 @@ class Menu final : public finalcut::FDialog
|
||||||
void AdjustWindows();
|
void AdjustWindows();
|
||||||
void initWindows();
|
void initWindows();
|
||||||
void initLayout() override;
|
void initLayout() override;
|
||||||
void adjustSize() override;
|
|
||||||
// Event handler
|
// Event handler
|
||||||
void onClose (finalcut::FCloseEvent*) override;
|
void onClose (finalcut::FCloseEvent*) override;
|
||||||
// Callback method
|
// Callback method
|
||||||
void cb_message (const finalcut::FMenuItem*);
|
void cb_message (const finalcut::FMenuItem*);
|
||||||
// Data members
|
// Data members
|
||||||
finalcut::FString line{13, finalcut::UniChar::BoxDrawingsHorizontal};
|
//finalcut::FString line{13, finalcut::UniChar::BoxDrawingsHorizontal};
|
||||||
finalcut::FMenuBar Menubar{this};
|
finalcut::FMenuBar Menubar{this};
|
||||||
finalcut::FMenu Game{"&Partie", &Menubar};
|
finalcut::FMenu Game{"&Partie", &Menubar};
|
||||||
finalcut::FMenuItem New{"&Nouvelle partie", &Game};
|
finalcut::FMenuItem New{"&Nouvelle partie", &Game};
|
||||||
|
@ -394,8 +398,13 @@ class Menu final : public finalcut::FDialog
|
||||||
finalcut::FRadioMenuItem Es_edi{"ES:EDI", &Memory};
|
finalcut::FRadioMenuItem Es_edi{"ES:EDI", &Memory};
|
||||||
finalcut::FRadioMenuItem Cs_eip{"CS:EIP", &Memory};
|
finalcut::FRadioMenuItem Cs_eip{"CS:EIP", &Memory};
|
||||||
finalcut::FRadioMenuItem Ss_sp{"SS:SP", &Memory};
|
finalcut::FRadioMenuItem Ss_sp{"SS:SP", &Memory};
|
||||||
|
finalcut::FRadioMenuItem Value{"Valeur...", &Memory};
|
||||||
|
finalcut::FMenu Code{"&Code", &Options};
|
||||||
|
finalcut::FRadioMenuItem Cs_eip2{"CS:EIP", &Code};
|
||||||
|
finalcut::FRadioMenuItem Value2{"Valeur...", &Code};
|
||||||
|
finalcut::FRadioMenuItem Att{"Syntaxe AT&T", &Code};
|
||||||
finalcut::FMenu Tools{"&Outils", &Menubar};
|
finalcut::FMenu Tools{"&Outils", &Menubar};
|
||||||
finalcut::FMenuItem Assemble{"&Compilation", &Tools};
|
finalcut::FMenuItem Assemble{"&Assembler", &Tools};
|
||||||
finalcut::FMenuItem Rearange{"&Ordonne les fenêtres", &Tools};
|
finalcut::FMenuItem Rearange{"&Ordonne les fenêtres", &Tools};
|
||||||
finalcut::FMenu Debug{"&Déboguage", &Menubar};
|
finalcut::FMenu Debug{"&Déboguage", &Menubar};
|
||||||
finalcut::FMenuItem Run{"&Exécuter", &Debug};
|
finalcut::FMenuItem Run{"&Exécuter", &Debug};
|
||||||
|
@ -404,7 +413,6 @@ class Menu final : public finalcut::FDialog
|
||||||
finalcut::FMenuItem StepOver{"&Pas à pas", &Debug};
|
finalcut::FMenuItem StepOver{"&Pas à pas", &Debug};
|
||||||
finalcut::FMenu Breakpoint{"&Point d'arrêt", &Menubar};
|
finalcut::FMenu Breakpoint{"&Point d'arrêt", &Menubar};
|
||||||
finalcut::FMenuItem AddBp{"&Ajouter", &Breakpoint};
|
finalcut::FMenuItem AddBp{"&Ajouter", &Breakpoint};
|
||||||
finalcut::FMenuItem DelBp{"&Supprimer", &Breakpoint};
|
|
||||||
finalcut::FMenuItem ClearBp{"&Tout supprimer", &Breakpoint};
|
finalcut::FMenuItem ClearBp{"&Tout supprimer", &Breakpoint};
|
||||||
finalcut::FDialogListMenu Window{"&Fenêtres", &Menubar};
|
finalcut::FDialogListMenu Window{"&Fenêtres", &Menubar};
|
||||||
finalcut::FMenu Help{"&Aide", &Menubar};
|
finalcut::FMenu Help{"&Aide", &Menubar};
|
||||||
|
|
Loading…
Reference in New Issue