Commit 27f70ce5 authored by Oleg Dzhimiev's avatar Oleg Dzhimiev

1. off/on debug

parent 56a0dbca
......@@ -54,17 +54,37 @@ function init(){
var f2 = $("<span title='Include module name in the printed message'>");
var f3 = $("<span title='Include thread ID in messages not generated from interrupt context'>");
var f0_cb = $("<input>",{id:"fflag",type:"checkbox",class:"tp"}).css({position:"relative",top:"3px"});
var f1_cb = $("<input>",{id:"lflag",type:"checkbox",class:"tp"}).css({position:"relative",top:"3px"});
var f2_cb = $("<input>",{id:"mflag",type:"checkbox",class:"tp"}).css({position:"relative",top:"3px"});
var f3_cb = $("<input>",{id:"tflag",type:"checkbox",class:"tp"}).css({position:"relative",top:"3px"});
var f0_cb = $("<input>",{id:"fflag",type:"checkbox",class:"tp flags_cb"}).css({position:"relative",top:"3px"});
var f1_cb = $("<input>",{id:"lflag",type:"checkbox",class:"tp flags_cb"}).css({position:"relative",top:"3px"});
var f2_cb = $("<input>",{id:"mflag",type:"checkbox",class:"tp flags_cb"}).css({position:"relative",top:"3px"});
var f3_cb = $("<input>",{id:"tflag",type:"checkbox",class:"tp flags_cb"}).css({position:"relative",top:"3px"});
f0.html("&nbsp;&nbsp;f&nbsp;").append(f0_cb);
f1.html("&nbsp;l&nbsp;").append(f1_cb);
f2.html("&nbsp;m&nbsp;").append(f2_cb);
f3.html("&nbsp;t&nbsp;").append(f3_cb);
$("body").append($("<div>").css({padding:"0px 0px 10px 0px"}).append(b0).append(b1).append(b2).append(f0).append(f1).append(f2).append(f3));
var b3 = $("<button>",{
title: "Enable/disable debug messages for selected files"
}).css({
margin:"0px 0px 0px 10px"
}).html("Switch off debug").click(function(){
if ($(this).html()=="Switch off debug"){
$(this).html("Switch on debug");
$.ajax({
url: "debugfs.php?cmd=setflag&flag=-p",
queue: true
});
}else{
$(this).html("Switch off debug");
$.ajax({
url: "debugfs.php?cmd=setflag&flag=%2Bp",
queue: true
});
}
});
$("body").append($("<div>").css({padding:"0px 0px 10px 0px"}).append(b0).append(b1).append(b2).append(b3).append(f0).append(f1).append(f2).append(f3));
//list header
var t = $("<table border=\"1\">").html("\
......@@ -126,6 +146,22 @@ function init(){
update_debugfs_config();
});
$(".flags_cb").change(function(){
if ($(this).prop("checked")) sign = "%2B";
else sign = "-";
flag = $(this).attr("id")[0];
$.ajax({
url: "debugfs.php?cmd=setflag&flag="+sign+flag,
queue: true
});
});
//init flags
$(".flags_cb").prop("checked",true);
$(".flags_cb").change();
//when everything is parsed. do something.
// unique IDs
// save config
......@@ -200,10 +236,10 @@ function fill_content_rebind_events(){
var subindex = $(this).attr("subindex");
var flags = "";
if ($("#tflag").prop("checked")) flags += "t";
if ($("#mflag").prop("checked")) flags += "m";
if ($("#lflag").prop("checked")) flags += "l";
if ($("#fflag").prop("checked")) flags += "f";
//if ($("#fflag").prop("checked")) flags += "f";
//if ($("#lflag").prop("checked")) flags += "l";
//if ($("#mflag").prop("checked")) flags += "m";
//if ($("#tflag").prop("checked")) flags += "t";
if ($(this).prop("checked")) flags = "p"+flags;
else flags = "_";
......
......@@ -100,6 +100,7 @@ function update_config($data){
function apply_config_to_control(){
global $tmp_config, $DEBUGFSFILE;
$arr_config = json_decode(file_get_contents($tmp_config),true);
foreach($arr_config as $k0 => $v0){
if ($v0['state']==1){
......@@ -121,26 +122,55 @@ function apply_config_to_control(){
echo "Done";
}
function apply_flag($flag){
global $tmp_config, $DEBUGFSFILE;
//echo "<pre>\n";
$arr_config = json_decode(file_get_contents($tmp_config),true);
foreach($arr_config as $k0 => $v0){
if ($v0['state']==1){
foreach($v0['configs'] as $k1 => $v1){
if ($v1['state']==1){
foreach($v1['lines'] as $k2 => $v2){
$file = $v2['file'];
$lineno = $v2['lineno'];
$cmd = "echo -n 'file $file line $lineno $flag' > $DEBUGFSFILE";
//echo "$cmd\n";
exec($cmd);
//echo "echo -n 'file $file line $lineno ${sign}p'\n";
}
}
}
}
}
echo "Done";
}
function sync_from_debugfs_to_config($file,$line,$flags,$sign){
global $tmp_config;
//$arr_debugfs = get_control("/sys/kernel/debug/dynamic_debug/control");
$arr_config = json_decode(file_get_contents($tmp_config),true);
$err = 0;
$dc = 0; $dcc = 0; $dccc = 0;
foreach($arr_config as $k => $v){
if ($v['file']==$file) {
$dc = $k;
$err = $err + 1;
break;
}
}
echo "DC=$dc\n";
$tmp_arr1 = $arr_config[$dc]['configs'];
foreach($tmp_arr1 as $k => $v){
if ($v['state']==1) {
$dcc = $k;
$err = $err + 2;
break;
}
}
......@@ -150,6 +180,7 @@ function sync_from_debugfs_to_config($file,$line,$flags,$sign){
foreach($tmp_arr2 as $k => $v){
if ($v['lineno']==$line) {
$dccc = $k;
$err = $err + 4;
break;
}
}
......@@ -157,10 +188,14 @@ function sync_from_debugfs_to_config($file,$line,$flags,$sign){
if ($sign=="+") $flag = "p";
else $flag = "_";
$arr_config[$dc]['configs'][$dcc]['lines'][$dccc]['flags'] = $flag;
echo "file index: $dc, config index: $dcc, line index: $dccc \n";
if ($err==7){
$arr_config[$dc]['configs'][$dcc]['lines'][$dccc]['flags'] = $flag;
update_config(json_encode($arr_config));
//print_r($arr_config);
}else{
echo "error code: $err";
}
}
function filter_record_by_file($a,$f){
......@@ -245,6 +280,11 @@ if ($cmd=="reread"){
//echo "<pre>";print_r($filtered);
}
if ($cmd=="setflag"){
$flag = $_GET['flag'];
apply_flag($flag);
}
//single line: echo -n 'file gamma_tables.c +p' > /sys/kernel/debug/dynamic_debug/control
?>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment