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
Admin message
GitLab upgrade completed. Current version is 17.11.3.
Show more breadcrumbs
dema
gdb-testing
Commits
023eb38c
Commit
023eb38c
authored
9 years ago
by
Kevin Pouget
Browse files
Options
Downloads
Patches
Plain Diff
improve
parent
9815e74f
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
__init__.py
+1
-1
1 addition, 1 deletion
__init__.py
gdb_testing/native_gdb.py
+24
-9
24 additions, 9 deletions
gdb_testing/native_gdb.py
mcgdb_testing/benchmark.c
+87
-76
87 additions, 76 deletions
mcgdb_testing/benchmark.c
with
112 additions
and
86 deletions
__init__.py
+
1
−
1
View file @
023eb38c
...
...
@@ -193,7 +193,7 @@ class GDB_Instance:
source
.
package
=
self
.
package
source
.
compile
()
command_line
=
"
/usr/bin/
gdb -nx
"
command_line
=
"
gdb -nx
"
self
.
_gdb
=
subprocess
.
Popen
(
shlex
.
split
(
command_line
),
stdin
=
subprocess
.
PIPE
,
stdout
=
subprocess
.
PIPE
,
...
...
This diff is collapsed.
Click to expand it.
gdb_testing/native_gdb.py
+
24
−
9
View file @
023eb38c
...
...
@@ -12,8 +12,10 @@ def run(what, run="run"):
def
version
():
gdb
.
set_title
(
"
version
"
)
print
(
gdb
.
execute
(
'
pi print(sys.version)
'
)[
1
])
print
(
gdb
.
execute
(
'
show version
'
)[
1
].
split
(
"
\n
"
)[
0
])
print
(
gdb
.
execute
(
'
pi print(
"
Python
"
+str(sys.version))
'
)[
1
][:
-
1
].
replace
(
"
\n
"
,
"
---
"
))
print
(
""
)
def
nominal_time
():
run
(
"
Nominal time
"
)
...
...
@@ -44,23 +46,36 @@ PARAMETERS = [
'
int(gdb.newest_frame().older().read_var(
"
i
"
))
'
]
def
gdb_py_breakpoint_parameter
(
params_choice
):
params
=
[
par
for
i
,
par
in
enumerate
(
PARAMETERS
)
if
params_choice
&
(
1
<<
i
)]
def
to_run
():
gdb
.
execute
(
"""
python
PY_ON_BREAKPOINT
=
"""
python
class TestBP(gdb.Breakpoint):
def __init__(self):
gdb.Breakpoint.__init__(self,
"
action
"
)
self.silent=True
def stop(self):
{
params
}
{
on_breakpoint
}
return False
TestBP()
end
"""
.
format
(
params
=
"
\n
"
.
join
(
params
)))
"""
def
gdb_py_breakpoint_sleep_for_ref
():
SLEEP_TIME
=
0.001
gdb
.
execute
(
PY_ON_BREAKPOINT
.
format
(
on_breakpoint
=
"
import time;time.sleep({})
"
.
format
(
SLEEP_TIME
)))
run
(
"
Python sleep {}s on breakpoint for reference
"
.
format
(
SLEEP_TIME
))
def
gdb_py_breakpoint
():
gdb
.
execute
(
PY_ON_BREAKPOINT
.
format
(
on_breakpoint
=
""
))
run
(
"
Python breakpoint
"
)
def
gdb_py_breakpoint_parameter
(
params_choice
):
params
=
[
par
for
i
,
par
in
enumerate
(
PARAMETERS
)
if
params_choice
&
(
1
<<
i
)]
def
to_run
():
gdb
.
execute
(
PY_ON_BREAKPOINT
.
format
(
on_breakpoint
=
"
\n
"
.
join
(
params
)))
run
(
"
Py BP param {:02b}
"
.
format
(
params_choice
)[
2
:])
...
...
@@ -137,7 +152,7 @@ def benchmark(_gdb, what=None, at_init=None):
global
gdb
gdb
=
_gdb
#
what = [version,
do_nothing, set_breakpoints
]
what
=
[
version
,
nominal_time
,
gdb_py_breakpoint
,
gdb_py_breakpoint_sleep_for_ref
]
if
what
is
None
:
what
=
[
version
,
do_nothing
,
set_breakpoints
,
nominal_time
,
gdb_breakpoint
,
gdb_watchpoint
]
+
\
list
(
map
(
lambda
x
:
gdb_py_breakpoint_parameter
(
x
),
(
0b0
,
0b1
,
0b10
,
0b11
)))
...
...
This diff is collapsed.
Click to expand it.
mcgdb_testing/benchmark.c
+
87
−
76
View file @
023eb38c
#include
<stdio.h>
#include
<stdlib.h>
#include
<sys/time.h>
#include
<unistd.h>
/***********/
// modified by debugging, do not change to macro.
int
repeat
=
2
;
int
it_count
=
1000
;
int
us_sleep_time
=
100
;
/***********/
void
finish_data_ready
(
void
)
{}
void
finish
(
struct
timeval
x
,
struct
timeval
y
)
{
static
float
it_total
;
static
float
ms_busy_time
,
us_busy_once
;
static
float
ms_total_sleep
;
static
float
ms_time
;
{
static
double
x_us
,
y_us
;
x_us
=
(
double
)
x
.
tv_sec
*
1000000
+
(
double
)
x
.
tv_usec
;
y_us
=
(
double
)
y
.
tv_sec
*
1000000
+
(
double
)
y
.
tv_usec
;
it_total
=
repeat
*
it_count
;
ms_time
=
(
y_us
-
x_us
)
/
1000
;
ms_total_sleep
=
us_sleep_time
*
(
it_total
/
1000
.
0
);
ms_busy_time
=
ms_time
-
ms_total_sleep
;
us_busy_once
=
ms_busy_time
*
1000
/
it_total
;
}
finish_data_ready
();
printf
(
"Repeat: %d; Loop: %d; usleep %dus (one) %1.fms (total)
\n
"
,
repeat
,
it_count
,
us_sleep_time
,
ms_total_sleep
);
printf
(
"------------------
\n
"
);
printf
(
"Total time: %1.fms
\n
"
,
ms_time
);
printf
(
"Busy time : %1.fms
\n
"
,
ms_busy_time
);
printf
(
"Busy once : %1.fus
\n
"
,
us_busy_once
);
}
void
action
(
int
it
)
{
usleep
(
us_sleep_time
);
}
void
benchmark
(
void
)
{
static
int
i
;
for
(
i
=
0
;
i
<
it_count
;
++
i
)
{
action
(
i
);
}
}
int
main
(
int
argc
,
char
**
argv
)
{
struct
timeval
before
,
after
;
int
i
;
benchmark
();
// warm-up
gettimeofday
(
&
before
,
NULL
);
for
(
i
=
0
;
i
<
repeat
;
++
i
)
{
benchmark
();
}
gettimeofday
(
&
after
,
NULL
);
finish
(
before
,
after
);
return
EXIT_SUCCESS
;
}
#include
<time.h>
#include
<sys/time.h>
#include
<unistd.h>
#include
<stdint.h>
#include
<stdio.h>
#include
<stdlib.h>
struct
timespec
tbefore
,
tafter
;
/***********/
// modified by debugging, do not change to macro.
int
repeat
=
2
;
int
it_count
=
1000
;
int
us_sleep_time
=
100
;
/***********/
void
finish_data_ready
(
void
)
{}
void
finish
(
struct
timeval
x
,
struct
timeval
y
)
{
static
float
it_total
;
static
float
ms_total_sleep
;
static
float
us_time
,
us_busy_once
;
{
long
nsec
;
time_t
sec
=
tafter
.
tv_sec
-
tbefore
.
tv_sec
;
if
(
tafter
.
tv_nsec
>
tbefore
.
tv_nsec
)
{
nsec
=
tafter
.
tv_nsec
-
tbefore
.
tv_nsec
;
}
else
{
sec
--
;
nsec
=
(
1000000000L
+
tafter
.
tv_nsec
)
-
tbefore
.
tv_nsec
;
}
printf
(
"Total time: %ld.%09ld
\n
"
,
sec
,
nsec
);
it_total
=
repeat
*
it_count
;
us_time
=
((
float
)
sec
)
*
(
1
/
it_total
*
1000000
);
us_time
+=
((
float
)
nsec
)
/
(
it_total
*
1000
);
us_busy_once
=
us_time
-
us_sleep_time
;
ms_total_sleep
=
(
float
)(
us_sleep_time
*
it_total
)
/
1000000
;
}
printf
(
"Repeat: %d; Loop: %d; usleep %dus (one) %.2fms (total)
\n
"
,
repeat
,
it_count
,
us_sleep_time
,
ms_total_sleep
);
printf
(
"------------------
\n
"
);
printf
(
"Busy once : %1.fus
\n
"
,
us_busy_once
);
finish_data_ready
();
}
void
action
(
int
it
)
{
usleep
(
us_sleep_time
);
}
void
benchmark
(
void
)
{
static
int
i
;
for
(
i
=
0
;
i
<
it_count
;
++
i
)
{
action
(
i
);
}
}
int
main
(
int
argc
,
char
**
argv
)
{
struct
timeval
before
,
after
;
int
i
;
benchmark
();
// warm-up
clock_gettime
(
CLOCK_MONOTONIC_RAW
,
&
tbefore
);
for
(
i
=
0
;
i
<
repeat
;
++
i
)
{
benchmark
();
}
clock_gettime
(
CLOCK_MONOTONIC_RAW
,
&
tafter
);
finish
(
before
,
after
);
return
EXIT_SUCCESS
;
}
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