Skip to content
This repository has been archived by the owner on Apr 2, 2019. It is now read-only.

ignore arguments that start with + #41

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

colinschmidt
Copy link
Contributor

This causes htif to skip unknown arguments that start with +.

Other arguments that start with - will still issue stderr messages but not stop option parsing.

This is an improvement on current handling where htif will silently treat unknown arguments that start with + as target arguments.

Open to suggestions but this is a strawman for handling chipsalliance/rocket-chip#1194

@mwachs5
Copy link
Contributor

mwachs5 commented Jan 18, 2018

@seldridge does this make sense with chipsalliance/rocket-chip#1192?

@seldridge
Copy link
Contributor

Yes, they should be mutually exclusive as HTIF argument parsing happens after emulator.cc argument parsing. The PlusArg PR (chipsalliance/rocket-chip#1192) effectively only generates your plusarg struct and the help text based on Chisel code. So, if this PR works with rocket-chip master then the chipsalliance/rocket-chip#1192 shouldn't be an incompatible approach.

Famous last words, however, as I keep delaying testing this with VCS (it's a pain for a variety of reasons...) and there are no regressions that bang on these specific plus args...

@@ -246,8 +246,11 @@ void htif_t::parse_arguments(int argc, char ** argv)
optarg = optarg + 8;
}
else {
optind--;
goto done_processing;
if(arg.find("+") != 0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't this say, "if the argument contains a + anywhere besides the first character, stop parsing arguments"? Should it be if (arg.find("+") == std::string::npos)?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is okay. find should return something non-zero (or npos which is a big number) if it finds something that doesn't start with a +. Looking for npos would be too restrictive as there could be a binary with a + in the middle of it. It's a stretch, but possible.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants