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
598598 return "poly<T>";
599599
600600 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);
602602 case type_class_t::channel:
603603 return "chan of " + to_string(tt.resolve_table_index<type_t>(t.value_index_1), tt);
604604 case type_class_t::list:
@@ -656,13 +656,13 @@ namespace · 51 unmodified lines
656656 {
657657 std::stringstream ss;
658658
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)
660661 ss << f.name;
661662
662− auto has_argument = false;
663− if (util::has_flag(fmt, function_name_format_t::arguments))
663+ const auto inc_arguments = util::has_flag(fmt, function_name_format_t::arguments);
664+ if (inc_arguments)
664665 {
665− has_argument = true;
666666 ss << '(';
667667
668668 auto first = true;
@@ -678,9 +678,11 @@ namespace · 9 unmodified lines
678678 ss << ')';
679679 }
680680
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)
682684 {
683− if (has_argument)
685+ if (inc_name || inc_arguments)
684686 ss << ':';
685687
686688 ss << to_string(f.return_type, tt);
@@ -689,17 +691,17 @@ namespace · 2 unmodified lines
689691 return ss.str();
690692 }
691693
692− class sbl_symbol_debug final : public symbol_debug_t
694+ class sbl_symbol_pc_iter final : public symbol_pc_iter_t
693695 {
694696 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)
696698 : _current_pc{ 0 }
697699 , _file{ f }
698700 {
699701 assert(_file != nullptr);
700702 }
701703
702− public: // symbol_debug_t
704+ public: // symbol_pc_iter_t
703705 void set_current_pc(disvm::runtime::vm_pc_t pc) override
704706 {
705707 assert(0 <= pc && pc < static_cast<int32_t>(_file->pc_table.size()));
@@ -784,7 +786,7 @@ namespace · 78 unmodified lines
784786
785787 private:
786788 runtime::vm_pc_t _current_pc;
787− std::shared_ptr<sbl_file_t> _file;
789+ std::shared_ptr<const sbl_file_t> _file;
788790 };
789791
790792 class sbl_symbol_data final : public symbol_data_t
@@ -807,13 +809,25 @@ namespace · 16 unmodified lines
807809 return _file->pc_table.size();
808810 }
809811
810− std::unique_ptr<symbol_debug_t> get_debug() override
812+ std::vector<function_data_t> get_functions(function_name_format_t f) const override
811813 {
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);
813827 }
814828
815829 private:
816− std::shared_ptr<sbl_file_t> _file;
830+ std::shared_ptr<const sbl_file_t> _file;
817831 };
818832 }
819833