History

Create configuration struct for VM Add syscall failure exception - Create VM syscall failure message functions Respect the 'r' format verb Create module resolver interface Implement default module resolver interface Implement Sys.fildes() function

arr committed 9 years ago

Commit 232a6591 parent eb06d3d17 files · +416 −124Browse files

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

Unified · Split

src/exec/main.cpp+14−22
@@ -195,14 +195,12 @@ struct exec_options · 194 unmodified lines
195195 , enabled_debugger{ false }
196196 , quiet_start{ false }
197197 , print_help{ false }
198− , sys_thread_count{ vm_t::default_system_thread_count }
199− , thread_quanta{ vm_t::default_thread_quanta }
198+ , vm_config{}
200199 { }
201200
202201 std::vector<char *> vm_args;
203202
204− uint32_t sys_thread_count;
205− uint32_t thread_quanta;
203+ vm_config_t vm_config;
206204
207205 bool print_help;
208206 bool quiet_start;
@@ -220,7 +218,7 @@ void print_banner(const exec_options &options) · 11 unmodified lines
220218 std::cout
221219 << "\n----------------\n"
222220 << "Debugger enabled: " << std::boolalpha << options.enabled_debugger << "\n"
223− << "System thread usage: " << options.sys_thread_count << "\n";
221+ << "System thread usage: " << options.vm_config.sys_thread_pool_size << "\n";
224222
225223 if (options.enabled_debugger)
226224 std::cout << "\n" << options.debugger << "\n";
@@ -274,14 +272,6 @@ void log_callback(const debug::component_trace_t origin, const debug::log_level_ · 47 unmodified lines
274272 std::cout << ss.str();
275273 }
276274
277−void enable_logging(debug::component_trace_t c)
278−{
279− debug::set_component_tracing(c, true);
280−
281− // Constantly setting the callback
282− debug::set_logging_callback(log_callback);
283−}
284−
285275 void process_arg(char* arg, std::function<char *()> next, exec_options &options)
286276 {
287277 assert(arg != nullptr && next != nullptr);
@@ -326,28 +316,30 @@ void process_arg(char* arg, std::function<char *()> next, exec_options &options) · 38 unmodified lines
326316 if (sys_threads <= 0 || 4 < sys_threads)
327317 throw arg_exception_t{ "Invalid system thread value", sys_threads_str };
328318
329− options.sys_thread_count = sys_threads;
319+ options.vm_config.sys_thread_pool_size = sys_threads;
330320 }
331321 break;
332322
333323 case 'l':
324+ // Set the callback
325+ debug::set_logging_callback(log_callback);
334326 for (auto i = std::size_t{ 2 }; i < arg_len; ++i)
335327 {
336328 switch (arg[i])
337329 {
338− case 's': enable_logging(debug::component_trace_t::scheduler);
330+ case 's': debug::set_component_tracing(debug::component_trace_t::scheduler, true);
339331 break;
340− case 'S': enable_logging(debug::component_trace_t::stack);
332+ case 'S': debug::set_component_tracing(debug::component_trace_t::stack, true);
341333 break;
342− case 't': enable_logging(debug::component_trace_t::thread);
334+ case 't': debug::set_component_tracing(debug::component_trace_t::thread, true);
343335 break;
344− case 'T': enable_logging(debug::component_trace_t::tool);
336+ case 'T': debug::set_component_tracing(debug::component_trace_t::tool, true);
345337 break;
346− case 'e': enable_logging(debug::component_trace_t::exception);
338+ case 'e': debug::set_component_tracing(debug::component_trace_t::exception, true);
347339 break;
348− case 'g': enable_logging(debug::component_trace_t::garbage_collector);
340+ case 'g': debug::set_component_tracing(debug::component_trace_t::garbage_collector, true);
349341 break;
350− case 'm': enable_logging(debug::component_trace_t::memory);
342+ case 'm': debug::set_component_tracing(debug::component_trace_t::memory, true);
351343 break;
352344 }
353345 }
@@ -402,7 +394,7 @@ int main(int argc, char* argv[]) · 48 unmodified lines
402394 return EXIT_SUCCESS;
403395 }
404396
405− vm_t vm{ options.sys_thread_count, options.thread_quanta };
397+ vm_t vm{ std::move(options.vm_config) };
406398
407399 if (options.enabled_debugger)
408400 vm.load_tool(std::make_shared<debugger>(options.debugger));