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
4// Author: arr4// Author: arr
5//5//
6 6
7#include <cstdio>7#include <iostream>
8#include <cassert>8#include <cassert>
9#include <array>9#include <array>
10#include <disvm.h>10#include <memory>
11#include <builtin_module.h>11#include <builtin_module.h>
12#include <debug.h>12#include <debug.h>
13#include <exceptions.h>
14#include "exec.h"
13 15
14using namespace disvm;16using namespace disvm;
15using namespace disvm::runtime;17using namespace disvm::runtime;
@@ -26,13 +28,10 @@ namespace · 10 unmodified lines
26 28
27 const auto entry_frame_pointer_map = std::vector<byte_t>{ 0x06 };29 const auto entry_frame_pointer_map = std::vector<byte_t>{ 0x06 };
28 30
29 std::shared_ptr<const runtime::vm_module_t> command_module;31 std::shared_ptr<const vm_module_t> command_module;
30 32
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[])
32 {34 {
33 if (argc == 0)
34 return{};
35
36 // First argument is the module to load35 // First argument is the module to load
37 auto command_module_path = new vm_string_t{ std::strlen(argv[0]), reinterpret_cast<uint8_t *>(argv[0]) };36 auto command_module_path = new vm_string_t{ std::strlen(argv[0]), reinterpret_cast<uint8_t *>(argv[0]) };
38 37
@@ -168,14 +167,37 @@ namespace · 129 unmodified lines
168 167
169int main(int argc, char* argv[])168int main(int argc, char* argv[])
170{169{
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>());
172 176
173 // Ignore the process name177 try
174 auto entry = create_entry_module(vm, argc - 1, argv + 1);178 {
179 // Ignore the process name
180 auto entry = create_entry_module(vm, argc - 1, argv + 1);
175 181
176 vm.exec(std::move(entry));182 vm.exec(std::move(entry));
177 183
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 }
179 201
180 return 0;202 return 0;
181}203}

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