Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
K
klee
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Per Lindgren
klee
Commits
ec4de17d
Commit
ec4de17d
authored
Dec 23, 2018
by
Per Lindgren
Browse files
Options
Downloads
Patches
Plain Diff
cargo subcommand with gdb
parent
f19164d4
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
cargo-klee/src/main.rs
+43
-4
43 additions, 4 deletions
cargo-klee/src/main.rs
with
43 additions
and
4 deletions
cargo-klee/src/main.rs
+
43
−
4
View file @
ec4de17d
...
...
@@ -2,7 +2,7 @@ extern crate libc;
use
std
::{
env
,
fs
,
path
::
PathBuf
,
path
::
{
Path
,
PathBuf
}
,
process
::{
self
,
Command
},
time
::
SystemTime
,
};
...
...
@@ -90,6 +90,12 @@ fn run() -> Result<i32, failure::Error> {
.short
(
"r"
)
.help
(
"Generate replay binary in target directory [default: <NAME>.replay]"
),
)
.arg
(
Arg
::
with_name
(
"gdb"
)
.long
(
"gdb"
)
.short
(
"g"
)
.help
(
"Run the generated replay binary in gdb"
),
)
.get_matches
();
let
is_example
=
matches
.is_present
(
"example"
);
...
...
@@ -98,10 +104,11 @@ fn run() -> Result<i32, failure::Error> {
let
is_release
=
matches
.is_present
(
"release"
);
let
is_replay
=
matches
.is_present
(
"replay"
);
let
is_ktest
=
matches
.is_present
(
"ktest"
);
let
is_gdb
=
matches
.is_present
(
"gdb"
);
// let target_flag = matches.value_of("target"); // not supported
let
file
=
if
is_
binary
{
let
file
=
if
is_
example
{
matches
.value_of
(
"example"
)
.unwrap
()
}
else
{
matches
.value_of
(
"bin"
)
.unwrap
()
...
...
@@ -220,6 +227,8 @@ fn run() -> Result<i32, failure::Error> {
}
}
let
mut
obj
=
ll
.clone
()
.unwrap
();
let
replay_name
=
obj
.with_file_name
(
file
)
.with_extension
(
"replay"
);
if
is_replay
{
// compile to object code for replay using llc
// llc -filetype=obj -relocation-model=pic target/<debug|release>/examples/foo-<hash>.ll
...
...
@@ -240,10 +249,9 @@ fn run() -> Result<i32, failure::Error> {
// compile to executable for replay using clang
// clang target/<debug|release>/examples/foo-<hash>.o -lkleeRuntest
let
mut
clang
=
Command
::
new
(
"clang"
);
let
mut
obj
=
ll
.clone
()
.unwrap
();
obj
=
obj
.with_extension
(
"o"
);
let
replay_name
=
obj
.with_file_name
(
file
)
.with_extension
(
"replay"
);
println!
(
"file {:?}"
,
replay_name
);
clang
.arg
(
obj
)
...
...
@@ -275,6 +283,37 @@ fn run() -> Result<i32, failure::Error> {
return
Ok
(
status
.code
()
.unwrap_or
(
1
));
}
}
// gdb
println!
(
"{:?}"
,
env
::
var_os
(
"GDB_CWD"
));
if
is_gdb
{
let
mut
gdb
=
Command
::
new
(
"gdb"
);
// run gdb in the target/target/<debug|release>/examples/ directory
if
let
Ok
(
cwd
)
=
env
::
var
(
"GDB_CWD"
)
{
// set gdb current dir to GDB_CWD
gdb
.current_dir
(
cwd
);
// set replay name to be loaded by gdb
gdb
.arg
(
replay_name
);
}
else
{
// set gdb current dir to the target directory
gdb
.current_dir
(
replay_name
.parent
()
.unwrap
());
// set replay name to be loaded by gdb
gdb
.arg
(
replay_name
.file_name
()
.unwrap
());
};
//gdb.current_dir(cwd);
//gdb.arg();
if
verbose
{
eprintln!
(
"
\n
{:?}
\n
"
,
gdb
);
}
// TODO: better error handling, e.g., if gdb is not installed/in path
let
status
=
gdb
.status
()
?
;
if
!
status
.success
()
{
println!
(
"gdb failed: {:?}"
,
status
.code
()
.unwrap_or
(
1
));
}
}
// return to shell without error
Ok
(
0
)
}
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