btf-reader: Add missing data members reset to reader::initialize

Message ID 87bk3utel4.fsf@redhat.com
State New
Headers
Series btf-reader: Add missing data members reset to reader::initialize |

Commit Message

Dodji Seketeli June 21, 2024, 5:01 p.m. UTC
  Hello,

btf::reader::initialize forgets to reset a few data members used
during binary type information loading.  This resetting is key to get
the reader ready for being re-used to load a new binary, like a kernel
module.  Otherwise, the working set just keeps growing unnecessarily.

	* src/abg-btf-reader.cc (btf::reader::initialize): Clear
	types_to_canonicalize_, btf_type_id_to_artifacts_ and cur_tu_.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
---
 src/abg-btf-reader.cc | 3 +++
 1 file changed, 3 insertions(+)
  

Patch

diff --git a/src/abg-btf-reader.cc b/src/abg-btf-reader.cc
index a8131fd7..e4aca24f 100644
--- a/src/abg-btf-reader.cc
+++ b/src/abg-btf-reader.cc
@@ -240,6 +240,9 @@  protected:
   {
     btf__free(btf_handle_);
     btf_handle_ = nullptr;
+    types_to_canonicalize_.clear();
+    btf_type_id_to_artifacts_.clear();
+    cur_tu_.reset();
     elf_based_reader::initialize(elf_path, debug_info_root_paths);
     options().load_all_types = load_all_types;
     options().load_in_linux_kernel_mode = linux_kernel_mode;