修改进程锁分析模块
This commit is contained in:
parent
bc916e1153
commit
d40a0fdb3d
Binary file not shown.
Binary file not shown.
|
@ -31,10 +31,6 @@
|
|||
{
|
||||
"command": "deadlock-detect.analysepid",
|
||||
"title": "C/C++程序进程锁分析"
|
||||
},
|
||||
{
|
||||
"command": "deadlock-detect.analyseremotepid",
|
||||
"title": "C/C++程序远程进程锁分析"
|
||||
}
|
||||
],
|
||||
"taskDefinitions": [
|
||||
|
|
|
@ -20,7 +20,7 @@ function execCheckTool(pwd: string, checkedPid: number, cb: (code: number, da:st
|
|||
});
|
||||
}
|
||||
|
||||
function createTerm(checkedPid:number, passwd: string, task: child.ChildProcess): vscode.Pseudoterminal {
|
||||
function createTerm(checkedPid:number, passwd: string): vscode.Pseudoterminal {
|
||||
const writeEmitter = new vscode.EventEmitter<string>();
|
||||
const closeEmitter = new vscode.EventEmitter<number>();
|
||||
const pty: vscode.Pseudoterminal = {
|
||||
|
@ -34,15 +34,15 @@ function createTerm(checkedPid:number, passwd: string, task: child.ChildProcess)
|
|||
intervalObj = setInterval(intervalFunc, 1500, writeEmitter);
|
||||
},
|
||||
close: () => {
|
||||
child.execSync(`echo ${passwd} | sudo -S killall -2 deadlockcheck`);
|
||||
child.exec(`echo ${passwd} | sudo -S killall -2 deadlockcheck`);
|
||||
closeEmitter.fire(0);
|
||||
},
|
||||
handleInput: data => {
|
||||
if (data === 'q') {
|
||||
writeEmitter.fire(`\r\n停止进程${checkedPid}锁分析\r\n`);
|
||||
writeEmitter.fire(`\r\n已停止进程${checkedPid}锁分析\r\n`);
|
||||
clearInterval(intervalObj);
|
||||
console.log(task.pid);
|
||||
child.execSync(`echo ${passwd} | sudo -S killall -2 deadlockcheck`);
|
||||
child.exec(`echo ${passwd} | sudo -S killall -2 deadlockcheck`);
|
||||
closeEmitter.fire(0);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -81,11 +81,17 @@ function localPidAnalyse(pid: number, passwd:string, context: vscode.ExtensionCo
|
|||
vscode.window.showWarningMessage(`${pid}进程检测程序无法识别`);
|
||||
return;
|
||||
}
|
||||
let task = execDetect(passwd, pthreadlib[0], pid, (out2)=>{
|
||||
if(out2.length ===0){
|
||||
var pty = createTerm(pid, passwd);
|
||||
vscode.window.createTerminal({name:`检测进程 ${pid}`, pty}).show();
|
||||
execDetect(passwd, pthreadlib[0], pid, (out2)=>{
|
||||
if(out2.length === 0){
|
||||
vscode.window.showWarningMessage(`未检测到进程${pid}相关锁信息`);
|
||||
return;
|
||||
}
|
||||
if(out2.match(/warn/)?.length){
|
||||
vscode.window.showWarningMessage(`被检测进程${pid}已退出`);
|
||||
pty.close();
|
||||
}
|
||||
if(out2.match(/fatal/)?.length){
|
||||
vscode.window.showWarningMessage("被检测程序存在严重问题!");
|
||||
}else if(out2.match(/deadlock/)?.length){
|
||||
|
@ -101,33 +107,17 @@ function localPidAnalyse(pid: number, passwd:string, context: vscode.ExtensionCo
|
|||
retainContextWhenHidden: true,
|
||||
}
|
||||
);
|
||||
console.log(out2);
|
||||
webPanel.webview.html = prase_yaml2html(pthreadlib[1], context.extensionPath, webPanel.webview, out2);
|
||||
}else{
|
||||
vscode.window.showInformationMessage("未检测到相关锁信息");
|
||||
}
|
||||
});
|
||||
var pty = createTerm(pid, passwd, task);
|
||||
vscode.window.createTerminal({name:`检测进程 ${pid}`, pty}).show();
|
||||
});
|
||||
}
|
||||
|
||||
function remotePidAnalyse(pid: number, userAndhost: string, passwd: string) {
|
||||
var cmd: child.ChildProcessWithoutNullStreams;
|
||||
cmd = child.spawn(checkTool, [pid.toString()]);
|
||||
cmd.on("error", (err)=>{
|
||||
|
||||
});
|
||||
|
||||
cmd.stderr.on("data", (data)=>{
|
||||
|
||||
});
|
||||
cmd.stdout.on("data", (data)=>{
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
// 本地进程锁分析
|
||||
export function DoLocalPidLockAnalyse(context: vscode.ExtensionContext) {
|
||||
export function doLocalPidLockAnalyse(context: vscode.ExtensionContext) {
|
||||
vscode.window.showInputBox({
|
||||
ignoreFocusOut:true, // 默认false,设置为true时鼠标点击别的地方输入框不会消失
|
||||
placeHolder:'请输入本地进程PID', // 在输入框内的提示信息
|
||||
|
@ -164,14 +154,9 @@ export function DoLocalPidLockAnalyse(context: vscode.ExtensionContext) {
|
|||
return;
|
||||
}
|
||||
localPidAnalyse(pid, data, context);
|
||||
})
|
||||
});
|
||||
});
|
||||
});
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// 远程进程锁分析
|
||||
export function DoRemotePidLockAnalyse(context: vscode.ExtensionContext) {
|
||||
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ import {DetectTaskProvider} from './detectTaskProvider';
|
|||
import { homedir } from 'os';
|
||||
import {exec} from 'child_process';
|
||||
import {testPwd} from './utils';
|
||||
import {DoLocalPidLockAnalyse, DoRemotePidLockAnalyse} from './analysePid';
|
||||
import {doLocalPidLockAnalyse} from './analysePid';
|
||||
// linux命令操作模块
|
||||
var child = require('child_process');
|
||||
const { pid } = require('process');
|
||||
|
@ -143,12 +143,8 @@ export function activate(context: vscode.ExtensionContext) {
|
|||
panel.webview.html = getWebViewContent(context, 'dist/index.html');
|
||||
});
|
||||
// 进程锁分析
|
||||
let disposable0 = vscode.commands.registerCommand('deadlock-detect.analysepid',(context)=>{
|
||||
DoLocalPidLockAnalyse(context);
|
||||
});
|
||||
// 远程进程锁分析
|
||||
let disposable1 = vscode.commands.registerCommand('deadlock-detect.analyseremotepid',(context)=>{
|
||||
DoRemotePidLockAnalyse(context);
|
||||
let disposable0 = vscode.commands.registerCommand('deadlock-detect.analysepid',()=>{
|
||||
doLocalPidLockAnalyse(context);
|
||||
});
|
||||
exec(`which sshpass`, (e, o, err)=>{
|
||||
if(e){
|
||||
|
@ -170,7 +166,7 @@ export function activate(context: vscode.ExtensionContext) {
|
|||
detectTaskProvider = vscode.tasks.registerTaskProvider(DetectTaskProvider.customBuildScriptType, new DetectTaskProvider(workspaceRoot, context));
|
||||
});
|
||||
});
|
||||
context.subscriptions.push(...[disposable,disposable0,disposable1]);
|
||||
context.subscriptions.push(...[disposable,disposable0]);
|
||||
}
|
||||
|
||||
// this method is called when your extension is deactivated
|
||||
|
|
|
@ -400,14 +400,12 @@ export function prase_yaml2html(cmd: string, uri: string, webView: vscode.Webvie
|
|||
let ymlObj = YAML.parse(str);
|
||||
const diskPath = vscode.Uri.file(join(uri, 'static', 'echarts.min.js'));
|
||||
const scriptUri = diskPath.with({ scheme: 'vscode-resource' }).toString();
|
||||
if(ymlObj.warn){
|
||||
if(ymlObj.normalInfo?.mutex){
|
||||
let sinfoList:SourceInfo[] = [];
|
||||
let dimensionsList:string[] = [];
|
||||
let seriesList: object[] = [];
|
||||
let miStr = parse_mutexInfo(ymlObj.normalInfo.mutex, sinfoList, dimensionsList, seriesList);
|
||||
return product_normalinfo_to_html(cmd, scriptUri, miStr, dimensionsList, sinfoList, seriesList);
|
||||
}
|
||||
if(ymlObj.normalInfo?.mutex){
|
||||
let sinfoList:SourceInfo[] = [];
|
||||
let dimensionsList:string[] = [];
|
||||
let seriesList: object[] = [];
|
||||
let miStr = parse_mutexInfo(ymlObj.normalInfo.mutex, sinfoList, dimensionsList, seriesList);
|
||||
return product_normalinfo_to_html(cmd, scriptUri, miStr, dimensionsList, sinfoList, seriesList);
|
||||
}
|
||||
if(ymlObj.fatal){
|
||||
return product_fatalinfo_to_html(cmd, parse_fatalInfo(ymlObj.fatal));
|
||||
|
|
Loading…
Reference in New Issue