注入方式的锁分析

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`
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"

Binary file not shown.

Binary file not shown.

View File

@ -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;

View File

@ -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