History

Basic debugger implementation - No way to enable it without altering exec main.cpp.

arr committed 10 years ago

Commit f2c6ef31 parent 7c21b7718 files · +776 −72Browse files

Showing the changes to src/exec/main.cpp (1 of 18 files). Show all

Unified · Split

src/exec/main.cpp+34−12
@@ -4,12 +4,14 @@ · 3 unmodified lines
44 // Author: arr
55 //
66
7−#include <cstdio>
7+#include <iostream>
88 #include <cassert>
99 #include <array>
10−#include <disvm.h>
10+#include <memory>
1111 #include <builtin_module.h>
1212 #include <debug.h>
13+#include <exceptions.h>
14+#include "exec.h"
1315
1416 using namespace disvm;
1517 using namespace disvm::runtime;
@@ -26,13 +28,10 @@ namespace · 10 unmodified lines
2628
2729 const auto entry_frame_pointer_map = std::vector<byte_t>{ 0x06 };
2830
29− std::shared_ptr<const runtime::vm_module_t> command_module;
31+ std::shared_ptr<const vm_module_t> command_module;
3032
31− std::unique_ptr<vm_module_t> create_entry_module(disvm::vm_t &vm, int argc, char* argv[])
33+ std::unique_ptr<vm_module_t> create_entry_module(vm_t &vm, int argc, char* argv[])
3234 {
33− if (argc == 0)
34− return{};
35−
3635 // First argument is the module to load
3736 auto command_module_path = new vm_string_t{ std::strlen(argv[0]), reinterpret_cast<uint8_t *>(argv[0]) };
3837
@@ -168,14 +167,37 @@ namespace · 129 unmodified lines
168167
169168 int main(int argc, char* argv[])
170169 {
171− disvm::vm_t vm;
170+ // [TODO] Handle command line arguments
171+ assert(argc > 1);
172+
173+ vm_t vm;
174+
175+ //vm.load_tool(std::make_shared<debugger>());
172176
173− // Ignore the process name
174− auto entry = create_entry_module(vm, argc - 1, argv + 1);
177+ try
178+ {
179+ // Ignore the process name
180+ auto entry = create_entry_module(vm, argc - 1, argv + 1);
175181
176− vm.exec(std::move(entry));
182+ vm.exec(std::move(entry));
177183
178− vm.spin_sleep_till_idle(std::chrono::milliseconds(100));
184+ vm.spin_sleep_till_idle(std::chrono::milliseconds(100));
185+ }
186+ catch (vm_user_exception &ue)
187+ {
188+ std::cout << ue.what() << std::endl;
189+
190+ return EXIT_FAILURE;
191+ }
192+ catch (vm_system_exception &se)
193+ {
194+ std::cout
195+ << "Internal exception:\n\t"
196+ << se.what()
197+ << std::endl;
198+
199+ return EXIT_FAILURE;
200+ }
179201
180202 return 0;
181203 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t