History

Add support for inleaving source information into disassembly view in debugger.

arr committed 9 years ago

Commit eb8b0901 parent 2b710fc4 files · +217 −59Browse files

Showing the changes to src/include (1 of 4 files). Show all

Unified · Split

src/include/vm_asm.h+25−12
@@ -407,6 +407,7 @@ namespace disvm · 406 unmodified lines
407 int32_t end_column;407 int32_t end_column;
408 };408 };
409 409
410 // Enumeration for formatting a function name
410 enum class function_name_format_t411 enum class function_name_format_t
411 {412 {
412 name = 1,413 name = 1,
@@ -418,20 +419,20 @@ namespace disvm · 5 unmodified lines
418 419
419 DEFINE_ENUM_FLAG_OPERATORS(function_name_format_t);420 DEFINE_ENUM_FLAG_OPERATORS(function_name_format_t);
420 421
421 class symbol_debug_t422 // Enumeration for advancing the pc
423 enum class advance_pc_t
424 {
425 current, // Return the current pc
426 next_pc,
427 next_debug_statement, // Advance to the next debug statement (i.e. source language statement)
428 };
429
430 class symbol_pc_iter_t
422 {431 {
423 public:432 public:
424 // Set the current pc433 // Set the current pc
425 virtual void set_current_pc(disvm::runtime::vm_pc_t) = 0;434 virtual void set_current_pc(disvm::runtime::vm_pc_t) = 0;
426 435
427 // Enumeration for advancing the pc
428 enum class advance_pc_t
429 {
430 current, // Return the current pc
431 next_pc,
432 next_debug_statement, // Advance to the next debug statement (i.e. source language statement)
433 };
434
435 // Advance the current pc.436 // Advance the current pc.
436 // Returns 'true' if the function was successful, otherwise 'false'.437 // Returns 'true' if the function was successful, otherwise 'false'.
437 virtual bool try_advance_pc(advance_pc_t, disvm::runtime::vm_pc_t *pc_after_advance = nullptr) = 0;438 virtual bool try_advance_pc(advance_pc_t, disvm::runtime::vm_pc_t *pc_after_advance = nullptr) = 0;
@@ -439,7 +440,7 @@ namespace disvm · 1 unmodified line
439 // Return the name of the function containing the current pc.440 // Return the name of the function containing the current pc.
440 // Optionally format the returned string.441 // Optionally format the returned string.
441 // This function will throw a 'std::runtime_error' if a function doesn't exist at the current pc.442 // This function will throw a 'std::runtime_error' if a function doesn't exist at the current pc.
442 virtual std::string current_function_name(function_name_format_t f = function_name_format_t::name) const = 0;443 virtual std::string current_function_name(function_name_format_t f) const = 0;
443 444
444 // Return the source location for the current pc445 // Return the source location for the current pc
445 virtual source_ref_t current_source_location() const = 0;446 virtual source_ref_t current_source_location() const = 0;
@@ -448,6 +449,13 @@ namespace disvm · 2 unmodified lines
448 virtual const std::string &get_source_by_id(int32_t source_id) const = 0;449 virtual const std::string &get_source_by_id(int32_t source_id) const = 0;
449 };450 };
450 451
452 struct function_data_t
453 {
454 disvm::runtime::vm_pc_t entry_pc;
455 disvm::runtime::vm_pc_t limit_pc;
456 std::string name;
457 };
458
451 class symbol_data_t459 class symbol_data_t
452 {460 {
453 public:461 public:
@@ -457,10 +465,15 @@ namespace disvm · 3 unmodified lines
457 // Get instruction count in the symbol data465 // Get instruction count in the symbol data
458 virtual size_t get_instruction_count() const = 0;466 virtual size_t get_instruction_count() const = 0;
459 467
460 // Get interface over symbol data targeted for debugging468 // Get list of functions in module.
461 virtual std::unique_ptr<symbol_debug_t> get_debug() = 0;469 // Supply a formatting enum for the function name.
470 virtual std::vector<function_data_t> get_functions(function_name_format_t f) const = 0;
471
472 // Get pc iterator interface over symbol data
473 virtual std::unique_ptr<symbol_pc_iter_t> get_pc_iter() const = 0;
462 };474 };
463 475
476 // Read in symbol data from the supplied stream
464 std::unique_ptr<symbol_data_t> read(std::istream &);477 std::unique_ptr<symbol_data_t> read(std::istream &);
465 }478 }
466 479