diff options
author | Andrzej Janik <[email protected]> | 2021-12-13 22:25:26 +0100 |
---|---|---|
committer | Andrzej Janik <[email protected]> | 2021-12-13 22:25:26 +0100 |
commit | 0ca14d740fcf76579d17f5b573f3f003f04592bc (patch) | |
tree | e865c53ab545b9c1a6dd9748f340d4c566c9ed1f /zluda_dump/src/trace.rs | |
parent | 7ba1586d6c6336c50b5b13809fec5f42f3f78a21 (diff) | |
download | ZLUDA-0ca14d740fcf76579d17f5b573f3f003f04592bc.tar.gz ZLUDA-0ca14d740fcf76579d17f5b573f3f003f04592bc.zip |
Better reporting of unrecognized tokens
Diffstat (limited to 'zluda_dump/src/trace.rs')
-rw-r--r-- | zluda_dump/src/trace.rs | 39 |
1 files changed, 17 insertions, 22 deletions
diff --git a/zluda_dump/src/trace.rs b/zluda_dump/src/trace.rs index 3bdf807..eac6bbd 100644 --- a/zluda_dump/src/trace.rs +++ b/zluda_dump/src/trace.rs @@ -1,4 +1,5 @@ use ptx::{ast::PtxError, Token};
+use ptx::{DisplayParseError, ModuleParserExt};
use crate::{cuda::CUmodule, dark_api, log, Settings};
use std::{
@@ -170,24 +171,18 @@ impl StateTracker { submodule_index: Option<usize>,
module_text: &str,
) {
- let mut errors = Vec::new();
- let ast = ptx::ModuleParser::new().parse(&mut errors, module_text);
- let ast = match (&*errors, ast) {
- (&[], Ok(ast)) => ast,
- (err_vec, res) => {
- fn_logger.log(log::LogEntry::ModuleParsingError(
- DumpWriter::get_file_name(module_index, version, submodule_index, "log"),
- ));
- fn_logger.log_io_error(self.writer.save_module_error_log(
- module_index,
- version,
- submodule_index,
- err_vec,
- res.err(),
- ));
- return;
- }
- };
+ let (ast, errors) = ptx::ModuleParser::parse_unchecked(module_text);
+ if !errors.is_empty() {
+ fn_logger.log(log::LogEntry::ModuleParsingError(
+ DumpWriter::get_file_name(module_index, version, submodule_index, "log"),
+ ));
+ fn_logger.log_io_error(self.writer.save_module_error_log(
+ module_index,
+ version,
+ submodule_index,
+ &*errors,
+ ));
+ }
}
pub(crate) fn module_exists(&self, hmod: CUmodule) -> bool {
@@ -238,8 +233,7 @@ impl DumpWriter { module_index: usize,
version: Option<usize>,
submodule_index: Option<usize>,
- recoverable: &[ptx::ParseError<usize, Token<'input>, PtxError>],
- unrecoverable: Option<ptx::ParseError<usize, Token<'input>, PtxError>>,
+ errors: &[ptx::ParseError<usize, Token<'input>, PtxError>],
) -> io::Result<()> {
let mut log_file = match &self.dump_dir {
None => return Ok(()),
@@ -252,8 +246,9 @@ impl DumpWriter { "log",
));
let mut file = File::create(log_file)?;
- for error in unrecoverable.iter().chain(recoverable.iter()) {
- writeln!(file, "{}", error)?;
+ for error in errors {
+ let pretty_print_error = DisplayParseError("", error);
+ writeln!(file, "{}", pretty_print_error)?;
}
Ok(())
}
|