增加死锁环路判断及进程是否正在被gdb调试判断
This commit is contained in:
parent
c10f311cf0
commit
2282b85bb1
Binary file not shown.
Binary file not shown.
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -5,7 +5,7 @@
|
|||
<link rel="icon" href="/favicon.ico" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Vite App</title>
|
||||
<script type="module" crossorigin src="/assets/index.f4f02362.js"></script>
|
||||
<script type="module" crossorigin src="/assets/index.1ae65bd5.js"></script>
|
||||
<link rel="stylesheet" href="/assets/index.2ee78ff5.css">
|
||||
<script type="module">try{import("_").catch(()=>1);}catch(e){}window.__vite_is_dynamic_import_support=true;</script>
|
||||
<script type="module">!function(){if(window.__vite_is_dynamic_import_support)return;console.warn("vite: loading legacy build because dynamic import is unsupported, syntax error above should be ignored");var e=document.getElementById("vite-legacy-polyfill"),n=document.createElement("script");n.src=e.src,n.onload=function(){System.import(document.getElementById('vite-legacy-entry').getAttribute('data-src'))},document.body.appendChild(n)}();</script>
|
||||
|
@ -15,6 +15,6 @@
|
|||
|
||||
<script nomodule>!function(){var e=document,t=e.createElement("script");if(!("noModule"in t)&&"onbeforeload"in t){var n=!1;e.addEventListener("beforeload",(function(e){if(e.target===t)n=!0;else if(!e.target.hasAttribute("nomodule")||!n)return;e.preventDefault()}),!0),t.type="module",t.src=".",e.head.appendChild(t),t.remove()}}();</script>
|
||||
<script nomodule id="vite-legacy-polyfill" src="/assets/polyfills-legacy.82d708a7.js"></script>
|
||||
<script nomodule id="vite-legacy-entry" data-src="/assets/index-legacy.5463ca04.js">System.import(document.getElementById('vite-legacy-entry').getAttribute('data-src'))</script>
|
||||
<script nomodule id="vite-legacy-entry" data-src="/assets/index-legacy.9a811587.js">System.import(document.getElementById('vite-legacy-entry').getAttribute('data-src'))</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -3,7 +3,7 @@
|
|||
"displayName": "deadlock-detect",
|
||||
"description": "Deadlock detect for C/C++ program which use the posix thread library for Linux system platform.",
|
||||
"publisher": "KylinIDETeam",
|
||||
"version": "0.2.0",
|
||||
"version": "0.2.2",
|
||||
"engines": {
|
||||
"vscode": "^1.54.0"
|
||||
},
|
||||
|
|
|
@ -606,6 +606,40 @@ export function activate(context: vscode.ExtensionContext) {
|
|||
return "deb";
|
||||
}
|
||||
}
|
||||
function is_gdb_already_attach_the_pid(pid:string):Boolean{
|
||||
let temcmd = `cat ${__dirname}/../detect-tools/.user.pwd | sudo -S gdb -q -p ${pid} -ex "q" 2>&1`;
|
||||
let findstring="is already traced by process"
|
||||
let cmdout = execSync(temcmd).toString();
|
||||
if(cmdout.includes(findstring)){
|
||||
console.log("cmdout is:",cmdout)
|
||||
return true
|
||||
}else{
|
||||
return false
|
||||
}
|
||||
//const { stdout, stderr } = execSync(temcmd,{ encoding: 'utf-8' });
|
||||
|
||||
/*
|
||||
const result = spawnSync(temcmd, {
|
||||
stdio: ['inherit', 'pipe', 'inherit'],
|
||||
shell: true,
|
||||
});
|
||||
if (result.status !== 0) {
|
||||
console.error(`命令执行失败,退出码:${result.status}`);
|
||||
console.error(`错误信息:${result.stderr.toString()}`);
|
||||
return true;
|
||||
} else {
|
||||
console.log(`命令执行成功,输出信息:${result.stdout.toString()}`);
|
||||
const stderr = result.stderr.toString();
|
||||
const mergedStderr = stderr.replace(/\r?\n/g, ' ');
|
||||
console.log("all message is:",mergedStderr)
|
||||
let findstring="is already traced by process"
|
||||
if(mergedStderr.includes(findstring)){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
|
@ -634,7 +668,16 @@ export function activate(context: vscode.ExtensionContext) {
|
|||
//no __lll_lock_wait
|
||||
let isOpenkylin =is_openkylin();//openkylin flag
|
||||
let sys_flag = rpm_or_deb();
|
||||
|
||||
let gdb_using= is_gdb_already_attach_the_pid(form.pid);
|
||||
if (gdb_using == true){
|
||||
vscode.window.showErrorMessage(`进程${form.pid}已被gdb attach,请关闭该gdb attach进程,重新进行检测`);
|
||||
form.using = true;
|
||||
form.success='error';
|
||||
panel.webview.postMessage({
|
||||
res: form});
|
||||
console.log("gdb is in using!!!")
|
||||
return;
|
||||
}
|
||||
if(form.dead_type== 1 && isOpenkylin == false && sys_flag == "deb"){
|
||||
//__lll_lock_wait
|
||||
try{
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -5,7 +5,7 @@
|
|||
<link rel="icon" href="/favicon.ico" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Vite App</title>
|
||||
<script type="module" crossorigin src="/assets/index.f4f02362.js"></script>
|
||||
<script type="module" crossorigin src="/assets/index.1ae65bd5.js"></script>
|
||||
<link rel="stylesheet" href="/assets/index.2ee78ff5.css">
|
||||
<script type="module">try{import("_").catch(()=>1);}catch(e){}window.__vite_is_dynamic_import_support=true;</script>
|
||||
<script type="module">!function(){if(window.__vite_is_dynamic_import_support)return;console.warn("vite: loading legacy build because dynamic import is unsupported, syntax error above should be ignored");var e=document.getElementById("vite-legacy-polyfill"),n=document.createElement("script");n.src=e.src,n.onload=function(){System.import(document.getElementById('vite-legacy-entry').getAttribute('data-src'))},document.body.appendChild(n)}();</script>
|
||||
|
@ -15,6 +15,6 @@
|
|||
|
||||
<script nomodule>!function(){var e=document,t=e.createElement("script");if(!("noModule"in t)&&"onbeforeload"in t){var n=!1;e.addEventListener("beforeload",(function(e){if(e.target===t)n=!0;else if(!e.target.hasAttribute("nomodule")||!n)return;e.preventDefault()}),!0),t.type="module",t.src=".",e.head.appendChild(t),t.remove()}}();</script>
|
||||
<script nomodule id="vite-legacy-polyfill" src="/assets/polyfills-legacy.82d708a7.js"></script>
|
||||
<script nomodule id="vite-legacy-entry" data-src="/assets/index-legacy.5463ca04.js">System.import(document.getElementById('vite-legacy-entry').getAttribute('data-src'))</script>
|
||||
<script nomodule id="vite-legacy-entry" data-src="/assets/index-legacy.9a811587.js">System.import(document.getElementById('vite-legacy-entry').getAttribute('data-src'))</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -293,8 +293,15 @@ export default {
|
|||
|
||||
});
|
||||
}
|
||||
|
||||
if (event.data.res.CmdType == 1) {
|
||||
if(event.data.res.using == true){
|
||||
this.loading1 = false;
|
||||
this.loading2 = false;
|
||||
this.loading3 = false;
|
||||
this.$message({
|
||||
message:'当前进程正在被gdb attach,请确保当前进程没有被gdb调试!!',
|
||||
});
|
||||
}else{
|
||||
if (event.data.res.CmdType == 1) {
|
||||
if(this.c_dead_type == 3){
|
||||
if(event.data.res.shuaxin == true){
|
||||
this.local_thread_data = ''
|
||||
|
@ -384,6 +391,17 @@ export default {
|
|||
console.log("读写锁死锁:",this.thread_info)
|
||||
let echartsData=this.getdeadgraphData(this.thread_info);
|
||||
this.deadgraph(echartsData);
|
||||
let cirle_deadlock = this.hasDeadlock1(this.thread_info);
|
||||
/* */
|
||||
if(cirle_deadlock){
|
||||
this.$message({
|
||||
message: "发现读写锁死锁(严格意义的环路死锁)!",
|
||||
})
|
||||
}else{
|
||||
this.$message({
|
||||
message: "发现读写锁死锁(无环路,长时间占用未释放)!",
|
||||
})
|
||||
}
|
||||
/* */
|
||||
this.$message({
|
||||
message: "发现读写锁死锁!",
|
||||
|
@ -443,10 +461,17 @@ export default {
|
|||
console.log("互斥锁死锁:",this.thread_info)
|
||||
let echartsData=this.getdeadgraphData(this.thread_info);
|
||||
this.deadgraph(echartsData);
|
||||
let cirle_deadlock = this.hasDeadlock1(this.thread_info);
|
||||
/* */
|
||||
this.$message({
|
||||
message: "发现互斥锁死锁!",
|
||||
if(cirle_deadlock){
|
||||
this.$message({
|
||||
message: "发现互斥锁死锁(严格意义的环路死锁)!",
|
||||
})
|
||||
}else{
|
||||
this.$message({
|
||||
message: "发现互斥锁死锁(无环路,长时间占用未释放)!",
|
||||
})
|
||||
}
|
||||
}else{
|
||||
console.log("未发现互斥锁死锁:",this.local_thread_data)
|
||||
this.$message({
|
||||
|
@ -461,6 +486,17 @@ export default {
|
|||
|
||||
if(event.data.res.success=='success'){
|
||||
this.drawDeadGraph(event.data.res.data);
|
||||
let cirle_deadlock = this.hasDeadlock1(this.thread_info);
|
||||
/* */
|
||||
if(cirle_deadlock){
|
||||
this.$message({
|
||||
message: "发现互斥锁死锁(严格意义的环路死锁)!",
|
||||
})
|
||||
}else{
|
||||
this.$message({
|
||||
message: "发现互斥锁死锁(无环路,长时间占用未释放)!",
|
||||
})
|
||||
}
|
||||
}else{
|
||||
if(event.data.res.shuaxin == true){
|
||||
this.local_thread_data = ''
|
||||
|
@ -481,8 +517,8 @@ export default {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (event.data.res.CmdType == 3) {
|
||||
}
|
||||
else if (event.data.res.CmdType == 3) {
|
||||
//remote detect
|
||||
if(event.data.res.openkylin){
|
||||
this.$message({
|
||||
|
@ -513,7 +549,7 @@ export default {
|
|||
}
|
||||
}
|
||||
}
|
||||
}else if(event.data.res.CmdType == 5){
|
||||
}else if(event.data.res.CmdType == 5){
|
||||
//java deadlock info
|
||||
if(event.data.res.shuaxin==true){
|
||||
|
||||
|
@ -536,6 +572,7 @@ export default {
|
|||
console.log("start to process the java data")
|
||||
this.javalockInfoInit(event.data.res.data,event.data.res.arch);
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
|
@ -1555,8 +1592,117 @@ export default {
|
|||
};
|
||||
option && myChart.setOption(option);
|
||||
this.loading3 = false;//java
|
||||
}
|
||||
},
|
||||
//lockowner
|
||||
hasDeadlock(lockList) {
|
||||
// 构造有向图
|
||||
const graph = {};
|
||||
for (const lock of lockList) {
|
||||
const threadId = lock.threadID;
|
||||
const lockId = lock.lockID;
|
||||
const ownId = lock.lockowner;
|
||||
if (!graph[threadId]) {
|
||||
graph[threadId] = new Set();
|
||||
}
|
||||
if (!graph[lockId]) {
|
||||
graph[lockId] = new Set();
|
||||
}
|
||||
if (!graph[ownId]) {
|
||||
graph[ownId] = new Set();
|
||||
}
|
||||
graph[threadId].add(lockId);
|
||||
graph[lockId].add(ownId);
|
||||
graph[ownId].add(lockId);
|
||||
}
|
||||
|
||||
// 计算入度
|
||||
const indegrees = {};
|
||||
for (const node in graph) {
|
||||
indegrees[node] = 0;
|
||||
}
|
||||
for (const node in graph) {
|
||||
for (const neighbor of graph[node]) {
|
||||
indegrees[neighbor]++;
|
||||
}
|
||||
}
|
||||
|
||||
// 拓扑排序
|
||||
const queue = [];
|
||||
for (const node in indegrees) {
|
||||
if (indegrees[node] === 0) {
|
||||
queue.push(node);
|
||||
}
|
||||
}
|
||||
let visited = 0;
|
||||
while (queue.length) {
|
||||
const node = queue.shift();
|
||||
visited++;
|
||||
for (const neighbor of graph[node]) {
|
||||
indegrees[neighbor]--;
|
||||
if (indegrees[neighbor] === 0) {
|
||||
queue.push(neighbor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 判断是否存在环
|
||||
return visited !== Object.keys(graph).length;
|
||||
},
|
||||
//ownID
|
||||
hasDeadlock1(lockList) {
|
||||
// 构造有向图
|
||||
const graph = {};
|
||||
for (const lock of lockList) {
|
||||
const threadId = lock.threadID;
|
||||
const lockId = lock.lockID;
|
||||
const ownId = lock.ownID;
|
||||
if (!graph[threadId]) {
|
||||
graph[threadId] = new Set();
|
||||
}
|
||||
if (!graph[lockId]) {
|
||||
graph[lockId] = new Set();
|
||||
}
|
||||
if (!graph[ownId]) {
|
||||
graph[ownId] = new Set();
|
||||
}
|
||||
graph[threadId].add(lockId);
|
||||
graph[lockId].add(ownId);
|
||||
graph[ownId].add(lockId);
|
||||
}
|
||||
|
||||
// 计算入度
|
||||
const indegrees = {};
|
||||
for (const node in graph) {
|
||||
indegrees[node] = 0;
|
||||
}
|
||||
for (const node in graph) {
|
||||
for (const neighbor of graph[node]) {
|
||||
indegrees[neighbor]++;
|
||||
}
|
||||
}
|
||||
|
||||
// 拓扑排序
|
||||
const queue = [];
|
||||
for (const node in indegrees) {
|
||||
if (indegrees[node] === 0) {
|
||||
queue.push(node);
|
||||
}
|
||||
}
|
||||
let visited = 0;
|
||||
while (queue.length) {
|
||||
const node = queue.shift();
|
||||
visited++;
|
||||
for (const neighbor of graph[node]) {
|
||||
indegrees[neighbor]--;
|
||||
if (indegrees[neighbor] === 0) {
|
||||
queue.push(neighbor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 判断是否存在环
|
||||
return visited !== Object.keys(graph).length;
|
||||
},
|
||||
}//methods
|
||||
};
|
||||
</script>
|
||||
|
|
Loading…
Reference in New Issue