Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement lldb-mi --versionFull to show underlying llvm-project version info #110

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/MICmnResources.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ const CMICmnResources::SRsrcTextData
{IDE_MI_APP_ARG_VERSION_LONG, "--versionLong\n\tPrints out MI Driver "
"version information. Exit the MI "
"Driver\n\timmediately."},
{IDE_MI_APP_ARG_VERSION_FULL, "--versionFull\n\tPrints out MI Driver "
"full version information including lldb"
" llvm clang versions. Exit the MI "
"Driver\n\timmediately."},
{IDE_MI_APP_ARG_INTERPRETER, "--interpreter\n\t This option is kept "
"for backward compatibility. This "
"executable always run in MI mode"},
Expand Down
1 change: 1 addition & 0 deletions src/MICmnResources.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ enum {
IDE_MI_APP_ARG_HELP,
IDE_MI_APP_ARG_VERSION,
IDE_MI_APP_ARG_VERSION_LONG,
IDE_MI_APP_ARG_VERSION_FULL,
IDE_MI_APP_ARG_INTERPRETER,
IDE_MI_APP_ARG_EXECUTEABLE,
IDE_MI_APP_ARG_SOURCE,
Expand Down
16 changes: 16 additions & 0 deletions src/MIDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ const CMIUtilString CMIDriver::ms_constMIVersion =
const CMIUtilString
CMIDriver::ms_constAppNameShort(MIRSRC(IDS_MI_APPNAME_SHORT));
const CMIUtilString CMIDriver::ms_constAppNameLong(MIRSRC(IDS_MI_APPNAME_LONG));
CMIUtilString CMIDriver::ms_MIVersionFull = "";

//++
// Details: CMIDriver constructor.
Expand Down Expand Up @@ -134,6 +135,21 @@ const CMIUtilString &CMIDriver::GetVersionDescription() const {
return ms_constMIVersion;
}

//++
// Details: Retrive MI's lldb version decription.
// Type: Method.
// Args: None.
// Return: CMIUtilString & - Text description.
// Throws: None.
//--
const CMIUtilString &CMIDriver::GetVersionDescriptionFull() {
if (ms_MIVersionFull == "") {
ms_MIVersionFull =
CMICmnLLDBDebugSessionInfo::Instance().GetDebugger().GetVersionString();
}
return ms_MIVersionFull;
}

//++
// Details: Initialize setup *this driver ready for use.
// Type: Method.
Expand Down
2 changes: 2 additions & 0 deletions src/MIDriver.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ class CMIDriver : public CMICmnBase,
const CMIUtilString &GetAppNameShort() const;
const CMIUtilString &GetAppNameLong() const;
const CMIUtilString &GetVersionDescription() const;
const CMIUtilString &GetVersionDescriptionFull();

// MI do work
bool WriteMessageToLog(const CMIUtilString &vMessage);
Expand Down Expand Up @@ -154,6 +155,7 @@ class CMIDriver : public CMICmnBase,
static const CMIUtilString ms_constAppNameShort;
static const CMIUtilString ms_constAppNameLong;
static const CMIUtilString ms_constMIVersion;
static CMIUtilString ms_MIVersionFull;
//
bool m_bFallThruToOtherDriverEnabled; // True = yes fall through, false = do
// not pass on command
Expand Down
31 changes: 31 additions & 0 deletions src/MIDriverMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,7 @@ bool CMIDriverMgr::ParseArgs(const int argc, const char *argv[],
bool bHaveArgInterpret = false;
bool bHaveArgVersion = false;
bool bHaveArgVersionLong = false;
bool bHaveArgVersionFull = false;
bool bHaveArgLog = false;
bool bHaveArgLogDir = false;
bool bHaveArgHelp = false;
Expand All @@ -513,6 +514,9 @@ bool CMIDriverMgr::ParseArgs(const int argc, const char *argv[],
if ("--versionLong" == strArg) {
bHaveArgVersionLong = true;
}
if ("--versionFull" == strArg) {
bHaveArgVersionFull = true;
}
if ("--log" == strArg) {
bHaveArgLog = true;
}
Expand Down Expand Up @@ -555,6 +559,15 @@ bool CMIDriverMgr::ParseArgs(const int argc, const char *argv[],
return bOk;
}

// Todo: Make this the --version when the above --version version is removed
// Handle --versionlong option (ignore the --interpreter option if present)
if (bHaveArgVersionFull) {
vwbExiting = true;
bOk = (bOk &&
CMICmnStreamStdout::Instance().WriteMIResponse(GetAppVersionFull()));
return bOk;
}

// Both '--help' and '--interpreter' means give help for MI only. Without
// '--interpreter' help the LLDB driver is working and so help is for that.
if (bHaveArgHelp && bHaveArgInterpret) {
Expand Down Expand Up @@ -603,6 +616,23 @@ CMIUtilString CMIDriverMgr::GetAppVersion() const {
return strVrsnInfo;
}

//++
// Details: Return formatted application version and name information.
// Type: Method.
// Args: None.
// Return: CMIUtilString - Text data.
// Throws: None.
//--
CMIUtilString CMIDriverMgr::GetAppVersionFull() const {
const CMIUtilString strProj(MIRSRC(IDS_PROJNAME));
const CMIUtilString strVn(CMIDriver::Instance().GetVersionDescriptionFull());
const CMIUtilString strGdb(MIRSRC(IDE_MI_VERSION_GDB));
const CMIUtilString strVrsnInfo(CMIUtilString::Format(
"%s\n%s\n%s", strProj.c_str(), strVn.c_str(), strGdb.c_str()));

return strVrsnInfo;
}

//++
// Details: Return formatted help information on all the MI command line
// options.
Expand All @@ -619,6 +649,7 @@ CMIUtilString CMIDriverMgr::GetHelpOnCmdLineArgOptions() const {
MIRSRC(IDE_MI_APP_ARG_HELP),
MIRSRC(IDE_MI_APP_ARG_VERSION),
MIRSRC(IDE_MI_APP_ARG_VERSION_LONG),
MIRSRC(IDE_MI_APP_ARG_VERSION_FULL),
MIRSRC(IDE_MI_APP_ARG_INTERPRETER),
MIRSRC(IDE_MI_APP_ARG_SOURCE),
MIRSRC(IDE_MI_APP_ARG_EXECUTEABLE),
Expand Down
1 change: 1 addition & 0 deletions src/MIDriverMgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ class CMIDriverMgr : public CMICmnBase, public MI::ISingleton<CMIDriverMgr> {
bool Shutdown() override;
//
CMIUtilString GetAppVersion() const;
CMIUtilString GetAppVersionFull() const;
bool RegisterDriver(const IDriver &vrADriver,
const CMIUtilString &vrDriverID);
bool UnregisterDriver(const IDriver &vrADriver);
Expand Down