Mentions légales du service
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
gdb-testing
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
dema
gdb-testing
Commits
b83d7630
Commit
b83d7630
authored
9 years ago
by
Kevin Pouget
Browse files
Options
Downloads
Patches
Plain Diff
add breakpoint creating time to benchmarks
parent
42e7e2bf
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
__init__.py
+12
-4
12 additions, 4 deletions
__init__.py
mcgdb_testing/native_gdb.py
+69
-5
69 additions, 5 deletions
mcgdb_testing/native_gdb.py
with
81 additions
and
9 deletions
__init__.py
+
12
−
4
View file @
b83d7630
import
pkgutil
,
importlib
,
difflib
# standard lib packages
import
pkgutil
,
importlib
,
difflib
# standard lib packages
import
sys
,
subprocess
,
shlex
,
fcntl
,
os
,
time
,
errno
# standard lib packages
import
sys
,
subprocess
,
shlex
,
fcntl
,
os
,
time
,
errno
# standard lib packages
import
logging
;
log
=
logging
.
getLogger
(
__name__
)
import
logging
;
log
=
logging
.
getLogger
(
__name__
)
import
traceback
EXPECTED_FILE_PREFIX
=
"
file://
"
EXPECTED_FILE_PREFIX
=
"
file://
"
...
@@ -38,7 +39,8 @@ def all_subpackages(pkg_prefix, verbose, what_to_run, parent, prefix=""):
...
@@ -38,7 +39,8 @@ def all_subpackages(pkg_prefix, verbose, what_to_run, parent, prefix=""):
run_module
(
verbose
,
modname
,
mod
,
getattr
(
mod
,
what
))
run_module
(
verbose
,
modname
,
mod
,
getattr
(
mod
,
what
))
except
Exception
as
e
:
except
Exception
as
e
:
log
.
warn
(
"
{} failed {}
"
.
format
(
modname
,
e
))
log
.
warn
(
"
{} failed {}
"
.
format
(
modname
,
e
))
#traceback.print_exc()
def
main
(
pkg_prefix
,
module
=
None
,
benchmark
=
True
,
test
=
True
,
verbose
=
False
,
help
=
False
):
def
main
(
pkg_prefix
,
module
=
None
,
benchmark
=
True
,
test
=
True
,
verbose
=
False
,
help
=
False
):
what_to_run
=
[]
what_to_run
=
[]
...
@@ -276,21 +278,27 @@ class GDB_Instance:
...
@@ -276,21 +278,27 @@ class GDB_Instance:
output
=
self
.
execute
(
"
python print({})
"
.
format
(
name
))
output
=
self
.
execute
(
"
python print({})
"
.
format
(
name
))
value
=
output
.
out
[:
-
1
]
if
GDB_Instance
.
CSV_mode
:
if
GDB_Instance
.
CSV_mode
:
print
(
output
.
out
[:
-
1
]
,
end
=
"
,
"
,
flush
=
True
)
print
(
value
,
end
=
"
,
"
,
flush
=
True
)
else
:
else
:
output
.
print_all
()
output
.
print_all
()
return
value
def
save_value
(
self
,
name
,
format
,
unit
):
def
save_value
(
self
,
name
,
format
,
unit
):
if
GDB_Instance
.
CSV_header
:
return
if
GDB_Instance
.
CSV_header
:
return
output
=
self
.
execute
(
'
printf
"
{format}{unit}
\\
n
"
, {name}
'
.
format
(
output
=
self
.
execute
(
'
printf
"
{format}{unit}
\\
n
"
, {name}
'
.
format
(
name
=
name
,
format
=
format
,
unit
=
unit
))
name
=
name
,
format
=
format
,
unit
=
unit
))
value
=
output
.
out
[:
-
1
]
if
GDB_Instance
.
CSV_mode
:
if
GDB_Instance
.
CSV_mode
:
print
(
output
.
out
[:
-
1
]
,
end
=
"
,
"
,
flush
=
True
)
print
(
value
,
end
=
"
,
"
,
flush
=
True
)
else
:
else
:
output
.
print_all
()
output
.
print_all
()
return
value
def
_read_til_prompt
(
self
,
command
):
def
_read_til_prompt
(
self
,
command
):
if
command
is
not
None
:
if
command
is
not
None
:
...
...
This diff is collapsed.
Click to expand it.
mcgdb_testing/native_gdb.py
+
69
−
5
View file @
b83d7630
from
gdb_tester
import
*
from
gdb_tester
import
*
import
mcgdb
gdb
=
None
gdb
=
None
...
@@ -9,7 +8,7 @@ def run(what, run="run"):
...
@@ -9,7 +8,7 @@ def run(what, run="run"):
gdb
.
execute
(
run
)
gdb
.
execute
(
run
)
gdb
.
execute
(
"
up
"
)
gdb
.
execute
(
"
up
"
)
gdb
.
save_value
(
"
us_busy_once
"
,
"
%1.f
"
,
"
us
"
)
return
gdb
.
save_value
(
"
us_busy_once
"
,
"
%1.f
"
,
"
us
"
)
def
nominal_time
():
def
nominal_time
():
run
(
"
Nominal time
"
)
run
(
"
Nominal time
"
)
...
@@ -39,6 +38,7 @@ PARAMETERS = [
...
@@ -39,6 +38,7 @@ PARAMETERS = [
'
int(gdb.parse_and_eval(
"
it
"
))
'
,
'
int(gdb.parse_and_eval(
"
it
"
))
'
,
'
int(gdb.newest_frame().older().read_var(
"
i
"
))
'
'
int(gdb.newest_frame().older().read_var(
"
i
"
))
'
]
]
def
gdb_py_breakpoint_parameter
(
params_choice
):
def
gdb_py_breakpoint_parameter
(
params_choice
):
params
=
[
par
for
i
,
par
in
enumerate
(
PARAMETERS
)
if
params_choice
&
(
1
<<
i
)]
params
=
[
par
for
i
,
par
in
enumerate
(
PARAMETERS
)
if
params_choice
&
(
1
<<
i
)]
...
@@ -56,17 +56,81 @@ class TestBP(gdb.Breakpoint):
...
@@ -56,17 +56,81 @@ class TestBP(gdb.Breakpoint):
TestBP()
TestBP()
end
end
"""
.
format
(
params
=
"
\n
"
.
join
(
params
)))
"""
.
format
(
params
=
"
\n
"
.
join
(
params
)))
run
(
"
Py BP param {:02b}
"
.
format
(
params_choice
)[
2
:])
run
(
"
Py BP param {:02b}
"
.
format
(
params_choice
)[
2
:])
return
to_run
return
to_run
ref_time_set_bp
=
None
def
do_nothing
():
global
ref_time_set_bp
assert
ref_time_set_bp
is
None
ref_time_set_bp
=
set_breakpoints
(
nb_bp
=
0
)
ref_time_set_bp
=
float
(
ref_time_set_bp
[:
-
2
])
def
set_breakpoints
(
nb_bp
=
1000
):
assert
not
(
ref_time_set_bp
is
None
and
nb_bp
!=
0
)
gdb
.
execute
(
"
py import sys; sys.path.append(
'
/home/kevin/travail/Python
'
)
"
)
gdb
.
execute
(
"
py import mcgdb
"
)
gdb
.
execute
(
"""
python
class VoidBP(gdb.Breakpoint):
def __init__(self, addr):
gdb.Breakpoint.__init__(self,
"
*{{}}
"
.format(addr), internal=True)
#self.silent=True
class TestBP(mcgdb.capture.FunctionBreakpoint):
def __init__(self):
mcgdb.capture.FunctionBreakpoint.__init__(self,
"
action
"
)
def prepare_before (self):
NB_BP = {np_bp}
print(
"
create breakpoints
"
)
start_addr = int(gdb.parse_and_eval(
"
main
"
).address)
bps = []
for addr in range(start_addr, start_addr+NB_BP):
bps.append(VoidBP(addr))
return (False, True, bps)
def prepare_after(self, bps):
print(
"
delete all
"
)
for bp in bps:
bp.delete()
return False
TestBP()
end
"""
.
format
(
np_bp
=
nb_bp
))
gdb
.
execute
(
"
start
"
)
gdb
.
execute
(
"
set var it_count = 10
"
)
exec_time
=
run
(
"
set {} breakpoints
"
.
format
(
nb_bp
),
run
=
"
continue
"
)
if
nb_bp
!=
0
:
gdb
.
execute
(
'
pi bp_create_time = float(gdb.parse_and_eval(
"
us_busy_once
"
))
'
)
gdb
.
execute
(
'
pi bp_create_time -= {}
'
.
format
(
ref_time_set_bp
))
print
(
gdb
.
execute
(
'
pi print(
"
Soit {:.2f}us
"
.format(bp_create_time))
'
)[
1
])
gdb
.
execute
(
"
pi bp_create_time /= {}
"
.
format
(
nb_bp
))
print
(
gdb
.
execute
(
'
pi print(
"
Soit {:.2f}us/bpt
"
.format(bp_create_time))
'
)[
1
])
return
exec_time
def
benchmark
(
_gdb
,
what
=
None
,
no_mcgdb
=
True
):
def
benchmark
(
_gdb
,
what
=
None
,
no_mcgdb
=
True
):
global
gdb
global
gdb
gdb
=
_gdb
gdb
=
_gdb
if
what
is
None
:
# if what is None:
what
=
[
nominal_time
,
gdb_breakpoint
,
gdb_watchpoint
]
+
\
# what = [nominal_time, gdb_breakpoint, gdb_watchpoint] + \
list
(
map
(
lambda
x
:
gdb_py_breakpoint_parameter
(
x
),
(
0b0
,
0b1
,
0b10
,
0b11
)))
# list(map(lambda x: gdb_py_breakpoint_parameter(x), (0b0, 0b1, 0b10, 0b11)))
what
=
[
do_nothing
,
set_breakpoints
]
gdb
.
start
(
CSource
(
"
benchmark.c
"
),
None
if
no_mcgdb
else
mcgdb
.
testing
.
gdb__init_mcgdb
)
gdb
.
start
(
CSource
(
"
benchmark.c
"
),
None
if
no_mcgdb
else
mcgdb
.
testing
.
gdb__init_mcgdb
)
for
prepare_and_run
in
what
:
for
prepare_and_run
in
what
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment