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/asm/sbl_reader.cpp (1 of 4 files). Show all

Unified · Split

src/asm/sbl_reader.cpp+28−14
@@ -598,7 +598,7 @@ namespace · 597 unmodified lines
598 return "poly<T>";598 return "poly<T>";
599 599
600 case type_class_t::array:600 case type_class_t::array:
601 return to_string(tt.resolve_table_index<type_t>(t.value_index_1), tt) + "[]";601 return "array of " + to_string(tt.resolve_table_index<type_t>(t.value_index_1), tt);
602 case type_class_t::channel:602 case type_class_t::channel:
603 return "chan of " + to_string(tt.resolve_table_index<type_t>(t.value_index_1), tt);603 return "chan of " + to_string(tt.resolve_table_index<type_t>(t.value_index_1), tt);
604 case type_class_t::list:604 case type_class_t::list:
@@ -656,13 +656,13 @@ namespace · 51 unmodified lines
656 {656 {
657 std::stringstream ss;657 std::stringstream ss;
658 658
659 if (util::has_flag(fmt, function_name_format_t::name))659 const auto inc_name = util::has_flag(fmt, function_name_format_t::name);
660 if (inc_name)
660 ss << f.name;661 ss << f.name;
661 662
662 auto has_argument = false;663 const auto inc_arguments = util::has_flag(fmt, function_name_format_t::arguments);
663 if (util::has_flag(fmt, function_name_format_t::arguments))664 if (inc_arguments)
664 {665 {
665 has_argument = true;
666 ss << '(';666 ss << '(';
667 667
668 auto first = true;668 auto first = true;
@@ -678,9 +678,11 @@ namespace · 9 unmodified lines
678 ss << ')';678 ss << ')';
679 }679 }
680 680
681 if (util::has_flag(fmt, function_name_format_t::return_type))681 // Only add the return value if it is not 'none'
682 if (util::has_flag(fmt, function_name_format_t::return_type)
683 && f.return_type.type_class != type_class_t::none)
682 {684 {
683 if (has_argument)685 if (inc_name || inc_arguments)
684 ss << ':';686 ss << ':';
685 687
686 ss << to_string(f.return_type, tt);688 ss << to_string(f.return_type, tt);
@@ -689,17 +691,17 @@ namespace · 2 unmodified lines
689 return ss.str();691 return ss.str();
690 }692 }
691 693
692 class sbl_symbol_debug final : public symbol_debug_t694 class sbl_symbol_pc_iter final : public symbol_pc_iter_t
693 {695 {
694 public:696 public:
695 sbl_symbol_debug(std::shared_ptr<sbl_file_t> f)697 sbl_symbol_pc_iter(std::shared_ptr<const sbl_file_t> f)
696 : _current_pc{ 0 }698 : _current_pc{ 0 }
697 , _file{ f }699 , _file{ f }
698 {700 {
699 assert(_file != nullptr);701 assert(_file != nullptr);
700 }702 }
701 703
702 public: // symbol_debug_t704 public: // symbol_pc_iter_t
703 void set_current_pc(disvm::runtime::vm_pc_t pc) override705 void set_current_pc(disvm::runtime::vm_pc_t pc) override
704 {706 {
705 assert(0 <= pc && pc < static_cast<int32_t>(_file->pc_table.size()));707 assert(0 <= pc && pc < static_cast<int32_t>(_file->pc_table.size()));
@@ -784,7 +786,7 @@ namespace · 78 unmodified lines
784 786
785 private:787 private:
786 runtime::vm_pc_t _current_pc;788 runtime::vm_pc_t _current_pc;
787 std::shared_ptr<sbl_file_t> _file;789 std::shared_ptr<const sbl_file_t> _file;
788 };790 };
789 791
790 class sbl_symbol_data final : public symbol_data_t792 class sbl_symbol_data final : public symbol_data_t
@@ -807,13 +809,25 @@ namespace · 16 unmodified lines
807 return _file->pc_table.size();809 return _file->pc_table.size();
808 }810 }
809 811
810 std::unique_ptr<symbol_debug_t> get_debug() override812 std::vector<function_data_t> get_functions(function_name_format_t f) const override
811 {813 {
812 return std::make_unique<sbl_symbol_debug>(_file);814 std::vector<function_data_t> funcs;
815 for (func_table_t::const_reference func : _file->func_table)
816 {
817 auto formatted_name = to_string(func, _file->type_table, f);
818 funcs.push_back({ func.entry_pc, func.limit_pc, std::move(formatted_name) });
819 }
820
821 return funcs;
822 }
823
824 std::unique_ptr<symbol_pc_iter_t> get_pc_iter() const override
825 {
826 return std::make_unique<sbl_symbol_pc_iter>(_file);
813 }827 }
814 828
815 private:829 private:
816 std::shared_ptr<sbl_file_t> _file;830 std::shared_ptr<const sbl_file_t> _file;
817 };831 };
818}832}
819 833