-
Notifications
You must be signed in to change notification settings - Fork 29
Common casr tool #259
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Common casr tool #259
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #259 +/- ##
==========================================
- Coverage 66.64% 64.47% -2.17%
==========================================
Files 34 39 +5
Lines 8266 7629 -637
==========================================
- Hits 5509 4919 -590
+ Misses 2757 2710 -47 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
let output = Command::new(EXE_CASR_SAN) | ||
.args(["--stdout", "--", &paths[1]]) | ||
let output = Command::new(EXE_CASR) | ||
.args(["asan", "--stdout", "--", &paths[1]]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AFAIR, casr-san handles all sanitizers (e.g., msan). Maybe, we should rename casr asan
to casr san
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, there is san
mod for backward capability with bahaviour that is equal to casr-san
, asan
and msan
modes are needed for explicit indication for the parser when we are confident in it and do not want to try to guess it. The equal case for go
and rust
@@ -0,0 +1,121 @@ | |||
//! Gdb module implements `ParseStacktrace`, `Exception` and `Severity` traits for Gdb output. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These docs should be updated, I suppose
maps: Vec<String>, | ||
report: Vec<String>, | ||
stream: String, | ||
stacktrace: Option<Stacktrace>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, add docs to all fields
}; | ||
use regex::Regex; | ||
/// Structure provides an interface for save parsing gdb crash. | ||
pub struct GdbCrash { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'd better call it GdbCrashReport or GdbCrashInfo
return Err(Error::Casr("Unable to get results from gdb".to_string())); | ||
}; | ||
let stream = String::from_utf8_lossy(&stream); | ||
let stream = stream.to_string(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we actually need this to_string?
} | ||
/// Get disassembly | ||
pub fn disassembly(&self) -> &str { | ||
&self.report[5] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't we add it to GdbContext? I'm not sure by the way...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How does a lib user know, that the disassmebly is inside someRandomField[someRandomNumber]
?
/// Structure provides an interface for save parsing some sanitizer crash. | ||
#[derive(Clone, Debug)] | ||
pub struct SanCrash { | ||
context: StacktraceContext, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is just a duplicate of StacktraceContext, do we need a new structure here? Or we can just create an alias?
|
||
impl AsanCrash { | ||
/// Create new `AsanCrash` instance from stream | ||
pub fn new(stream: &str) -> Result<Option<Self>> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
btw, we need some library tests for newly added functions.
@@ -116,7 +120,24 @@ impl ParseStacktrace for CSharpStacktrace { | |||
} | |||
|
|||
/// Structure provides an interface for parsing c# exception message. | |||
pub struct CSharpException; | |||
pub struct CSharpException { | |||
context: StacktraceContext, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the same here, mostly looks like a duplicate structure
@@ -20,7 +22,7 @@ impl ParseStacktrace for JavaStacktrace { | |||
conv_counter: usize, | |||
} | |||
// Get java stack trace. | |||
let re = Regex::new(r"(?m)^(?:Caused by:|Exception in thread|== Java Exception:)(?:.|\n)*?((?:\n\s+at .*\(.*\))+)(?:\n\s+\.\.\. (\d+) more)?").unwrap(); | |||
let re = Regex::new(r"(?m)^(?:Caused by:|Exception in thread|== Java Exception:)(?:.|\n)*?((?:\n\s*at .*\(.*\))+)(?:\n\s*\.\.\. (\d+) more)?").unwrap(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we upstream first this change in a separate PR?
|
||
impl PythonException { | ||
/// Create new `PythonException` instance from Python output | ||
fn new_from_python(stream: &str) -> Result<Option<Self>> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can just call it from_python
let sub = matches.subcommand(); | ||
for arg in args { | ||
if !matches.contains_id(arg) && (sub.is_none() || !sub.unwrap().1.contains_id(arg)) { | ||
bail!("The following argument is required: {}", arg); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this the same message as clap throws?
casr_cmd.envs(&self.envs); | ||
|
||
// Add envs | ||
if self.target_args.iter().any(|x| x.eq("-detect_leaks=0")) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we remove this code?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We dоn't, just move it to the upper function
impl fmt::Display for Mode { | ||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | ||
let s = match self { | ||
Mode::Csharp => "csharp", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can store string mapping for enum somewhere, so, we don't repeate the same string constants
This function is a reverse function of new()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is more optimal way then searching in map
use goblin::container::Endian; | ||
use goblin::elf::{Elf, header}; | ||
|
||
pub fn gdb_run( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe, some of the code here can be moved to libcasr
Ok(()) | ||
} | ||
|
||
pub fn prepare_run(argv: &mut [String], mode: &Mode) -> Result<()> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we reduce copy-paste here? So, adding new cast tools could be easier
Nobody wanted it, nobody asked it, but we did it anyway.