diff --git a/detect-plugin/detect-tools/bincheck_loader.sh b/detect-plugin/detect-tools/bincheck_loader.sh index d2a42e0b..85763fcc 100755 --- a/detect-plugin/detect-tools/bincheck_loader.sh +++ b/detect-plugin/detect-tools/bincheck_loader.sh @@ -4,15 +4,9 @@ ARCH=`arch` DIR=`dirname $0` BINLOADER=$DIR/${ARCH}/binloader -if [ -n "`ps -ef | grep deadlockcheck | grep -v grep`" ];then - exit 99 -fi - -SUPPORTBPF=`grep -r "^CONFIG_BPF_EVENTS=" /boot/config-$(uname -r)` -if [ -z "$SUPPORTBPF" ];then - echo "Current Kernel not support ebpf" - exit 100 -fi +# if [ -n "`ps -ef | grep deadlockcheck | grep -v grep`" ];then +# exit 100 +# fi if [ $# -lt 1 ];then # echo "Error params" diff --git a/detect-plugin/detect-tools/x86_64/detectlock b/detect-plugin/detect-tools/x86_64/detectlock new file mode 100755 index 00000000..213c0f67 Binary files /dev/null and b/detect-plugin/detect-tools/x86_64/detectlock differ diff --git a/detect-plugin/detect-tools/x86_64/hijack_pthread.so b/detect-plugin/detect-tools/x86_64/hijack_pthread.so new file mode 100755 index 00000000..6fad8a15 Binary files /dev/null and b/detect-plugin/detect-tools/x86_64/hijack_pthread.so differ diff --git a/detect-plugin/src/detectTaskProvider.ts b/detect-plugin/src/detectTaskProvider.ts index cd4aa096..516623c2 100644 --- a/detect-plugin/src/detectTaskProvider.ts +++ b/detect-plugin/src/detectTaskProvider.ts @@ -16,8 +16,8 @@ var isNotSupport = false; const arch = archs.get(process.arch); const binLoader: string = join(dirname(__dirname), "detect-tools/bincheck_loader.sh"); -const hijackLib: string = join(dirname(__dirname), "detect-tools", arch? arch : "x86_64", ""); -const hijackTool: string = join(dirname(__dirname), "detect-tools", arch? arch : "x86_64", ""); +const hijackLib: string = join(dirname(__dirname), "detect-tools", arch? arch : "x86_64", "hijack_pthread.so"); +const hijackTool: string = join(dirname(__dirname), "detect-tools", arch? arch : "x86_64", "detectlock"); interface DetectTaskDefinition extends vscode.TaskDefinition { command: string; @@ -141,7 +141,7 @@ class CustomBuildTaskTerminal implements vscode.Pseudoterminal { private hijackCheck(){ // 注入方式 child.exec(`${hijackTool} ${this.checkedPid}`, (err, o, e)=>{ - if(o.match(/normal/)?.length){ + if(o.match(/normal|deadlock/)?.length){ const webPanel = vscode.window.createWebviewPanel( 'detectResultWebview', "检测结果", @@ -198,6 +198,9 @@ class CustomBuildTaskTerminal implements vscode.Pseudoterminal { this.cmd.on('exit', (code) =>{ let errmsg = ""; switch (code) { + case 100: + errmsg = "正在检测请稍后"; + break; case 101: errmsg = "待检测可执行程序不能为空 !"; break; diff --git a/detect-plugin/src/extension.ts b/detect-plugin/src/extension.ts index 05cc69e1..d23dd864 100644 --- a/detect-plugin/src/extension.ts +++ b/detect-plugin/src/extension.ts @@ -143,9 +143,6 @@ export function activate(context: vscode.ExtensionContext) { panel.webview.html = getWebViewContent(context, 'dist/index.html'); }); // 进程锁分析 - let disposable0 = vscode.commands.registerCommand('deadlock-detect.analysepid',()=>{ - doLocalPidLockAnalyse(context); - }); exec(`which sshpass`, (e, o, err)=>{ if(e){ vscode.window.showWarningMessage('当前环境缺失sshpass工具,C/C++程序远程死锁检测功能受限,请执行 sudo apt install sshpass 安装.'); @@ -169,18 +166,23 @@ export function activate(context: vscode.ExtensionContext) { if(err){ isNotSupport = true; }else{ - var str = buffer.toString(); + // var str = buffer.toString(); kernelOptions.forEach(elem=>{ - if(!str.includes(elem)){ + if(!buffer.includes(elem)){ isNotSupport = true; } }); } + if(!isNotSupport){ + context.subscriptions.push(vscode.commands.registerCommand('deadlock-detect.analysepid',()=>{ + doLocalPidLockAnalyse(context); + })); + } const workspaceRoot = (vscode.workspace.workspaceFolders && (vscode.workspace.workspaceFolders.length > 0)) ? vscode.workspace.workspaceFolders[0].uri.fsPath : homedir(); detectTaskProvider = vscode.tasks.registerTaskProvider(DetectTaskProvider.customBuildScriptType, new DetectTaskProvider(workspaceRoot, context, isNotSupport)); }); }); - context.subscriptions.push(...[disposable,disposable0]); + context.subscriptions.push(disposable); } // this method is called when your extension is deactivated