Showing the changes to src/exec/main.cpp (1 of 17 files). Show all
Unified · Split
| @@ -195,14 +195,12 @@ struct exec_options · 194 unmodified lines | |||
| 195 | , enabled_debugger{ false } | 195 | , enabled_debugger{ false } |
| 196 | , quiet_start{ false } | 196 | , quiet_start{ false } |
| 197 | , print_help{ false } | 197 | , print_help{ false } |
| 198 | , sys_thread_count{ vm_t::default_system_thread_count } | 198 | , vm_config{} |
| 199 | , thread_quanta{ vm_t::default_thread_quanta } | ||
| 200 | { } | 199 | { } |
| 201 | 200 | ||
| 202 | std::vector<char *> vm_args; | 201 | std::vector<char *> vm_args; |
| 203 | 202 | ||
| 204 | uint32_t sys_thread_count; | 203 | vm_config_t vm_config; |
| 205 | uint32_t thread_quanta; | ||
| 206 | 204 | ||
| 207 | bool print_help; | 205 | bool print_help; |
| 208 | bool quiet_start; | 206 | bool quiet_start; |
| @@ -220,7 +218,7 @@ void print_banner(const exec_options &options) · 11 unmodified lines | |||
| 220 | std::cout | 218 | std::cout |
| 221 | << "\n----------------\n" | 219 | << "\n----------------\n" |
| 222 | << "Debugger enabled: " << std::boolalpha << options.enabled_debugger << "\n" | 220 | << "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"; |
| 224 | 222 | ||
| 225 | if (options.enabled_debugger) | 223 | if (options.enabled_debugger) |
| 226 | std::cout << "\n" << options.debugger << "\n"; | 224 | 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 | |||
| 274 | std::cout << ss.str(); | 272 | std::cout << ss.str(); |
| 275 | } | 273 | } |
| 276 | 274 | ||
| 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 | |||
| 285 | void process_arg(char* arg, std::function<char *()> next, exec_options &options) | 275 | void process_arg(char* arg, std::function<char *()> next, exec_options &options) |
| 286 | { | 276 | { |
| 287 | assert(arg != nullptr && next != nullptr); | 277 | assert(arg != nullptr && next != nullptr); |
| @@ -326,28 +316,30 @@ void process_arg(char* arg, std::function<char *()> next, exec_options &options) · 38 unmodified lines | |||
| 326 | if (sys_threads <= 0 || 4 < sys_threads) | 316 | if (sys_threads <= 0 || 4 < sys_threads) |
| 327 | throw arg_exception_t{ "Invalid system thread value", sys_threads_str }; | 317 | throw arg_exception_t{ "Invalid system thread value", sys_threads_str }; |
| 328 | 318 | ||
| 329 | options.sys_thread_count = sys_threads; | 319 | options.vm_config.sys_thread_pool_size = sys_threads; |
| 330 | } | 320 | } |
| 331 | break; | 321 | break; |
| 332 | 322 | ||
| 333 | case 'l': | 323 | case 'l': |
| 324 | // Set the callback | ||
| 325 | debug::set_logging_callback(log_callback); | ||
| 334 | for (auto i = std::size_t{ 2 }; i < arg_len; ++i) | 326 | for (auto i = std::size_t{ 2 }; i < arg_len; ++i) |
| 335 | { | 327 | { |
| 336 | switch (arg[i]) | 328 | switch (arg[i]) |
| 337 | { | 329 | { |
| 338 | case 's': enable_logging(debug::component_trace_t::scheduler); | 330 | case 's': debug::set_component_tracing(debug::component_trace_t::scheduler, true); |
| 339 | break; | 331 | break; |
| 340 | case 'S': enable_logging(debug::component_trace_t::stack); | 332 | case 'S': debug::set_component_tracing(debug::component_trace_t::stack, true); |
| 341 | break; | 333 | break; |
| 342 | case 't': enable_logging(debug::component_trace_t::thread); | 334 | case 't': debug::set_component_tracing(debug::component_trace_t::thread, true); |
| 343 | break; | 335 | break; |
| 344 | case 'T': enable_logging(debug::component_trace_t::tool); | 336 | case 'T': debug::set_component_tracing(debug::component_trace_t::tool, true); |
| 345 | break; | 337 | break; |
| 346 | case 'e': enable_logging(debug::component_trace_t::exception); | 338 | case 'e': debug::set_component_tracing(debug::component_trace_t::exception, true); |
| 347 | break; | 339 | 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); |
| 349 | break; | 341 | break; |
| 350 | case 'm': enable_logging(debug::component_trace_t::memory); | 342 | case 'm': debug::set_component_tracing(debug::component_trace_t::memory, true); |
| 351 | break; | 343 | break; |
| 352 | } | 344 | } |
| 353 | } | 345 | } |
| @@ -402,7 +394,7 @@ int main(int argc, char* argv[]) · 48 unmodified lines | |||
| 402 | return EXIT_SUCCESS; | 394 | return EXIT_SUCCESS; |
| 403 | } | 395 | } |
| 404 | 396 | ||
| 405 | vm_t vm{ options.sys_thread_count, options.thread_quanta }; | 397 | vm_t vm{ std::move(options.vm_config) }; |
| 406 | 398 | ||
| 407 | if (options.enabled_debugger) | 399 | if (options.enabled_debugger) |
| 408 | vm.load_tool(std::make_shared<debugger>(options.debugger)); | 400 | vm.load_tool(std::make_shared<debugger>(options.debugger)); |