注入方式的锁分析

This commit is contained in:
Your Name 2022-11-22 17:37:56 +08:00
parent 1491ef3061
commit 0b2723f90f
5 changed files with 17 additions and 18 deletions

View File

@ -4,15 +4,9 @@ ARCH=`arch`
DIR=`dirname $0` DIR=`dirname $0`
BINLOADER=$DIR/${ARCH}/binloader BINLOADER=$DIR/${ARCH}/binloader
if [ -n "`ps -ef | grep deadlockcheck | grep -v grep`" ];then # if [ -n "`ps -ef | grep deadlockcheck | grep -v grep`" ];then
exit 99 # exit 100
fi # 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 [ $# -lt 1 ];then if [ $# -lt 1 ];then
# echo "Error params" # echo "Error params"

Binary file not shown.

Binary file not shown.

View File

@ -16,8 +16,8 @@ var isNotSupport = false;
const arch = archs.get(process.arch); const arch = archs.get(process.arch);
const binLoader: string = join(dirname(__dirname), "detect-tools/bincheck_loader.sh"); const binLoader: string = join(dirname(__dirname), "detect-tools/bincheck_loader.sh");
const hijackLib: 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", ""); const hijackTool: string = join(dirname(__dirname), "detect-tools", arch? arch : "x86_64", "detectlock");
interface DetectTaskDefinition extends vscode.TaskDefinition { interface DetectTaskDefinition extends vscode.TaskDefinition {
command: string; command: string;
@ -141,7 +141,7 @@ class CustomBuildTaskTerminal implements vscode.Pseudoterminal {
private hijackCheck(){ private hijackCheck(){
// 注入方式 // 注入方式
child.exec(`${hijackTool} ${this.checkedPid}`, (err, o, e)=>{ child.exec(`${hijackTool} ${this.checkedPid}`, (err, o, e)=>{
if(o.match(/normal/)?.length){ if(o.match(/normal|deadlock/)?.length){
const webPanel = vscode.window.createWebviewPanel( const webPanel = vscode.window.createWebviewPanel(
'detectResultWebview', 'detectResultWebview',
"检测结果", "检测结果",
@ -198,6 +198,9 @@ class CustomBuildTaskTerminal implements vscode.Pseudoterminal {
this.cmd.on('exit', (code) =>{ this.cmd.on('exit', (code) =>{
let errmsg = ""; let errmsg = "";
switch (code) { switch (code) {
case 100:
errmsg = "正在检测请稍后";
break;
case 101: case 101:
errmsg = "待检测可执行程序不能为空 !"; errmsg = "待检测可执行程序不能为空 !";
break; break;

View File

@ -143,9 +143,6 @@ export function activate(context: vscode.ExtensionContext) {
panel.webview.html = getWebViewContent(context, 'dist/index.html'); panel.webview.html = getWebViewContent(context, 'dist/index.html');
}); });
// 进程锁分析 // 进程锁分析
let disposable0 = vscode.commands.registerCommand('deadlock-detect.analysepid',()=>{
doLocalPidLockAnalyse(context);
});
exec(`which sshpass`, (e, o, err)=>{ exec(`which sshpass`, (e, o, err)=>{
if(e){ if(e){
vscode.window.showWarningMessage('当前环境缺失sshpass工具,C/C++程序远程死锁检测功能受限,请执行 sudo apt install sshpass 安装.'); vscode.window.showWarningMessage('当前环境缺失sshpass工具,C/C++程序远程死锁检测功能受限,请执行 sudo apt install sshpass 安装.');
@ -169,18 +166,23 @@ export function activate(context: vscode.ExtensionContext) {
if(err){ if(err){
isNotSupport = true; isNotSupport = true;
}else{ }else{
var str = buffer.toString(); // var str = buffer.toString();
kernelOptions.forEach(elem=>{ kernelOptions.forEach(elem=>{
if(!str.includes(elem)){ if(!buffer.includes(elem)){
isNotSupport = true; 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(); 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)); 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 // this method is called when your extension is deactivated