Loading src/debugfs-webgui/debugfs.js +187 −83 Original line number Diff line number Diff line Loading @@ -5,7 +5,7 @@ var debugfs_data; function init(){ $("body").html("<h3>DebugFS:</h3>"); $("body").html("<h3>Dynamic Debug, DebugFS:</h3>"); var b0 = $("<button>",{id:"b0"}).html("toggle hidden"); b0.prop("state",0); Loading @@ -17,6 +17,8 @@ function init(){ }else{ $(this).prop("state",0) $(".hidden_rows").hide(); $(".hidden_content").hide(); //$("#content_"+id).hide(); ?! } }); Loading Loading @@ -55,118 +57,220 @@ function init(){ //global debugfs_data = r; var l,content,controls; for(var i=0;i<r.length;i++){ l = $("<tr>",{id:"row_"+i}).html("\ <td class='hidden_rows' style='text-align:center;display:none' >\ <input id='cb_"+i+"' class='tp visibility_cb' type='checkbox'>\ </td>\ <td class='special filename' id='header_"+i+" '>"+r[i].file+"</td>\ "); l = init_ui_file(r[i],i); content = init_ui_content(r[i],i); controls = init_ui_controls(r[i],i); if (r[i].state==0){ l.addClass("hidden_rows").hide(); l.find("input").prop("checked",false); }else{ l.removeClass("hidden_rows").show(); l.find("input").prop("checked",true); t.append(l).append(controls).append(content); var r1 = r[i].configs[0].lines; fill_content(r1,i,content.find("#content_td")); } content = $("<tr>",{ id: "content_"+i }).css({ display: "none", border: "0px solid rgba(255,255,255,0)" }); fill_content_rebind_events(); content.append( $("<td>").addClass("hidden_rows").hide() ).append( $("<td>",{id:"content_td"}) ); $(".filename").click(function(){ var id = $(this).attr("id"); id = id.substr(id.indexOf("_")+1); console.log(id); $("#content_"+id).toggle(); $("#controls_"+id).toggle(); }); //$("<table>").css({margin:"5px"}) $(".visibility_cb").change(function(){ var id = $(this).attr("id"); id = id.substr(id.indexOf("_")+1); if ($(this).prop("checked")){ $("#row_"+id).removeClass("hidden_rows"); $("#content_"+id).removeClass("hidden_content"); $("#controls_"+id).removeClass("hidden_content"); debugfs_data[id].state = 1; }else{ $("#row_"+id).addClass("hidden_rows"); $("#content_"+id).addClass("hidden_content"); $("#controls_"+id).addClass("hidden_content"); debugfs_data[id].state = 0; } update_debugfs_config(); }); //.append($("<td>").addClass("hidden_rows").css({display:"none"})) //when everything is parsed. do something. // unique IDs // save config } }); } t.append(l).append(content); function fill_content(record,index,target){ var r1 = r[i].configs[0].lines; target.html(""); var table_index=0; for (var j=0;j<r1.length;j++){ for (var j=0;j<record.length;j++){ table_index = Math.floor(j/NLINES); //shift because of 'all' checkbox if (j==((table_index+1)*NLINES-1)) table_index++; if (j%2==0) oddeven = "even"; else oddeven = "odd"; //create those tables?! if (content.find("#ctbl_"+table_index).length==0) { if (target.find("#ctbl_"+table_index).length==0) { ctbl = $("<table>",{id:"ctbl_"+table_index}).css({margin:"5px 30px 5px 5px",display:"inline"}); content.find("#content_td").append(ctbl); if (table_index==0){ //add all/none checkbox l = "<tr>"; l += " <td style='text-align:center' title='check/uncheck all'>all</td>"; l += " <td id='all_"+index+"' style='text-align:center'><input title='check flags' type='checkbox' class='tp allornone' /></td>"; l += " <td></td>"; l += " <td></td>"; l += "</tr>"; ctbl.append(l); } target.append(ctbl); } ttl = "module: "+r1[j].module+"\n"; ttl += "function: "+r1[j].function+"\n"; ttl += "format: "+r1[j].format; ttl = "module: "+record[j].module+"\n"; ttl += "function: "+record[j].function+"\n"; ttl += "format: "+record[j].format; if (r1[j].flags=="p"){ if (record[j].flags=="p"){ checked = "checked"; }else{ checked = ""; } if (r1[j].function.length>CUT_STRING_LIMIT) cut_function = "..."; if (record[j].function.length>CUT_STRING_LIMIT) cut_function = "..."; else cut_function = ""; if (r1[j].format.length>CUT_STRING_LIMIT) cut_format = "..."; if (record[j].format.length>CUT_STRING_LIMIT) cut_format = "..."; else cut_format = ""; l = "<tr class='"+oddeven+"'>"; l += " <td style='text-align:center' title='"+ttl+"'>"+r1[j].lineno+"</td>"; l += " <td style='text-align:center'><input title='p-flag' type='checkbox' class='tp debug' "+checked+" file='"+r1[j].file+"' line='"+r1[j].lineno+"' /></td>"; l += " <td title=\"function: "+r1[j].function+"\">"+r1[j].function.substr(0,20)+cut_function+"</td>"; l += " <td title=\"format: "+r1[j].format+"\">"+r1[j].format.substr(0,20)+cut_format+"</td>"; l += " <td style='text-align:center' title='"+ttl+"'>"+record[j].lineno+"</td>"; l += " <td style='text-align:center'><input title='p-flag' type='checkbox' class='tp debug' "+checked+" file='"+record[j].file+"' line='"+record[j].lineno+"' /></td>"; l += " <td title=\"function: "+record[j].function+"\">"+record[j].function.substr(0,20)+cut_function+"</td>"; l += " <td title=\"format: "+record[j].format+"\">"+record[j].format.substr(0,20)+cut_format+"</td>"; l += "</tr>"; ctbl.append(l); } } function fill_content_rebind_events(){ //init actions $(".debug").off("change"); $(".debug").change(function(){ console.log($(this).attr("file")+", "+$(this).attr("line")+", "+$(this).prop("checked")); $.ajax({ url: "debugfs.php?cmd=echo&file="+$(this).attr("file")+"&line="+$(this).attr("line")+"&pflag="+$(this).prop("checked") }); }); } $(".filename").click(function(){ var id = $(this).attr("id"); id = id.substr(id.indexOf("_")+1); console.log(id); $("#content_"+id).toggle(); function init_ui_file(record,index){ var l = $("<tr>",{id:"row_"+index}).html("\ <td class='hidden_rows' style='text-align:center;display:none' >\ <input id='cb_"+index+"' class='tp visibility_cb' type='checkbox'>\ </td>\ <td class='special filename' id='header_"+index+" '>"+record.file+"</td>\ "); if (record.state==0){ l.addClass("hidden_rows").hide(); l.find("input").prop("checked",false); }else{ l.find("input").prop("checked",true); } return l; } function init_ui_content(record,index){ var content = $("<tr>",{ id: "content_"+index }).css({ display: "none", border: "0px solid rgba(255,255,255,0)" }); $(".visibility_cb").change(function(){ if (record.state==0){ content.addClass("hidden_content").hide(); } content.append( $("<td>").addClass("hidden_rows").hide() ).append( $("<td>",{id:"content_td"}) ); return content; } function init_ui_controls(record,index){ var controls = $("<tr>",{ id: "controls_"+index }).css({ display: "none", border: "0px solid rgba(255,255,255,0)" }); if (record.state==0){ controls.addClass("hidden_content").hide(); } controls.append( $("<td>").addClass("hidden_rows").hide() ).append( $("<td>",{id:"controls_td"}) ); var bc0 = $("<button>",{id:"bc0_"+index,file:record.file}).css({margin:"5px 5px 5px 5px","font-size":"14px"}).html("reread from debugfs"); bc0.click(function(){ var id = $(this).attr("id"); id = id.substr(id.indexOf("_")+1); if ($(this).prop("checked")){ $("#row_"+id).removeClass("hidden_rows"); debugfs_data[id].state = 1; file = $(this).attr("file"); $.ajax({ url:"debugfs.php?cmd=reread&file="+file, success:function(data){ rec = jQuery.parseJSON(data); target = $("#content_"+id).find("#content_td"); //apply existing checkboxes to rec oldrec = debugfs_data[id]; lnew = rec.configs[0].lines.length; lold = debugfs_data[id].configs[0].lines.length; for(var i=0;i<lnew;i++){ if (i<lold) { rec.configs[0].lines[i].flags=oldrec.configs[0].lines[i].flags; }else{ $("#row_"+id).addClass("hidden_rows"); $("#content_"+id).hide(); debugfs_data[id].state = 0; rec.configs[0].lines[i].flags=oldrec.configs[0].lines[lold-1].flags; } } update_debugfs_config(); }); //when everything is parsed. do something. // unique IDs // save config //update debugfs_data debugfs_data[id].configs[0] = rec.configs[0]; fill_content(rec.configs[0].lines,id,target); fill_content_rebind_events(); } }); }); controls.find("#controls_td").append(bc0); return controls; } function update_debugfs_config(){ Loading src/debugfs-webgui/debugfs.php +26 −5 Original line number Diff line number Diff line Loading @@ -3,6 +3,8 @@ $config = "debugfs.json"; $tmp_config = "/tmp/$config"; $DEBUGFSFILE = "/sys/kernel/debug/dynamic_debug/control"; if (isset($_GET['cmd'])) $cmd = $_GET['cmd']; else Loading Loading @@ -97,7 +99,7 @@ function update_config($data){ } function apply_config_to_control(){ global $tmp_config; global $tmp_config, $DEBUGFSFILE; $arr_config = json_decode(file_get_contents($tmp_config),true); foreach($arr_config as $k0 => $v0){ if ($v0['state']==1){ Loading @@ -109,7 +111,7 @@ function apply_config_to_control(){ $flag = $v2['flags']; if ($flag=="p") $sign = "+"; else $sign = "-"; exec("echo -n 'file $file line $lineno ${sign}p' > /sys/kernel/debug/dynamic_debug/control"); exec("echo -n 'file $file line $lineno ${sign}p' > $DEBUGFSFILE"); //echo "echo -n 'file $file line $lineno ${sign}p'\n"; } } Loading Loading @@ -153,9 +155,20 @@ function sync_to_config($file,$line,$flag){ update_config(json_encode($arr_config)); } function filter_record_by_file($a,$f){ $res = Array(); foreach($a as $k=>$v){ if ($v['file']==$f){ $res = $v; break; } } return $res; } if ($cmd=="do_nothing"){ if (isset($_GET['file'])) $file = $_GET['file']; else $file = "/sys/kernel/debug/dynamic_debug/control"; else $file = $DEBUGFSFILE; //echo json_encode(get_control($file)); //echo "<pre>"; Loading Loading @@ -191,7 +204,7 @@ if ($cmd=="echo") { $flag="-"; } exec("echo -n 'file $file line $line ${flag}p' > /sys/kernel/debug/dynamic_debug/control"); exec("echo -n 'file $file line $line ${flag}p' > $DEBUGFSFILE"); sync_to_config($file,$line,$flag); } Loading @@ -201,7 +214,7 @@ $debugfs_configs = "debugfs_configs"; if ($cmd=="save"){ $file = $_GET['file']; if (!is_dir($debugfs_configs)) mkdir($debugfs_configs); file_put_contents("$debugfs_configs/$file", file_get_contents("/sys/kernel/debug/dynamic_debug/control")); file_put_contents("$debugfs_configs/$file", file_get_contents($DEBUGFSFILE)); } if ($cmd=="sync"){ Loading @@ -218,6 +231,14 @@ if ($cmd=="restore"){ apply_config_to_control(); } if ($cmd=="reread"){ $file = $_GET['file']; $arr = get_control($DEBUGFSFILE); $filtered = filter_record_by_file($arr,$file); echo json_encode($filtered); //echo "<pre>";print_r($filtered); } //single line: echo -n 'file gamma_tables.c +p' > /sys/kernel/debug/dynamic_debug/control ?> Loading
src/debugfs-webgui/debugfs.js +187 −83 Original line number Diff line number Diff line Loading @@ -5,7 +5,7 @@ var debugfs_data; function init(){ $("body").html("<h3>DebugFS:</h3>"); $("body").html("<h3>Dynamic Debug, DebugFS:</h3>"); var b0 = $("<button>",{id:"b0"}).html("toggle hidden"); b0.prop("state",0); Loading @@ -17,6 +17,8 @@ function init(){ }else{ $(this).prop("state",0) $(".hidden_rows").hide(); $(".hidden_content").hide(); //$("#content_"+id).hide(); ?! } }); Loading Loading @@ -55,118 +57,220 @@ function init(){ //global debugfs_data = r; var l,content,controls; for(var i=0;i<r.length;i++){ l = $("<tr>",{id:"row_"+i}).html("\ <td class='hidden_rows' style='text-align:center;display:none' >\ <input id='cb_"+i+"' class='tp visibility_cb' type='checkbox'>\ </td>\ <td class='special filename' id='header_"+i+" '>"+r[i].file+"</td>\ "); l = init_ui_file(r[i],i); content = init_ui_content(r[i],i); controls = init_ui_controls(r[i],i); if (r[i].state==0){ l.addClass("hidden_rows").hide(); l.find("input").prop("checked",false); }else{ l.removeClass("hidden_rows").show(); l.find("input").prop("checked",true); t.append(l).append(controls).append(content); var r1 = r[i].configs[0].lines; fill_content(r1,i,content.find("#content_td")); } content = $("<tr>",{ id: "content_"+i }).css({ display: "none", border: "0px solid rgba(255,255,255,0)" }); fill_content_rebind_events(); content.append( $("<td>").addClass("hidden_rows").hide() ).append( $("<td>",{id:"content_td"}) ); $(".filename").click(function(){ var id = $(this).attr("id"); id = id.substr(id.indexOf("_")+1); console.log(id); $("#content_"+id).toggle(); $("#controls_"+id).toggle(); }); //$("<table>").css({margin:"5px"}) $(".visibility_cb").change(function(){ var id = $(this).attr("id"); id = id.substr(id.indexOf("_")+1); if ($(this).prop("checked")){ $("#row_"+id).removeClass("hidden_rows"); $("#content_"+id).removeClass("hidden_content"); $("#controls_"+id).removeClass("hidden_content"); debugfs_data[id].state = 1; }else{ $("#row_"+id).addClass("hidden_rows"); $("#content_"+id).addClass("hidden_content"); $("#controls_"+id).addClass("hidden_content"); debugfs_data[id].state = 0; } update_debugfs_config(); }); //.append($("<td>").addClass("hidden_rows").css({display:"none"})) //when everything is parsed. do something. // unique IDs // save config } }); } t.append(l).append(content); function fill_content(record,index,target){ var r1 = r[i].configs[0].lines; target.html(""); var table_index=0; for (var j=0;j<r1.length;j++){ for (var j=0;j<record.length;j++){ table_index = Math.floor(j/NLINES); //shift because of 'all' checkbox if (j==((table_index+1)*NLINES-1)) table_index++; if (j%2==0) oddeven = "even"; else oddeven = "odd"; //create those tables?! if (content.find("#ctbl_"+table_index).length==0) { if (target.find("#ctbl_"+table_index).length==0) { ctbl = $("<table>",{id:"ctbl_"+table_index}).css({margin:"5px 30px 5px 5px",display:"inline"}); content.find("#content_td").append(ctbl); if (table_index==0){ //add all/none checkbox l = "<tr>"; l += " <td style='text-align:center' title='check/uncheck all'>all</td>"; l += " <td id='all_"+index+"' style='text-align:center'><input title='check flags' type='checkbox' class='tp allornone' /></td>"; l += " <td></td>"; l += " <td></td>"; l += "</tr>"; ctbl.append(l); } target.append(ctbl); } ttl = "module: "+r1[j].module+"\n"; ttl += "function: "+r1[j].function+"\n"; ttl += "format: "+r1[j].format; ttl = "module: "+record[j].module+"\n"; ttl += "function: "+record[j].function+"\n"; ttl += "format: "+record[j].format; if (r1[j].flags=="p"){ if (record[j].flags=="p"){ checked = "checked"; }else{ checked = ""; } if (r1[j].function.length>CUT_STRING_LIMIT) cut_function = "..."; if (record[j].function.length>CUT_STRING_LIMIT) cut_function = "..."; else cut_function = ""; if (r1[j].format.length>CUT_STRING_LIMIT) cut_format = "..."; if (record[j].format.length>CUT_STRING_LIMIT) cut_format = "..."; else cut_format = ""; l = "<tr class='"+oddeven+"'>"; l += " <td style='text-align:center' title='"+ttl+"'>"+r1[j].lineno+"</td>"; l += " <td style='text-align:center'><input title='p-flag' type='checkbox' class='tp debug' "+checked+" file='"+r1[j].file+"' line='"+r1[j].lineno+"' /></td>"; l += " <td title=\"function: "+r1[j].function+"\">"+r1[j].function.substr(0,20)+cut_function+"</td>"; l += " <td title=\"format: "+r1[j].format+"\">"+r1[j].format.substr(0,20)+cut_format+"</td>"; l += " <td style='text-align:center' title='"+ttl+"'>"+record[j].lineno+"</td>"; l += " <td style='text-align:center'><input title='p-flag' type='checkbox' class='tp debug' "+checked+" file='"+record[j].file+"' line='"+record[j].lineno+"' /></td>"; l += " <td title=\"function: "+record[j].function+"\">"+record[j].function.substr(0,20)+cut_function+"</td>"; l += " <td title=\"format: "+record[j].format+"\">"+record[j].format.substr(0,20)+cut_format+"</td>"; l += "</tr>"; ctbl.append(l); } } function fill_content_rebind_events(){ //init actions $(".debug").off("change"); $(".debug").change(function(){ console.log($(this).attr("file")+", "+$(this).attr("line")+", "+$(this).prop("checked")); $.ajax({ url: "debugfs.php?cmd=echo&file="+$(this).attr("file")+"&line="+$(this).attr("line")+"&pflag="+$(this).prop("checked") }); }); } $(".filename").click(function(){ var id = $(this).attr("id"); id = id.substr(id.indexOf("_")+1); console.log(id); $("#content_"+id).toggle(); function init_ui_file(record,index){ var l = $("<tr>",{id:"row_"+index}).html("\ <td class='hidden_rows' style='text-align:center;display:none' >\ <input id='cb_"+index+"' class='tp visibility_cb' type='checkbox'>\ </td>\ <td class='special filename' id='header_"+index+" '>"+record.file+"</td>\ "); if (record.state==0){ l.addClass("hidden_rows").hide(); l.find("input").prop("checked",false); }else{ l.find("input").prop("checked",true); } return l; } function init_ui_content(record,index){ var content = $("<tr>",{ id: "content_"+index }).css({ display: "none", border: "0px solid rgba(255,255,255,0)" }); $(".visibility_cb").change(function(){ if (record.state==0){ content.addClass("hidden_content").hide(); } content.append( $("<td>").addClass("hidden_rows").hide() ).append( $("<td>",{id:"content_td"}) ); return content; } function init_ui_controls(record,index){ var controls = $("<tr>",{ id: "controls_"+index }).css({ display: "none", border: "0px solid rgba(255,255,255,0)" }); if (record.state==0){ controls.addClass("hidden_content").hide(); } controls.append( $("<td>").addClass("hidden_rows").hide() ).append( $("<td>",{id:"controls_td"}) ); var bc0 = $("<button>",{id:"bc0_"+index,file:record.file}).css({margin:"5px 5px 5px 5px","font-size":"14px"}).html("reread from debugfs"); bc0.click(function(){ var id = $(this).attr("id"); id = id.substr(id.indexOf("_")+1); if ($(this).prop("checked")){ $("#row_"+id).removeClass("hidden_rows"); debugfs_data[id].state = 1; file = $(this).attr("file"); $.ajax({ url:"debugfs.php?cmd=reread&file="+file, success:function(data){ rec = jQuery.parseJSON(data); target = $("#content_"+id).find("#content_td"); //apply existing checkboxes to rec oldrec = debugfs_data[id]; lnew = rec.configs[0].lines.length; lold = debugfs_data[id].configs[0].lines.length; for(var i=0;i<lnew;i++){ if (i<lold) { rec.configs[0].lines[i].flags=oldrec.configs[0].lines[i].flags; }else{ $("#row_"+id).addClass("hidden_rows"); $("#content_"+id).hide(); debugfs_data[id].state = 0; rec.configs[0].lines[i].flags=oldrec.configs[0].lines[lold-1].flags; } } update_debugfs_config(); }); //when everything is parsed. do something. // unique IDs // save config //update debugfs_data debugfs_data[id].configs[0] = rec.configs[0]; fill_content(rec.configs[0].lines,id,target); fill_content_rebind_events(); } }); }); controls.find("#controls_td").append(bc0); return controls; } function update_debugfs_config(){ Loading
src/debugfs-webgui/debugfs.php +26 −5 Original line number Diff line number Diff line Loading @@ -3,6 +3,8 @@ $config = "debugfs.json"; $tmp_config = "/tmp/$config"; $DEBUGFSFILE = "/sys/kernel/debug/dynamic_debug/control"; if (isset($_GET['cmd'])) $cmd = $_GET['cmd']; else Loading Loading @@ -97,7 +99,7 @@ function update_config($data){ } function apply_config_to_control(){ global $tmp_config; global $tmp_config, $DEBUGFSFILE; $arr_config = json_decode(file_get_contents($tmp_config),true); foreach($arr_config as $k0 => $v0){ if ($v0['state']==1){ Loading @@ -109,7 +111,7 @@ function apply_config_to_control(){ $flag = $v2['flags']; if ($flag=="p") $sign = "+"; else $sign = "-"; exec("echo -n 'file $file line $lineno ${sign}p' > /sys/kernel/debug/dynamic_debug/control"); exec("echo -n 'file $file line $lineno ${sign}p' > $DEBUGFSFILE"); //echo "echo -n 'file $file line $lineno ${sign}p'\n"; } } Loading Loading @@ -153,9 +155,20 @@ function sync_to_config($file,$line,$flag){ update_config(json_encode($arr_config)); } function filter_record_by_file($a,$f){ $res = Array(); foreach($a as $k=>$v){ if ($v['file']==$f){ $res = $v; break; } } return $res; } if ($cmd=="do_nothing"){ if (isset($_GET['file'])) $file = $_GET['file']; else $file = "/sys/kernel/debug/dynamic_debug/control"; else $file = $DEBUGFSFILE; //echo json_encode(get_control($file)); //echo "<pre>"; Loading Loading @@ -191,7 +204,7 @@ if ($cmd=="echo") { $flag="-"; } exec("echo -n 'file $file line $line ${flag}p' > /sys/kernel/debug/dynamic_debug/control"); exec("echo -n 'file $file line $line ${flag}p' > $DEBUGFSFILE"); sync_to_config($file,$line,$flag); } Loading @@ -201,7 +214,7 @@ $debugfs_configs = "debugfs_configs"; if ($cmd=="save"){ $file = $_GET['file']; if (!is_dir($debugfs_configs)) mkdir($debugfs_configs); file_put_contents("$debugfs_configs/$file", file_get_contents("/sys/kernel/debug/dynamic_debug/control")); file_put_contents("$debugfs_configs/$file", file_get_contents($DEBUGFSFILE)); } if ($cmd=="sync"){ Loading @@ -218,6 +231,14 @@ if ($cmd=="restore"){ apply_config_to_control(); } if ($cmd=="reread"){ $file = $_GET['file']; $arr = get_control($DEBUGFSFILE); $filtered = filter_record_by_file($arr,$file); echo json_encode($filtered); //echo "<pre>";print_r($filtered); } //single line: echo -n 'file gamma_tables.c +p' > /sys/kernel/debug/dynamic_debug/control ?>