[solidity,llvm-context] Improve support for debugging the compiler (#32)

Add option --recursive-process-input <filename> for use with
--recursive-process to specify the name of a file to use instead of
reading from stdin.

If --debug-output-dir is set, dump the file passed to the recursive
invocation of the compiler as a JSON file suitable for use with
--recursive-process-input.

These changes are intended to support debugging the compiler and are
only available with DEBUG builds.
This commit is contained in:
wpt967
2024-08-23 17:18:07 +01:00
committed by GitHub
parent 184d40d377
commit bb4a4dddde
5 changed files with 77 additions and 3 deletions
+20
View File
@@ -164,6 +164,12 @@ pub struct Arguments {
/// Only for usage from within the compiler.
#[structopt(long = "recursive-process")]
pub recursive_process: bool,
/// Specify the input file to use instead of stdin when --recursive-process is given.
/// This is only intended for use when developing the compiler.
#[cfg(debug_assertions)]
#[structopt(long = "recursive-process-input")]
pub recursive_process_input: Option<String>,
}
impl Default for Arguments {
@@ -185,6 +191,20 @@ impl Arguments {
anyhow::bail!("No other options are allowed while getting the compiler version.");
}
#[cfg(debug_assertions)]
if self.recursive_process_input != None && !self.recursive_process {
anyhow::bail!("--process-input can be only used when --recursive-process is given");
}
#[cfg(debug_assertions)]
if self.recursive_process
&& ((self.recursive_process_input == None && std::env::args().count() > 2)
|| (self.recursive_process_input != None && std::env::args().count() > 4))
{
anyhow::bail!("No other options are allowed in recursive mode.");
}
#[cfg(not(debug_assertions))]
if self.recursive_process && std::env::args().count() > 2 {
anyhow::bail!("No other options are allowed in recursive mode.");
}