Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
elphel-web-393
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Elphel
elphel-web-393
Commits
e4569ef9
Commit
e4569ef9
authored
Aug 19, 2016
by
Oleg Dzhimiev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update lines from debugfs but use flags from saved config
parent
81d29baf
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
213 additions
and
88 deletions
+213
-88
debugfs.js
src/debugfs-webgui/debugfs.js
+187
-83
debugfs.php
src/debugfs-webgui/debugfs.php
+26
-5
No files found.
src/debugfs-webgui/debugfs.js
View file @
e4569ef9
...
@@ -5,7 +5,7 @@ var debugfs_data;
...
@@ -5,7 +5,7 @@ var debugfs_data;
function
init
(){
function
init
(){
$
(
"body"
).
html
(
"<h3>DebugFS:</h3>"
);
$
(
"body"
).
html
(
"<h3>D
ynamic Debug, D
ebugFS:</h3>"
);
var
b0
=
$
(
"<button>"
,{
id
:
"b0"
}).
html
(
"toggle hidden"
);
var
b0
=
$
(
"<button>"
,{
id
:
"b0"
}).
html
(
"toggle hidden"
);
b0
.
prop
(
"state"
,
0
);
b0
.
prop
(
"state"
,
0
);
...
@@ -17,6 +17,8 @@ function init(){
...
@@ -17,6 +17,8 @@ function init(){
}
else
{
}
else
{
$
(
this
).
prop
(
"state"
,
0
)
$
(
this
).
prop
(
"state"
,
0
)
$
(
".hidden_rows"
).
hide
();
$
(
".hidden_rows"
).
hide
();
$
(
".hidden_content"
).
hide
();
//$("#content_"+id).hide(); ?!
}
}
});
});
...
@@ -55,118 +57,220 @@ function init(){
...
@@ -55,118 +57,220 @@ function init(){
//global
//global
debugfs_data
=
r
;
debugfs_data
=
r
;
var
l
,
content
,
controls
;
for
(
var
i
=
0
;
i
<
r
.
length
;
i
++
){
for
(
var
i
=
0
;
i
<
r
.
length
;
i
++
){
l
=
$
(
"<tr>"
,{
id
:
"row_"
+
i
}).
html
(
"
\
l
=
init_ui_file
(
r
[
i
],
i
);
<td class='hidden_rows' style='text-align:center;display:none' >
\
content
=
init_ui_content
(
r
[
i
],
i
);
<input id='cb_"
+
i
+
"' class='tp visibility_cb' type='checkbox'>
\
controls
=
init_ui_controls
(
r
[
i
],
i
);
</td>
\
<td class='special filename' id='header_"
+
i
+
" '>"
+
r
[
i
].
file
+
"</td>
\
"
);
if
(
r
[
i
].
state
==
0
){
t
.
append
(
l
).
append
(
controls
).
append
(
content
);
l
.
addClass
(
"hidden_rows"
).
hide
();
l
.
find
(
"input"
).
prop
(
"checked"
,
false
);
var
r1
=
r
[
i
].
configs
[
0
].
lines
;
}
else
{
l
.
removeClass
(
"hidden_rows"
).
show
();
fill_content
(
r1
,
i
,
content
.
find
(
"#content_td"
));
l
.
find
(
"input"
).
prop
(
"checked"
,
true
);
}
}
content
=
$
(
"<tr>"
,{
fill_content_rebind_events
();
id
:
"content_"
+
i
}).
css
({
display
:
"none"
,
border
:
"0px solid rgba(255,255,255,0)"
});
content
.
append
(
$
(
".filename"
).
click
(
function
(){
$
(
"<td>"
).
addClass
(
"hidden_rows"
).
hide
()
var
id
=
$
(
this
).
attr
(
"id"
);
).
append
(
id
=
id
.
substr
(
id
.
indexOf
(
"_"
)
+
1
);
$
(
"<td>"
,{
id
:
"content_td"
})
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
;
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
);
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"
;
if
(
j
%
2
==
0
)
oddeven
=
"even"
;
else
oddeven
=
"odd"
;
else
oddeven
=
"odd"
;
//create those tables?!
//create those tables?!
if
(
conten
t
.
find
(
"#ctbl_"
+
table_index
).
length
==
0
)
{
if
(
targe
t
.
find
(
"#ctbl_"
+
table_index
).
length
==
0
)
{
ctbl
=
$
(
"<table>"
,{
id
:
"ctbl_"
+
table_index
}).
css
({
margin
:
"5px 30px 5px 5px"
,
display
:
"inline"
});
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
=
"module: "
+
record
[
j
].
module
+
"
\n
"
;
ttl
+=
"function: "
+
r1
[
j
].
function
+
"
\n
"
;
ttl
+=
"function: "
+
record
[
j
].
function
+
"
\n
"
;
ttl
+=
"format: "
+
r1
[
j
].
format
;
ttl
+=
"format: "
+
record
[
j
].
format
;
if
(
r1
[
j
].
flags
==
"p"
){
if
(
record
[
j
].
flags
==
"p"
){
checked
=
"checked"
;
checked
=
"checked"
;
}
else
{
}
else
{
checked
=
""
;
checked
=
""
;
}
}
if
(
r1
[
j
].
function
.
length
>
CUT_STRING_LIMIT
)
cut_function
=
"..."
;
if
(
record
[
j
].
function
.
length
>
CUT_STRING_LIMIT
)
cut_function
=
"..."
;
else
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
=
""
;
else
cut_format
=
""
;
l
=
"<tr class='"
+
oddeven
+
"'>"
;
l
=
"<tr class='"
+
oddeven
+
"'>"
;
l
+=
" <td style='text-align:center' title='"
+
ttl
+
"'>"
+
r1
[
j
].
lineno
+
"</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='"
+
r1
[
j
].
file
+
"' line='"
+
r1
[
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: "
+
r1
[
j
].
function
+
"
\"
>"
+
r1
[
j
].
function
.
substr
(
0
,
20
)
+
cut_function
+
"</td>"
;
l
+=
" <td title=
\"
function: "
+
record
[
j
].
function
+
"
\"
>"
+
record
[
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 title=
\"
format: "
+
record
[
j
].
format
+
"
\"
>"
+
record
[
j
].
format
.
substr
(
0
,
20
)
+
cut_format
+
"</td>"
;
l
+=
"</tr>"
;
l
+=
"</tr>"
;
ctbl
.
append
(
l
);
ctbl
.
append
(
l
);
}
}
}
}
function
fill_content_rebind_events
(){
//init actions
//init actions
$
(
".debug"
).
off
(
"change"
);
$
(
".debug"
).
change
(
function
(){
$
(
".debug"
).
change
(
function
(){
console
.
log
(
$
(
this
).
attr
(
"file"
)
+
", "
+
$
(
this
).
attr
(
"line"
)
+
", "
+
$
(
this
).
prop
(
"checked"
));
console
.
log
(
$
(
this
).
attr
(
"file"
)
+
", "
+
$
(
this
).
attr
(
"line"
)
+
", "
+
$
(
this
).
prop
(
"checked"
));
$
.
ajax
({
$
.
ajax
({
url
:
"debugfs.php?cmd=echo&file="
+
$
(
this
).
attr
(
"file"
)
+
"&line="
+
$
(
this
).
attr
(
"line"
)
+
"&pflag="
+
$
(
this
).
prop
(
"checked"
)
url
:
"debugfs.php?cmd=echo&file="
+
$
(
this
).
attr
(
"file"
)
+
"&line="
+
$
(
this
).
attr
(
"line"
)
+
"&pflag="
+
$
(
this
).
prop
(
"checked"
)
});
});
});
});
}
$
(
".filename"
).
click
(
function
(){
function
init_ui_file
(
record
,
index
){
var
id
=
$
(
this
).
attr
(
"id"
);
var
l
=
$
(
"<tr>"
,{
id
:
"row_"
+
index
}).
html
(
"
\
id
=
id
.
substr
(
id
.
indexOf
(
"_"
)
+
1
);
<td class='hidden_rows' style='text-align:center;display:none' >
\
console
.
log
(
id
);
<input id='cb_"
+
index
+
"' class='tp visibility_cb' type='checkbox'>
\
$
(
"#content_"
+
id
).
toggle
();
</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"
);
var
id
=
$
(
this
).
attr
(
"id"
);
id
=
id
.
substr
(
id
.
indexOf
(
"_"
)
+
1
);
id
=
id
.
substr
(
id
.
indexOf
(
"_"
)
+
1
);
if
(
$
(
this
).
prop
(
"checked"
)){
file
=
$
(
this
).
attr
(
"file"
);
$
(
"#row_"
+
id
).
removeClass
(
"hidden_rows"
);
$
.
ajax
({
debugfs_data
[
id
].
state
=
1
;
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
{
}
else
{
$
(
"#row_"
+
id
).
addClass
(
"hidden_rows"
);
rec
.
configs
[
0
].
lines
[
i
].
flags
=
oldrec
.
configs
[
0
].
lines
[
lold
-
1
].
flags
;
$
(
"#content_"
+
id
).
hide
();
}
debugfs_data
[
id
].
state
=
0
;
}
}
update_debugfs_config
();
});
//when everything is parsed. do something.
//update debugfs_data
// unique IDs
debugfs_data
[
id
].
configs
[
0
]
=
rec
.
configs
[
0
];
// save config
fill_content
(
rec
.
configs
[
0
].
lines
,
id
,
target
);
fill_content_rebind_events
();
}
}
});
});
});
controls
.
find
(
"#controls_td"
).
append
(
bc0
);
return
controls
;
}
}
function
update_debugfs_config
(){
function
update_debugfs_config
(){
...
...
src/debugfs-webgui/debugfs.php
View file @
e4569ef9
...
@@ -3,6 +3,8 @@
...
@@ -3,6 +3,8 @@
$config
=
"debugfs.json"
;
$config
=
"debugfs.json"
;
$tmp_config
=
"/tmp/
$config
"
;
$tmp_config
=
"/tmp/
$config
"
;
$DEBUGFSFILE
=
"/sys/kernel/debug/dynamic_debug/control"
;
if
(
isset
(
$_GET
[
'cmd'
]))
if
(
isset
(
$_GET
[
'cmd'
]))
$cmd
=
$_GET
[
'cmd'
];
$cmd
=
$_GET
[
'cmd'
];
else
else
...
@@ -97,7 +99,7 @@ function update_config($data){
...
@@ -97,7 +99,7 @@ function update_config($data){
}
}
function
apply_config_to_control
(){
function
apply_config_to_control
(){
global
$tmp_config
;
global
$tmp_config
,
$DEBUGFSFILE
;
$arr_config
=
json_decode
(
file_get_contents
(
$tmp_config
),
true
);
$arr_config
=
json_decode
(
file_get_contents
(
$tmp_config
),
true
);
foreach
(
$arr_config
as
$k0
=>
$v0
){
foreach
(
$arr_config
as
$k0
=>
$v0
){
if
(
$v0
[
'state'
]
==
1
){
if
(
$v0
[
'state'
]
==
1
){
...
@@ -109,7 +111,7 @@ function apply_config_to_control(){
...
@@ -109,7 +111,7 @@ function apply_config_to_control(){
$flag
=
$v2
[
'flags'
];
$flag
=
$v2
[
'flags'
];
if
(
$flag
==
"p"
)
$sign
=
"+"
;
if
(
$flag
==
"p"
)
$sign
=
"+"
;
else
$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";
//echo "echo -n 'file $file line $lineno ${sign}p'\n";
}
}
}
}
...
@@ -153,9 +155,20 @@ function sync_to_config($file,$line,$flag){
...
@@ -153,9 +155,20 @@ function sync_to_config($file,$line,$flag){
update_config
(
json_encode
(
$arr_config
));
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
(
$cmd
==
"do_nothing"
){
if
(
isset
(
$_GET
[
'file'
]))
$file
=
$_GET
[
'file'
];
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 json_encode(get_control($file));
//echo "<pre>";
//echo "<pre>";
...
@@ -191,7 +204,7 @@ if ($cmd=="echo") {
...
@@ -191,7 +204,7 @@ if ($cmd=="echo") {
$flag
=
"-"
;
$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
);
sync_to_config
(
$file
,
$line
,
$flag
);
}
}
...
@@ -201,7 +214,7 @@ $debugfs_configs = "debugfs_configs";
...
@@ -201,7 +214,7 @@ $debugfs_configs = "debugfs_configs";
if
(
$cmd
==
"save"
){
if
(
$cmd
==
"save"
){
$file
=
$_GET
[
'file'
];
$file
=
$_GET
[
'file'
];
if
(
!
is_dir
(
$debugfs_configs
))
mkdir
(
$debugfs_configs
);
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"
){
if
(
$cmd
==
"sync"
){
...
@@ -218,6 +231,14 @@ if ($cmd=="restore"){
...
@@ -218,6 +231,14 @@ if ($cmd=="restore"){
apply_config_to_control
();
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
//single line: echo -n 'file gamma_tables.c +p' > /sys/kernel/debug/dynamic_debug/control
?>
?>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment