diff options
author | Andrzej Janik <[email protected]> | 2021-11-16 02:07:50 +0100 |
---|---|---|
committer | Andrzej Janik <[email protected]> | 2021-11-16 02:07:50 +0100 |
commit | 24e100cb9c6101ecd04def6ac8cf6605f8df8c94 (patch) | |
tree | d45c95e5b2ad605991088584749fc00b04af7fe3 /zluda_dump/src/log.rs | |
parent | e459086c5bfb84ff3b382e65a95d0c6d162266fb (diff) | |
download | ZLUDA-24e100cb9c6101ecd04def6ac8cf6605f8df8c94.tar.gz ZLUDA-24e100cb9c6101ecd04def6ac8cf6605f8df8c94.zip |
Start converting cuModuleLoad to the new tracing infrastructure
Diffstat (limited to 'zluda_dump/src/log.rs')
-rw-r--r-- | zluda_dump/src/log.rs | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/zluda_dump/src/log.rs b/zluda_dump/src/log.rs index ca8a1ef..4ffc459 100644 --- a/zluda_dump/src/log.rs +++ b/zluda_dump/src/log.rs @@ -1,14 +1,17 @@ +use crate::cuda::CUmodule;
use crate::cuda::CUuuid;
use super::CUresult;
use super::Settings;
use std::borrow::Cow;
use std::error::Error;
+use std::ffi::c_void;
use std::fmt::Display;
use std::fs::File;
use std::io;
use std::io::Stderr;
use std::io::Write;
+use std::str::Utf8Error;
const LOG_PREFIX: &[u8] = b"[ZLUDA_DUMP] ";
@@ -237,6 +240,12 @@ impl<'a> FunctionLogger<'a> { self.log_queue.push(l);
}
+ pub(crate) fn log_io_error(&mut self, error: io::Result<()>) {
+ if let Err(e) = error {
+ self.log_queue.push(LogEntry::IoError(e));
+ }
+ }
+
fn flush_log_queue_to_write_buffer(&mut self) {
self.write_buffer.start_line();
self.write_buffer.write(&self.name);
@@ -284,6 +293,14 @@ impl<'a> Drop for FunctionLogger<'a> { pub(crate) enum LogEntry {
IoError(io::Error),
ErrorBox(Box<dyn Error>),
+ UnsupportedModule {
+ module: CUmodule,
+ raw_image: *const c_void,
+ kind: &'static str,
+ },
+ MalformedModulePath(Utf8Error),
+ MalformedModuleText(Utf8Error),
+ ModuleParsingError(usize),
}
impl Display for LogEntry {
@@ -291,6 +308,26 @@ impl Display for LogEntry { match self {
LogEntry::IoError(e) => e.fmt(f),
LogEntry::ErrorBox(e) => e.fmt(f),
+ LogEntry::UnsupportedModule {
+ module,
+ raw_image,
+ kind,
+ } => {
+ write!(
+ f,
+ "Unsupported {} module {:?} loaded from module image {:?}",
+ kind, module, raw_image
+ )
+ }
+ LogEntry::MalformedModulePath(e) => e.fmt(f),
+ LogEntry::MalformedModuleText(e) => e.fmt(f),
+ LogEntry::ModuleParsingError(index) => {
+ write!(
+ f,
+ "Error parsing module, log has been written to module_{:04}.log",
+ index
+ )
+ }
}
}
}
|