-
Notifications
You must be signed in to change notification settings - Fork 451
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
add windows crash_dump support & sys split #713
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.vscode/ | ||
dev.sh | ||
target/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
name = "plugins" | ||
version = "0.1.0" | ||
authors = ["zhanglei.sec <[email protected]>"] | ||
edition = "2018" | ||
edition = "2021" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
[features] | ||
|
@@ -23,9 +23,24 @@ serde_json = "1" | |
protobuf-codegen-pure = "2.3" | ||
|
||
[dependencies.windows] | ||
version = "0.48.0" | ||
version = "0.58.0" | ||
features = [ | ||
"Win32_System_Diagnostics_ToolHelp", | ||
"Win32_Foundation", | ||
"Win32_Security", | ||
"Win32_Storage_FileSystem", | ||
"Win32_System_Console", | ||
"Win32_System_Services", | ||
"Win32_System_Kernel", | ||
"Win32_System_JobObjects", | ||
"Win32_System_Memory", | ||
"Win32_System_Threading", | ||
"Win32_System_Diagnostics", | ||
"Win32_System_Diagnostics_ToolHelp", | ||
"Win32_System_Diagnostics_Debug_Extensions", | ||
] | ||
|
||
|
||
# Library dependencies (Windows) | ||
[target.'cfg(target_os = "windows")'.dependencies] | ||
anyhow = "1.0" | ||
zip = "2.2" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#[cfg(target_family = "windows")] | ||
pub mod windows; | ||
#[cfg(target_family = "windows")] | ||
pub use windows::*; | ||
|
||
#[cfg(target_family = "unix")] | ||
pub mod unix; | ||
#[cfg(target_family = "unix")] | ||
pub use unix::*; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
use std::os::unix::prelude::FromRawFd; | ||
|
||
#[cfg(feature = "debug")] | ||
const READ_PIPE_FD: i32 = 0; | ||
#[cfg(not(feature = "debug"))] | ||
const READ_PIPE_FD: i32 = 3; | ||
#[cfg(feature = "debug")] | ||
const WRITE_PIPE_FD: i32 = 1; | ||
#[cfg(not(feature = "debug"))] | ||
const WRITE_PIPE_FD: i32 = 4; | ||
const HIGH_PRIORIT_FD: i32 = 5; | ||
|
||
use std::{ | ||
fs::File, | ||
io::{BufReader, BufWriter}, | ||
sync::Arc, | ||
}; | ||
|
||
use parking_lot::Mutex; | ||
|
||
pub fn get_writer() -> Arc<Mutex<BufWriter<File>>> { | ||
Arc::new(Mutex::new(BufWriter::with_capacity(512 * 1024, unsafe { | ||
File::from_raw_fd(WRITE_PIPE_FD) | ||
}))) | ||
} | ||
|
||
pub fn get_high_writer() -> Arc<Mutex<BufWriter<File>>> { | ||
Arc::new(Mutex::new(BufWriter::with_capacity(512 * 1024, unsafe { | ||
File::from_raw_fd(HIGH_PRIORIT_FD) | ||
}))) | ||
} | ||
|
||
pub fn get_reader() -> Arc<Mutex<BufReader<File>>> { | ||
Arc::new(Mutex::new(BufReader::with_capacity(512 * 1024, unsafe { | ||
File::from_raw_fd(READ_PIPE_FD) | ||
}))) | ||
} | ||
|
||
extern "C" fn signal_handler(signal: i32) { | ||
eprintln!("catched signal {:?}, wait 3 seconds and exit", signal); | ||
unsafe { | ||
libc::sleep(3); | ||
libc::close(WRITE_PIPE_FD); | ||
libc::close(READ_PIPE_FD); | ||
if libc::fcntl(HIGH_PRIORIT_FD, libc::F_GETFD) != -1 | ||
|| std::io::Error::last_os_error().kind() != std::io::ErrorKind::InvalidInput | ||
{ | ||
libc::close(READ_PIPE_FD); | ||
} | ||
} | ||
} | ||
|
||
pub fn ignore_terminate() { | ||
unsafe { | ||
libc::signal(libc::SIGINT, libc::SIG_IGN); | ||
libc::signal(libc::SIGUSR1, libc::SIG_IGN); | ||
libc::signal(libc::SIGTERM, signal_handler as _); | ||
} | ||
} | ||
|
||
pub fn regist_exception_handler() {} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
这里应该使用HIGH_PRIORIT_FD吧
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.
done