mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-18 22:08:53 +08:00
refactor(debugger): Locally allocate euControl variable in thread ctrl
Avoids possible unique_ptr memory escape after free Signed-off-by: Brandon Yates <brandon.yates@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
5c5fe1f0cf
commit
e01d34741d
@@ -636,8 +636,13 @@ void DebugSessionLinuxXe::handleAttentionEvent(drm_xe_eudebug_event_eu_attention
|
||||
return updateStoppedThreadsAndCheckTriggerEvents(attentionEventFields, 0, threadsWithAttention);
|
||||
}
|
||||
|
||||
int DebugSessionLinuxXe::threadControlInterruptAll(drm_xe_eudebug_eu_control &euControl) {
|
||||
int DebugSessionLinuxXe::threadControlInterruptAll() {
|
||||
int euControlRetVal = -1;
|
||||
struct drm_xe_eudebug_eu_control euControl = {};
|
||||
euControl.client_handle = clientHandle;
|
||||
euControl.cmd = DRM_XE_EUDEBUG_EU_CONTROL_CMD_INTERRUPT_ALL;
|
||||
euControl.bitmask_size = 0;
|
||||
euControl.bitmask_ptr = 0;
|
||||
|
||||
DEBUG_BREAK_IF(clientHandleToConnection.find(clientHandle) == clientHandleToConnection.end());
|
||||
std::lock_guard<std::mutex> lock(asyncThreadMutex);
|
||||
@@ -662,10 +667,13 @@ int DebugSessionLinuxXe::threadControlInterruptAll(drm_xe_eudebug_eu_control &eu
|
||||
return euControlRetVal;
|
||||
}
|
||||
|
||||
int DebugSessionLinuxXe::threadControlStopped(drm_xe_eudebug_eu_control &euControl, std::unique_ptr<uint8_t[]> &bitmaskOut, size_t &bitmaskSizeOut) {
|
||||
int DebugSessionLinuxXe::threadControlStopped(std::unique_ptr<uint8_t[]> &bitmaskOut, size_t &bitmaskSizeOut) {
|
||||
int euControlRetVal = -1;
|
||||
auto hwInfo = connectedDevice->getHwInfo();
|
||||
auto &l0GfxCoreHelper = connectedDevice->getL0GfxCoreHelper();
|
||||
struct drm_xe_eudebug_eu_control euControl = {};
|
||||
euControl.client_handle = clientHandle;
|
||||
euControl.cmd = DRM_XE_EUDEBUG_EU_CONTROL_CMD_STOPPED;
|
||||
|
||||
std::unique_ptr<uint8_t[]> bitmask;
|
||||
size_t bitmaskSize = 0;
|
||||
@@ -702,10 +710,15 @@ int DebugSessionLinuxXe::threadControlStopped(drm_xe_eudebug_eu_control &euContr
|
||||
return euControlRetVal;
|
||||
}
|
||||
|
||||
int DebugSessionLinuxXe::threadControlResume(const std::vector<EuThread::ThreadId> &threads, drm_xe_eudebug_eu_control &euControl) {
|
||||
int DebugSessionLinuxXe::threadControlResume(const std::vector<EuThread::ThreadId> &threads) {
|
||||
int euControlRetVal = -1;
|
||||
auto hwInfo = connectedDevice->getHwInfo();
|
||||
auto &l0GfxCoreHelper = connectedDevice->getL0GfxCoreHelper();
|
||||
struct drm_xe_eudebug_eu_control euControl = {};
|
||||
euControl.client_handle = clientHandle;
|
||||
euControl.bitmask_size = 0;
|
||||
euControl.bitmask_ptr = 0;
|
||||
euControl.cmd = DRM_XE_EUDEBUG_EU_CONTROL_CMD_RESUME;
|
||||
|
||||
std::unique_ptr<uint8_t[]> bitmask;
|
||||
size_t bitmaskSize = 0;
|
||||
@@ -736,21 +749,13 @@ int DebugSessionLinuxXe::threadControl(const std::vector<EuThread::ThreadId> &th
|
||||
ThreadControlCmd threadCmd, std::unique_ptr<uint8_t[]> &bitmaskOut, size_t &bitmaskSizeOut) {
|
||||
|
||||
bitmaskSizeOut = 0;
|
||||
struct drm_xe_eudebug_eu_control euControl = {};
|
||||
euControl.client_handle = clientHandle;
|
||||
euControl.bitmask_size = 0;
|
||||
euControl.bitmask_ptr = 0;
|
||||
|
||||
switch (threadCmd) {
|
||||
case ThreadControlCmd::interruptAll:
|
||||
euControl.cmd = DRM_XE_EUDEBUG_EU_CONTROL_CMD_INTERRUPT_ALL;
|
||||
return threadControlInterruptAll(euControl);
|
||||
return threadControlInterruptAll();
|
||||
case ThreadControlCmd::resume:
|
||||
euControl.cmd = DRM_XE_EUDEBUG_EU_CONTROL_CMD_RESUME;
|
||||
return threadControlResume(threads, euControl);
|
||||
return threadControlResume(threads);
|
||||
case ThreadControlCmd::stopped:
|
||||
euControl.cmd = DRM_XE_EUDEBUG_EU_CONTROL_CMD_STOPPED;
|
||||
return threadControlStopped(euControl, bitmaskOut, bitmaskSizeOut);
|
||||
return threadControlStopped(bitmaskOut, bitmaskSizeOut);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -64,9 +64,9 @@ struct DebugSessionLinuxXe : DebugSessionLinux {
|
||||
|
||||
protected:
|
||||
int threadControl(const std::vector<EuThread::ThreadId> &threads, uint32_t tile, ThreadControlCmd threadCmd, std::unique_ptr<uint8_t[]> &bitmask, size_t &bitmaskSize) override;
|
||||
int threadControlInterruptAll(drm_xe_eudebug_eu_control &euControl);
|
||||
int threadControlResume(const std::vector<EuThread::ThreadId> &threads, drm_xe_eudebug_eu_control &euControl);
|
||||
int threadControlStopped(drm_xe_eudebug_eu_control &euControl, std::unique_ptr<uint8_t[]> &bitmaskOut, size_t &bitmaskSizeOut);
|
||||
int threadControlInterruptAll();
|
||||
int threadControlResume(const std::vector<EuThread::ThreadId> &threads);
|
||||
int threadControlStopped(std::unique_ptr<uint8_t[]> &bitmaskOut, size_t &bitmaskSizeOut);
|
||||
MOCKABLE_VIRTUAL void handleAttentionEvent(drm_xe_eudebug_event_eu_attention *attention);
|
||||
void handleMetadataEvent(drm_xe_eudebug_event_metadata *pMetaData);
|
||||
bool handleMetadataOpEvent(drm_xe_eudebug_event_vm_bind_op_metadata *vmBindOpMetadata);
|
||||
|
||||
Reference in New Issue
Block a user