mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-05 10:49:34 +02:00
fix for concurrent access exceptions
This commit is contained in:
parent
cd32ab60be
commit
c4f1ec8e0a
6 changed files with 71 additions and 50 deletions
|
@ -123,7 +123,11 @@ public class DbgManagerImpl implements DbgManager {
|
||||||
public DbgThreadImpl getThreadComputeIfAbsent(DebugThreadId id, DbgProcessImpl process,
|
public DbgThreadImpl getThreadComputeIfAbsent(DebugThreadId id, DbgProcessImpl process,
|
||||||
int tid) {
|
int tid) {
|
||||||
synchronized (threads) {
|
synchronized (threads) {
|
||||||
return threads.computeIfAbsent(id, i -> new DbgThreadImpl(this, process, id, tid));
|
if (!threads.containsKey(id)) {
|
||||||
|
DbgThreadImpl thread = new DbgThreadImpl(this, process, id, tid);
|
||||||
|
thread.add();
|
||||||
|
}
|
||||||
|
return threads.get(id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -188,7 +192,11 @@ public class DbgManagerImpl implements DbgManager {
|
||||||
|
|
||||||
public DbgProcessImpl getProcessComputeIfAbsent(DebugProcessId id, int pid) {
|
public DbgProcessImpl getProcessComputeIfAbsent(DebugProcessId id, int pid) {
|
||||||
synchronized (processes) {
|
synchronized (processes) {
|
||||||
return processes.computeIfAbsent(id, i -> new DbgProcessImpl(this, id, pid));
|
if (!processes.containsKey(id)) {
|
||||||
|
DbgProcessImpl process = new DbgProcessImpl(this, id, pid);
|
||||||
|
process.add();
|
||||||
|
}
|
||||||
|
return processes.get(id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -221,7 +229,11 @@ public class DbgManagerImpl implements DbgManager {
|
||||||
|
|
||||||
public DbgSessionImpl getSessionComputeIfAbsent(DebugSessionId id) {
|
public DbgSessionImpl getSessionComputeIfAbsent(DebugSessionId id) {
|
||||||
synchronized (sessions) {
|
synchronized (sessions) {
|
||||||
return sessions.computeIfAbsent(id, i -> new DbgSessionImpl(this, id));
|
if (!sessions.containsKey(id)) {
|
||||||
|
DbgSessionImpl session = new DbgSessionImpl(this, id);
|
||||||
|
session.add();
|
||||||
|
}
|
||||||
|
return sessions.get(id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -720,7 +732,7 @@ public class DbgManagerImpl implements DbgManager {
|
||||||
so.setCurrentProcessId(id);
|
so.setCurrentProcessId(id);
|
||||||
int pid = so.getCurrentProcessSystemId();
|
int pid = so.getCurrentProcessSystemId();
|
||||||
DbgProcessImpl proc = new DbgProcessImpl(this, id, pid);
|
DbgProcessImpl proc = new DbgProcessImpl(this, id, pid);
|
||||||
proc.add(evt.getCause());
|
proc.add();
|
||||||
getEventListeners().fire.processAdded(proc, evt.getCause());
|
getEventListeners().fire.processAdded(proc, evt.getCause());
|
||||||
getEventListeners().fire.processSelected(proc, evt.getCause());
|
getEventListeners().fire.processSelected(proc, evt.getCause());
|
||||||
|
|
||||||
|
@ -1325,50 +1337,62 @@ public class DbgManagerImpl implements DbgManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
public DbgThreadImpl getCurrentThread() {
|
public DbgThreadImpl getCurrentThread() {
|
||||||
DebugEventInformation info = getLastEventInformation();
|
synchronized (threads) {
|
||||||
if (info == null) {
|
DebugEventInformation info = getLastEventInformation();
|
||||||
return null;
|
if (info == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
DebugSystemObjects so = getSystemObjects();
|
||||||
|
int tid = so.getCurrentThreadSystemId();
|
||||||
|
if (tid < 0) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return threads.get(info.getThreadId());
|
||||||
}
|
}
|
||||||
DebugSystemObjects so = getSystemObjects();
|
|
||||||
int tid = so.getCurrentThreadSystemId();
|
|
||||||
if (tid < 0) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return threads.get(info.getThreadId());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public DbgProcessImpl getCurrentProcess() {
|
public DbgProcessImpl getCurrentProcess() {
|
||||||
DebugEventInformation info = getLastEventInformation();
|
synchronized (processes) {
|
||||||
if (info == null) {
|
DebugEventInformation info = getLastEventInformation();
|
||||||
return null;
|
if (info == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return processes.get(info.getProcessId());
|
||||||
}
|
}
|
||||||
return processes.get(info.getProcessId());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public DbgSessionImpl getCurrentSession() {
|
public DbgSessionImpl getCurrentSession() {
|
||||||
DebugEventInformation info = getLastEventInformation();
|
synchronized (sessions) {
|
||||||
if (info == null) {
|
DebugEventInformation info = getLastEventInformation();
|
||||||
return null;
|
if (info == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return sessions.get(info.getSessionId());
|
||||||
}
|
}
|
||||||
return sessions.get(info.getSessionId());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public DbgThreadImpl getEventThread() {
|
public DbgThreadImpl getEventThread() {
|
||||||
DebugSystemObjects so = getSystemObjects();
|
synchronized (threads) {
|
||||||
DebugThreadId id = so.getEventThread();
|
DebugSystemObjects so = getSystemObjects();
|
||||||
return threads.get(id);
|
DebugThreadId id = so.getEventThread();
|
||||||
|
return threads.get(id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public DbgProcessImpl getEventProcess() {
|
public DbgProcessImpl getEventProcess() {
|
||||||
DebugSystemObjects so = getSystemObjects();
|
synchronized (processes) {
|
||||||
DebugProcessId id = so.getEventProcess();
|
DebugSystemObjects so = getSystemObjects();
|
||||||
return processes.get(id);
|
DebugProcessId id = so.getEventProcess();
|
||||||
|
return processes.get(id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public DbgSessionImpl getEventSession() {
|
public DbgSessionImpl getEventSession() {
|
||||||
DebugSystemObjects so = getSystemObjects();
|
synchronized (sessions) {
|
||||||
DebugSessionId id = so.getEventSystem();
|
DebugSystemObjects so = getSystemObjects();
|
||||||
return sessions.get(id);
|
DebugSessionId id = so.getEventSystem();
|
||||||
|
return sessions.get(id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public CompletableFuture<Void> selectThread(DbgThreadImpl thread) {
|
public CompletableFuture<Void> selectThread(DbgThreadImpl thread) {
|
||||||
|
|
|
@ -63,8 +63,6 @@ public class DbgProcessImpl implements DbgProcess {
|
||||||
this.manager = manager;
|
this.manager = manager;
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.pid = pid;
|
this.pid = pid;
|
||||||
manager.processes.put(id, this);
|
|
||||||
manager.getEventListeners().fire.processAdded(this, DbgCause.Causes.UNCLAIMED);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public DbgProcessImpl(DbgManagerImpl manager) {
|
public DbgProcessImpl(DbgManagerImpl manager) {
|
||||||
|
@ -109,7 +107,9 @@ public class DbgProcessImpl implements DbgProcess {
|
||||||
*
|
*
|
||||||
* @param cause the cause of the new inferior
|
* @param cause the cause of the new inferior
|
||||||
*/
|
*/
|
||||||
public void add(DbgCause cause) {
|
public void add() {
|
||||||
|
manager.processes.put(id, this);
|
||||||
|
manager.getEventListeners().fire.processAdded(this, DbgCause.Causes.UNCLAIMED);
|
||||||
//manager.addProcess(this, cause);
|
//manager.addProcess(this, cause);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,8 +42,6 @@ public class DbgSessionImpl implements DbgSession {
|
||||||
public DbgSessionImpl(DbgManagerImpl manager, DebugSessionId id) {
|
public DbgSessionImpl(DbgManagerImpl manager, DebugSessionId id) {
|
||||||
this.manager = manager;
|
this.manager = manager;
|
||||||
this.id = id;
|
this.id = id;
|
||||||
manager.sessions.put(id, this);
|
|
||||||
manager.getEventListeners().fire.sessionAdded(this, DbgCause.Causes.UNCLAIMED);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public DbgSessionImpl(DbgManagerImpl manager) {
|
public DbgSessionImpl(DbgManagerImpl manager) {
|
||||||
|
@ -83,7 +81,9 @@ public class DbgSessionImpl implements DbgSession {
|
||||||
*
|
*
|
||||||
* @param cause the cause of the new inferior
|
* @param cause the cause of the new inferior
|
||||||
*/
|
*/
|
||||||
public void add(DbgCause cause) {
|
public void add() {
|
||||||
|
manager.sessions.put(id, this);
|
||||||
|
manager.getEventListeners().fire.sessionAdded(this, DbgCause.Causes.UNCLAIMED);
|
||||||
//manager.addSession(this, cause);
|
//manager.addSession(this, cause);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -64,14 +64,6 @@ public class DbgThreadImpl implements DbgThread {
|
||||||
this.process = process;
|
this.process = process;
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.tid = tid;
|
this.tid = tid;
|
||||||
manager.threads.put(id, this);
|
|
||||||
manager.getEventListeners().fire.threadCreated(this, DbgCause.Causes.UNCLAIMED);
|
|
||||||
}
|
|
||||||
|
|
||||||
public DbgThreadImpl(DbgManagerImpl manager, DbgProcessImpl process, DebugThreadId id, long tid,
|
|
||||||
DebugEventInformation info) {
|
|
||||||
this(manager, process, id, tid);
|
|
||||||
this.setInfo(info);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -98,6 +90,8 @@ public class DbgThreadImpl implements DbgThread {
|
||||||
* Add this thread to the inferior and manager
|
* Add this thread to the inferior and manager
|
||||||
*/
|
*/
|
||||||
public void add() {
|
public void add() {
|
||||||
|
manager.threads.put(id, this);
|
||||||
|
manager.getEventListeners().fire.threadCreated(this, DbgCause.Causes.UNCLAIMED);
|
||||||
process.addThread(this);
|
process.addThread(this);
|
||||||
state.addChangeListener((oldState, newState, pair) -> {
|
state.addChangeListener((oldState, newState, pair) -> {
|
||||||
this.manager.getEventListeners().fire.threadStateChanged(this, newState, pair.cause,
|
this.manager.getEventListeners().fire.threadStateChanged(this, newState, pair.cause,
|
||||||
|
|
|
@ -19,7 +19,6 @@ import java.io.IOException;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
import agent.dbgeng.dbgeng.DebugSessionId;
|
import agent.dbgeng.dbgeng.DebugSessionId;
|
||||||
import agent.dbgeng.manager.DbgCause.Causes;
|
|
||||||
import agent.dbgeng.manager.DbgManager;
|
import agent.dbgeng.manager.DbgManager;
|
||||||
import agent.dbgeng.manager.impl.DbgManagerImpl;
|
import agent.dbgeng.manager.impl.DbgManagerImpl;
|
||||||
import agent.dbgeng.manager.impl.DbgSessionImpl;
|
import agent.dbgeng.manager.impl.DbgSessionImpl;
|
||||||
|
@ -51,7 +50,7 @@ public class DbgModelImpl extends AbstractDbgModel {
|
||||||
this.root = new DbgModelTargetRootImpl(this);
|
this.root = new DbgModelTargetRootImpl(this);
|
||||||
this.completedRoot = CompletableFuture.completedFuture(root);
|
this.completedRoot = CompletableFuture.completedFuture(root);
|
||||||
DbgSessionImpl s = new DbgSessionImpl((DbgManagerImpl) dbg, new DebugSessionId(0));
|
DbgSessionImpl s = new DbgSessionImpl((DbgManagerImpl) dbg, new DebugSessionId(0));
|
||||||
s.add(Causes.UNCLAIMED);
|
s.add();
|
||||||
DbgModelTargetSessionContainer sessions = root.sessions;
|
DbgModelTargetSessionContainer sessions = root.sessions;
|
||||||
this.session = (DbgModelTargetSessionImpl) sessions.getTargetSession(s);
|
this.session = (DbgModelTargetSessionImpl) sessions.getTargetSession(s);
|
||||||
}
|
}
|
||||||
|
|
|
@ -120,14 +120,18 @@ public class DbgManager2Impl extends DbgManagerImpl {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DbgProcessImpl getCurrentProcess() {
|
public DbgProcessImpl getCurrentProcess() {
|
||||||
DebugProcessId id = getSystemObjects().getCurrentProcessId();
|
synchronized (processes) {
|
||||||
return processes.get(id);
|
DebugProcessId id = getSystemObjects().getCurrentProcessId();
|
||||||
|
return processes.get(id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DbgThreadImpl getCurrentThread() {
|
public DbgThreadImpl getCurrentThread() {
|
||||||
DebugThreadId id = getSystemObjects().getCurrentThreadId();
|
synchronized (threads) {
|
||||||
return threads.get(id);
|
DebugThreadId id = getSystemObjects().getCurrentThreadId();
|
||||||
|
return threads.get(id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue