Skip to content

Commit

Permalink
CR 1217061 : xrt-smi advanced --help prints Alveo help (#8545)
Browse files Browse the repository at this point in the history
* CR-1217061 revert

Signed-off-by: Akshay Tondak <[email protected]>

* CR-1217061 fix

Signed-off-by: Akshay Tondak <[email protected]>

* Adding missing line

Signed-off-by: Akshay Tondak <[email protected]>

* Adding missing code

Signed-off-by: Akshay Tondak <[email protected]>

* Taking care of empty error handling

Signed-off-by: Akshay Tondak <[email protected]>

---------

Signed-off-by: Akshay Tondak <[email protected]>
Co-authored-by: Akshay Tondak <[email protected]>
  • Loading branch information
aktondak and Akshay Tondak authored Oct 23, 2024
1 parent ace6f9d commit 4bc431f
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 27 deletions.
32 changes: 13 additions & 19 deletions src/runtime_src/core/tools/xbutil2/OO_Reports.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,19 @@ print_preemption_telemetry(const xrt_core::device* device)
// ----- C L A S S M E T H O D S -------------------------------------------

OO_Reports::OO_Reports( const std::string &_longName, bool _isHidden )
: OptionOptions(_longName, _isHidden, "Hidden reports")
: OptionOptions(_longName, _isHidden, "Reports to generate: clocks, preemption")
, m_device("")
, m_action("")
, m_help(false)
{
m_optionsDescription.add_options()
("device,d", boost::program_options::value<decltype(m_device)>(&m_device), "The Bus:Device.Function (e.g., 0000:d8:00.0) device of interest")
("help", boost::program_options::bool_switch(&m_help), "Help to use this sub-command")
("mode", boost::program_options::value<decltype(m_action)>(&m_action)->required(), "Action to perform: clocks, preemption")
;

m_optionsHidden.add_options()
("mode", boost::program_options::value<decltype(m_action)>(&m_action)->implicit_value(""), "Reports to generate: clocks, preemption");

m_positionalOptions.
add("mode", 1 /* max_count */)
;
Expand All @@ -96,25 +98,17 @@ OO_Reports::execute(const SubCmdOptions& _options) const

// Parse sub-command ...
po::variables_map vm;
process_arguments(vm, _options);

try {
po::options_description all_options("All Options");
all_options.add(m_optionsDescription);
po::command_line_parser parser(_options);
XBUtilities::process_arguments(vm, parser, all_options, m_positionalOptions, true);
} catch(boost::program_options::error&) {
if(m_help) {
printHelp();
throw xrt_core::error(std::errc::operation_canceled);
}
// Exit if neither action or device specified
if(m_action.empty()) {
std::cerr << boost::format("ERROR: the required argument for option '--report' is missing\n");
printHelp();
throw xrt_core::error(std::errc::operation_canceled);
}
if (m_help) {
printHelp();
return;
}
if(m_action.empty()) {
std::cerr << boost::format("ERROR: the required argument for option '--report' is missing\n");
printHelp();
throw xrt_core::error(std::errc::operation_canceled);
}

// Find device of interest
std::shared_ptr<xrt_core::device> device;

Expand Down
14 changes: 6 additions & 8 deletions src/runtime_src/core/tools/xbutil2/SubCmdAdvanced.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ namespace po = boost::program_options;

SubCmdAdvanced::SubCmdAdvanced(bool _isHidden, bool _isDepricated, bool _isPreliminary, const boost::property_tree::ptree& configurations)
: SubCmd("advanced",
"Low level command operations")
"Low level command operations"),
m_device("")
{
const std::string longDescription = "Low level command operations.";
setLongDescription(longDescription);
Expand All @@ -45,6 +46,7 @@ SubCmdAdvanced::SubCmdAdvanced(bool _isHidden, bool _isDepricated, bool _isPreli
setIsPreliminary(_isPreliminary);

m_commonOptions.add_options()
("device,d", boost::program_options::value<decltype(m_device)>(&m_device), "The Bus:Device.Function (e.g., 0000:d8:00.0) device of interest")
("help", boost::program_options::bool_switch(&m_help), "Help to use this sub-command")
;

Expand Down Expand Up @@ -77,17 +79,13 @@ SubCmdAdvanced::execute(const SubCmdOptions& _options) const
auto optionOption = checkForSubOption(vm);

// No suboption print help
if (!optionOption) {
printHelp();
if (!optionOption || m_help) {
printHelp(false, "", XBU::get_device_class(m_device, true));
return;
}

// 2) Process the top level options
if (m_help)
topOptions.push_back("--help");

optionOption->setGlobalOptions(getGlobalOptions());

// Execute the option
optionOption->execute(topOptions);
optionOption->execute(_options);
}
1 change: 1 addition & 0 deletions src/runtime_src/core/tools/xbutil2/SubCmdAdvanced.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class SubCmdAdvanced : public SubCmd {

private:
bool m_help;
std::string m_device;
};

#endif
Expand Down

0 comments on commit 4bc431f

Please sign in to comment.