Skip to content

Commit 8df5b6c

Browse files
author
shadow3aaa
committed
避免重复添加app
1 parent 972ca6c commit 8df5b6c

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

frame-analyzer/src/lib.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ impl Analyzer {
158158
}
159159

160160
/// Attach the Analyzer to the target application
161+
/// If attach the same application multiple times, `Analyzer::attach_app` will directly return `Ok` without attaching again
161162
///
162163
/// # Errors
163164
///
@@ -184,6 +185,10 @@ impl Analyzer {
184185
/// # }
185186
/// ```
186187
pub fn attach_app(&mut self, pid: Pid) -> Result<()> {
188+
if self.contains(pid) {
189+
return Ok(());
190+
}
191+
187192
let mut uprobe = UprobeHandler::attach_app(pid)?;
188193

189194
self.poll.registry().register(

0 commit comments

Comments
 (0)