8.8.1.1.1.2.15. SymbolModule

interface SymbolModule()
load(fullPath: string)

Unload all currently loaded symbols and load a symbol file.

symModule.load("C:/my_project/Debug/example.out");
Parameters:
  • fullPath (string) -- The path to the symbol file.

Return type:

void

add(fullPath: string)

Load a symbol file and add its symbols to the currently loaded symbols.

symModule.load("C:/my_project/Debug/example.out");
symModule.add("C:/my_library/Debug/library.out");
// Now symbols from both example.out and library.out are available
Parameters:
  • fullPath (string) -- The path to the symbol file.

Return type:

void

remove(fullPath: string)

Remove a symbol file from the currently loaded symbols. Symbols from other files will remain loaded.

symModule.load("C:/my_project/Debug/example.out");
symModule.add("C:/my_library/Debug/library.out");
// Now symbols from both example.out and library.out are available
symModule.remove("C:/my_project/Debug/example.out");
// Now only symbols from library.out are available
Parameters:
  • fullPath (string) -- The path to the symbol file

Return type:

void

unloadAll()

Unload all currently loaded symbols.

symModule.load("C:/my_project/Debug/example.out");
symModule.add("C:/my_library/Debug/library.out");
// Now symbols from both example.out and library.out are available
symModule.unloadAll();
// Now there are no symbols loaded
Return type:

void

lookupFunction(location: Address)

Lookup the function containing the given location.

const func = symModule.lookupFunction(0x0020001Cn);
if (func) {
  console.log(`0x0020001C is within ${func.name}`);
} else {
  console.log(`0x0020001C is not within any function in the currently loaded symbols`);
}
Parameters:
  • location (Address) -- The address at which to look for the function.

Returns:

The information of the function if found, null otherwise.

Return type:

FunctionInfo | null

lookupSourceLine(location: Address)

Lookup the source line corresponding to the given location.

const line = symModule.lookupSourceLine(0x0020001Cn);
if (line) {
  console.log(`0x0020001C is on line ${line.line} of ${line.file}`);
} else {
  console.log(`0x0020001C is not on any source line in the currently loaded symbols`);
}
Parameters:
  • location (Address) -- The address at which to look for the source line.

Returns:

The information of the source line if found, null otherwise.

Return type:

SourceLineInfo | null

findFirstSymbolValue(name: string)

Like :js:meth:~SymbolRootObject.findSymbolValues but returns the value of the first symbol found.

const value = symModule.findFirstSymbolValue("foo");
if (value) {
  console.log(`There is a symbol named "foo" with value ${value}`);
} else {
  console.log(`There is no symbol named "foo"`);
}
Parameters:
  • name (string) -- The name of the symbol to find.

Returns:

The value of the symbol if found, null otherwise.

Return type:

bigint | number | string | null

findSymbolValues(name: string)

Find the value of all symbols with a given name.

const values = symModule.findSymbolValues("foo");
console.log(`There are ${values.length} symbols named "foo" with values:`);
for (const value of values) {
  console.log(`  ${value}`);
}
Parameters:
  • name (string) -- The name of the symbol(s) to find.

Returns:

A list of values for the symbols found.

Return type:

(bigint | number | string)[]

disassemble(start: Address, end: Address)

Disassemble the given address range using the contents of the loaded object files. Both the start and end addresses are included in the range.

The text returned for each row of disassembly includes the address, opcode bytes, and the disassembled instruction.

const { disassembly } = symModule.disassemble(0x00200000n, 0x00201000n);
console.log("Disassembly:");
for (const line of disassembly) {
  console.log(`  ${line.text}`);
}

// This might output the following
//
// Disassembly:
//   20005494 B580                push    {r7, lr}
//   20005496 FFF9F7FF            bl      0x2000548c <foo>
//   2000549A BD80                pop     {r7, pc}
//   2000549C 2001                movs    r0, #0x1
//   ...
Parameters:
  • start (Address) -- The start address of the range to disassemble.

  • end (Address) -- The end address of the range to disassemble.

Return type:

DisassemblyResult