Skip to content

Commit a395a81

Browse files
pf: print the executable name on #PF
Signed-off-by: Andy-Python-Programmer <[email protected]>
1 parent fdae11d commit a395a81

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

src/aero_kernel/src/arch/x86_64/interrupts/exceptions.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,12 @@ pub(super) fn page_fault(stack: &mut InterruptErrorStack) {
113113
task.tid().as_usize(),
114114
task.pid().as_usize()
115115
);
116+
117+
log::error!(
118+
"process: (path=`{}`)",
119+
task.path()
120+
.expect("userland application does not have a path set")
121+
);
116122
}
117123

118124
scheduler::get_scheduler().current_task().vm.log();

src/aero_kernel/src/userland/task.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,8 @@ pub struct Task {
183183
sleep_duration: AtomicUsize,
184184
signals: Signals,
185185

186+
executable: Mutex<Option<DirCacheItem>>,
187+
186188
pub(super) link: intrusive_collections::LinkedListLink,
187189
pub(super) clink: intrusive_collections::LinkedListLink,
188190

@@ -215,6 +217,8 @@ impl Task {
215217
tid: pid.clone(),
216218
pid,
217219

220+
executable: Mutex::new(None),
221+
218222
vm: Arc::new(Vm::new()),
219223
state: AtomicU8::new(TaskState::Runnable as _),
220224

@@ -258,6 +262,8 @@ impl Task {
258262
sleep_duration: AtomicUsize::new(0),
259263
exit_status: AtomicIsize::new(0),
260264

265+
executable: Mutex::new(None),
266+
261267
children: Mutex::new(Default::default()),
262268
parent: Mutex::new(None),
263269

@@ -288,6 +294,8 @@ impl Task {
288294
tid: pid.clone(),
289295
pid,
290296

297+
executable: Mutex::new(self.executable.lock().clone()),
298+
291299
children: Mutex::new(Default::default()),
292300
parent: Mutex::new(None),
293301

@@ -369,13 +377,22 @@ impl Task {
369377
self.zombies.waitpid(pid, status)
370378
}
371379

380+
pub fn path(&self) -> Option<String> {
381+
self.executable
382+
.lock()
383+
.as_ref()
384+
.map(|e| e.absolute_path_str())
385+
}
386+
372387
pub fn exec(
373388
&self,
374389
executable: DirCacheItem,
375390

376391
argv: Option<ExecArgs>,
377392
envv: Option<ExecArgs>,
378393
) -> Result<(), MapToError<Size4KiB>> {
394+
*self.executable.lock() = Some(executable.clone());
395+
379396
let vm = self.vm();
380397
vm.clear();
381398

0 commit comments

Comments
 (0)