MCPcopy Create free account
hub / github.com/HexHive/NASS / new_objfile_handler

Function new_objfile_handler

tools/gef.py:3510–3536  ·  view source on GitHub ↗

GDB event handler for new object file cases.

(evt: Optional["gdb.NewObjFileEvent"])

Source from the content-addressed store, hash-verified

3508
3509
3510def new_objfile_handler(evt: Optional["gdb.NewObjFileEvent"]) -> None:
3511 """GDB event handler for new object file cases."""
3512 reset_all_caches()
3513 path = evt.new_objfile.filename if evt else gdb.current_progspace().filename
3514 try:
3515 if gef.session.root and path.startswith("target:"):
3516 # If the process is in a container, replace the "target:" prefix
3517 # with the actual root directory of the process.
3518 path = path.replace("target:", str(gef.session.root), 1)
3519 target = pathlib.Path(path)
3520 FileFormatClasses = list(filter(lambda fmtcls: fmtcls.is_valid(target), __registered_file_formats__))
3521 GuessedFileFormatClass : Type[FileFormat] = FileFormatClasses.pop() if len(FileFormatClasses) else Elf
3522 binary = GuessedFileFormatClass(target)
3523 if not gef.binary:
3524 gef.binary = binary
3525 reset_architecture()
3526 else:
3527 gef.session.modules.append(binary)
3528 except FileNotFoundError as fne:
3529 # Linux automatically maps the vDSO into our process, and GDB
3530 # will give us the string 'system-supplied DSO' as a path.
3531 # This is normal, so we shouldn't warn the user about it
3532 if "system-supplied DSO" not in path:
3533 warn(f"Failed to find objfile or not a valid file format: {str(fne)}")
3534 except RuntimeError as re:
3535 warn(f"Not a valid file format: {str(re)}")
3536 return
3537
3538
3539def exit_handler(_: "gdb.ExitedEvent") -> None:

Callers 1

gef.pyFile · 0.85

Calls 5

reset_all_cachesFunction · 0.85
reset_architectureFunction · 0.85
warnFunction · 0.85
is_validMethod · 0.45
popMethod · 0.45

Tested by

no test coverage detected