Skip to content

Commit bcc5fb0

Browse files
committed
Reset source dirs on load/attach
1 parent d97b06c commit bcc5fb0

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

gui/TODO.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
-Wipe source code dirs when attaching/loading file (otherwise unpredictable vuln.c)
2-
31
Test:
42
-Shell spawn / multiple threads
53
-Docker setup + attach

gui/pwndbg_gui.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,9 @@ def select_file(self):
227227
# Before loading the file we want to set the correct tty for the inferior
228228
self.set_gdb_tty.emit(self.inferior_handler.tty)
229229
self.set_gdb_file_target_signal.emit([file_name])
230+
# Reset dir so that GDB doesn't get confused when we load multiple programs with the same name / source
231+
# file name
232+
self.set_gdb_source_dir_signal.emit([""])
230233
# GDB only looks for source files in the cwd, so we additionally add the directory of the executable
231234
self.set_gdb_source_dir_signal.emit([str(Path(file_name).parent)])
232235
self.main_context.inferior_attached = False
@@ -341,6 +344,9 @@ def attach_to_pid(self, pid: int):
341344
Attach to the given (valid) PID. Also sets the search directories and updates the contexts after attaching
342345
:param pid: The PID of a running program
343346
"""
347+
# Reset dir so that GDB doesn't get confused when we load multiple programs with the same name / source
348+
# file name
349+
self.set_gdb_source_dir_signal.emit([""])
344350
# Add the directory of the executable as a search directory for source files for GDB
345351
process_path = Path(psutil.Process(pid).exe()).parent.resolve()
346352
self.set_gdb_source_dir_signal.emit([str(process_path)])

0 commit comments

Comments
 (0)