History

Expose the loaded path of a module from the VM. Display path for the loaded module in the debugger.

arr committed 10 years ago

Commit 42194721 parent 836214e4 files · +47 −57Browse files

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

Unified · Split

src/include/disvm.h+19−22
@@ -35,6 +35,19 @@ namespace disvm · 34 unmodified lines
3535 const char * const label; // Optional
3636 };
3737
38+ // Loaded module reference
39+ class loaded_vm_module_t final
40+ {
41+ public:
42+ // Origin of module
43+ std::unique_ptr<runtime::vm_string_t> origin;
44+
45+ // Weak reference to a loaded module
46+ std::weak_ptr<runtime::vm_module_t> module;
47+ };
48+
49+ using loaded_vm_module_callback_t = std::function<void(const loaded_vm_module_t&)>;
50+
3851 // Virtual machine
3952 class vm_t final
4053 {
@@ -71,9 +84,11 @@ namespace disvm · 30 unmodified lines
7184 // Load the module at the supplied path into the virtual machine
7285 std::shared_ptr<runtime::vm_module_t> load_module(const char *path);
7386
74− // Get a collection of all currently loaded modules.
75− // Note this will only include modules that have been loaded by a call to vm_t::load_module.
76− std::vector<std::shared_ptr<runtime::vm_module_t>> get_loaded_modules() const;
87+ // Enumerate all loaded modules - this can include references to modules that
88+ // have been unloaded due to no longer being used. If the module instance is null, the
89+ // module is no longer loaded.
90+ // Note this will only enumerate modules that have been loaded by a call to vm_t::load_module.
91+ void enum_loaded_modules(loaded_vm_module_callback_t callback) const;
7792
7893 // Access the scheduler control for this VM.
7994 runtime::vm_scheduler_control_t &get_scheduler_control() const;
@@ -94,25 +109,7 @@ namespace disvm · 14 unmodified lines
94109 private:
95110 const runtime::vm_thread_t &schedule_thread(std::unique_ptr<runtime::vm_thread_t> thread);
96111
97− // Loaded module reference
98− class loaded_module_t final
99− {
100− public:
101− loaded_module_t(std::unique_ptr<runtime::vm_string_t> origin, std::shared_ptr<runtime::vm_module_t> module);
102− loaded_module_t(const loaded_module_t &) = delete;
103− loaded_module_t &operator=(const loaded_module_t &) = delete;
104−
105− loaded_module_t(loaded_module_t &&);
106− ~loaded_module_t();
107−
108− // Origin of module
109− std::unique_ptr<runtime::vm_string_t> origin;
110−
111− // Weak reference to a loaded module
112− std::weak_ptr<runtime::vm_module_t> module;
113− };
114−
115− using loaded_modules_t = std::forward_list<loaded_module_t>;
112+ using loaded_modules_t = std::forward_list<loaded_vm_module_t>;
116113 mutable std::mutex _modules_lock;
117114 loaded_modules_t _modules;
118115