[DynInst_API:] [dyninst/dyninst] 7e62e5: Refactor Symtab::getOrCreateModule (#1568)


Date: Mon, 09 Oct 2023 11:56:10 -0700
From: Tim Haines <noreply@xxxxxxxxxx>
Subject: [DynInst_API:] [dyninst/dyninst] 7e62e5: Refactor Symtab::getOrCreateModule (#1568)
  Branch: refs/heads/master
  Home:   https://github.com/dyninst/dyninst
  Commit: 7e62e5e7f931fa18330fb633be1a81741ea0a2ca
      https://github.com/dyninst/dyninst/commit/7e62e5e7f931fa18330fb633be1a81741ea0a2ca
  Author: Tim Haines <thaines.astro@xxxxxxxxx>
  Date:   2023-10-09 (Mon, 09 Oct 2023)

  Changed paths:
    M symtabAPI/src/Symtab.C

  Log Message:
  -----------
  Refactor Symtab::getOrCreateModule (#1568)

* Merge getOrCreateModule and newModule

The latter was only ever called from the former.

* Remove dead debug code

* Do not adjust Module's address

It's unclear why this was here. This function is currently called from
only two places: BinaryEdit::writeFile and
Object::fix_global_symbol_modules_static_dwarf.

In the first, the module created is called 'dyninstInst'. This is the
only place where that name is used, so only one module would be created.
Moreover, 'writeFile' will only produce a single binary output, so there
wouldn't be multiple modules.

In the second, the module lookup will always fail because we are
creating new ones for each DWARF compilation unit (CU), and those are
guaranteed to be unique as we iterate over the results of
'dwarf_nextcu'.

* Remove 'directory definitions' check

This kind of name is never used manually anywhere in Dyninst and the
names that come from DWARF compilation units (CUs) are never
directories.

* Clean up 'create' tracing message

* Tidy up variable declarations.

* Remove 'assert' after 'new'.

We require exceptions to be enabled when building Dyninst and we aren't
using the 'nothrow' version of 'operator new' here. This check is
useless.

* Remove existence check.

This will never be true because 'findModuleByOffset' would have found
the module.

* Don't return with parens

* Rename 'ret' to 'mod'.

For clarity.


[← Prev in Thread] Current Thread [Next in Thread→]
  • [DynInst_API:] [dyninst/dyninst] 7e62e5: Refactor Symtab::getOrCreateModule (#1568), Tim Haines <=