Index: tools/lldb-mi/MICmnLogMediumFile.h =================================================================== --- tools/lldb-mi/MICmnLogMediumFile.h +++ tools/lldb-mi/MICmnLogMediumFile.h @@ -38,11 +38,12 @@ bool SetHeaderTxt(const CMIUtilString &vText); bool SetVerbosity(const MIuint veType); MIuint GetVerbosity(void) const; - const CMIUtilString &GetFileName(void) const; + const CMIUtilString &GetBaseFileName(void) const; const CMIUtilString &GetFileNamePath(void) const; bool IsOk(void) const; bool IsFileExist(void) const; const CMIUtilString &GetLineReturn(void) const; + bool SetLogDir(const CMIUtilString &vPath); // Overridden: public: @@ -71,9 +72,10 @@ // Attributes: private: const CMIUtilString m_constThisMediumName; - const CMIUtilString m_constMediumFileName; + const CMIUtilString m_constMediumBaseFileName; // CMIUtilString m_fileNamePath; + CMIUtilString m_fileDirectory; MIuint m_eVerbosityType; CMIUtilString m_strDate; CMIUtilString m_fileHeaderTxt; Index: tools/lldb-mi/MICmnLogMediumFile.cpp =================================================================== --- tools/lldb-mi/MICmnLogMediumFile.cpp +++ tools/lldb-mi/MICmnLogMediumFile.cpp @@ -27,8 +27,9 @@ //-- CMICmnLogMediumFile::CMICmnLogMediumFile(void) : m_constThisMediumName(MIRSRC(IDS_MEDIUMFILE_NAME)) - , m_constMediumFileName("lldb-mi-log.txt") + , m_constMediumBaseFileName("lldb-mi") , m_fileNamePath(MIRSRC(IDS_MEDIUMFILE_ERR_INVALID_PATH)) + , m_fileDirectory(MIRSRC(IDS_MEDIUMFILE_ERR_INVALID_PATH)) , m_eVerbosityType(CMICmnLog::eLogVerbosity_Log) , m_strDate(CMIUtilDateTimeStd().GetDate()) , m_fileHeaderTxt(MIRSRC(IDS_MEDIUMFILE_ERR_FILE_HEADER)) @@ -213,21 +214,14 @@ m_fileNamePath = MIRSRC(IDS_MEDIUMFILE_ERR_INVALID_PATH); - CMIUtilString strPathName; - if (CMIUtilSystem().GetLogFilesPath(strPathName)) + if (m_fileDirectory.compare(MIRSRC(IDS_MEDIUMFILE_ERR_INVALID_PATH)) != 0 || CMIUtilSystem().GetLogFilesPath(m_fileDirectory)) { - const CMIUtilString strPath = CMIUtilFileStd::StripOffFileName(strPathName); + CMIUtilDateTimeStd date; -// ToDo: Review this LINUX log file quick fix so not hidden -// AD: -// Linux was creating a log file here called '.\log.txt'. The '.' on linux -// signifies that this file is 'hidden' and not normally visible. A quick fix -// is to remove the path component all together. Linux also normally uses '/' -// as directory separators, again leading to the problem of the hidden log. #if defined(_MSC_VER) - m_fileNamePath = CMIUtilString::Format("%s\\%s", strPath.c_str(), m_constMediumFileName.c_str()); + m_fileNamePath = CMIUtilString::Format("%s\\%s-%s.log", m_fileDirectory.c_str(), m_constMediumBaseFileName.c_str(), date.GetDateTimeLogFilename().c_str()); #else - m_fileNamePath = CMIUtilString::Format("%s", m_constMediumFileName.c_str()); + m_fileNamePath = CMIUtilString::Format("%s/%s-%s.log", m_fileDirectory.c_str(), m_constMediumBaseFileName.c_str(), date.GetDateTimeLogFilename().c_str()); #endif // defined ( _MSC_VER ) return MIstatus::success; @@ -252,16 +246,16 @@ } //++ ------------------------------------------------------------------------------------ -// Details: Retrieve the medium file's name. +// Details: Retrieve the medium file's base name. // Type: Method. // Args: None. -// Return: CMIUtilString & - File name. +// Return: CMIUtilString & - File base name. // Throws: None. //-- const CMIUtilString & -CMICmnLogMediumFile::GetFileName(void) const +CMICmnLogMediumFile::GetBaseFileName(void) const { - return m_constMediumFileName; + return m_constMediumBaseFileName; } //++ ------------------------------------------------------------------------------------ @@ -426,3 +420,19 @@ { return m_file.GetLineReturn(); } + +//++ ------------------------------------------------------------------------------------ +// Details: Set the diretory to place the log file. +// Type: Method. +// Args: vPath - (R) Path to log. +// Return: MIstatus::success - Functional succeeded. +// MIstatus::failure - Functional failed. +// Throws: None. +//-- +bool +CMICmnLogMediumFile::SetLogDir(const CMIUtilString &vPath) +{ + m_fileDirectory = vPath; + + return FileFormFileNamePath(); +} \ No newline at end of file Index: tools/lldb-mi/MICmnResources.h =================================================================== --- tools/lldb-mi/MICmnResources.h +++ tools/lldb-mi/MICmnResources.h @@ -74,6 +74,7 @@ IDE_MI_APP_ARG_INTERPRETER, IDE_MI_APP_ARG_EXECUTEABLE, IDE_MI_APP_ARG_APP_LOG, + IDE_MI_APP_ARG_APP_LOG_DIR, IDE_MI_APP_ARG_EXAMPLE, IDE_MI_APP_ARG_EXECUTABLE, Index: tools/lldb-mi/MICmnResources.cpp =================================================================== --- tools/lldb-mi/MICmnResources.cpp +++ tools/lldb-mi/MICmnResources.cpp @@ -57,7 +57,7 @@ {IDE_MI_APP_INFORMATION, "Information:\nCurrent limitations. The MI Driver currently only handles remote target\ndebugging. Local " "debugging has not been implemented. The MI Driver has\nbeen designed primarily to be used with Eclipse Juno " "and a custom plugin.\nThe custom plugin is not necessary to operate the MI Driver."}, - {IDE_MI_APP_ARG_USAGE, "\nMI driver usage:\n\n\tlldb-mi [--longOption] [-s hortOption] [executeable]\n\n[] = optional argument."}, + {IDE_MI_APP_ARG_USAGE, "\nMI driver usage:\n\n\tlldb-mi [--longOption] [-s shortOption] [executeable]\n\n[] = optional argument."}, {IDE_MI_APP_ARG_HELP, "-h\n--help\n\tPrints out usage information for the MI debugger. Exit the MI\n\tDriver immediately."}, {IDE_MI_APP_ARG_VERSION, "--version\n\tPrints out GNU (gdb) version information. Exit the MI Driver\n\timmediately."}, {IDE_MI_APP_ARG_VERSION_LONG, "--versionLong\n\tPrints out MI Driver version information. Exit the MI Driver\n\timmediately."}, @@ -64,6 +64,7 @@ {IDE_MI_APP_ARG_INTERPRETER, "--interpreter\n\t This option is kept for backward compatibility. This executable always run in MI mode"}, {IDE_MI_APP_ARG_EXECUTEABLE, "--executable\n\tUse the MI Driver in MI mode for the debugging the specified executable." }, {IDE_MI_APP_ARG_APP_LOG, "--log\n\tUse this argument to tell the MI Driver to update it's log\n\tfile '%s'."}, + {IDE_MI_APP_ARG_APP_LOG_DIR, "--log-dir\n\tUse this argument to specify the directory the MI Driver\n\twill place the log file in, i.e --log-dir=/tmp" }, {IDE_MI_APP_ARG_EXAMPLE, "Example MI command:\n\t3-info-gdb-mi-command gdb-set\n\t3^done,command={exists=\"true\"}"}, {IDE_MI_APP_ARG_EXECUTABLE, "executable (NOT IMPLEMENTED)\n\tThe file path to the executable i.e. '\"C:\\My Dev\\foo.exe\"'."}, {IDS_STDIN_ERR_INVALID_PROMPT, "Stdin. Invalid prompt description '%s'"}, Index: tools/lldb-mi/MIDriverMgr.cpp =================================================================== --- tools/lldb-mi/MIDriverMgr.cpp +++ tools/lldb-mi/MIDriverMgr.cpp @@ -427,6 +427,7 @@ // --versionLong // --log // --executable +// --log-dir // The above arguments are not handled by any driver object except for --executable. // The options --interpreter and --executable in code act very similar. The // --executable is necessary to differentiate whither the MI Driver is being using @@ -436,7 +437,8 @@ // Driver is being called the command line and that the executable argument is indeed // a specified executable an so actions commands to set up the executable for a // debug session. Using --interpreter on the commnd line does not action additional -// commands to initialise a debug session and so be able to launch the process. +// commands to initialise a debug session and so be able to launch the process. The directory +// where the log file is created is specified using --log-dir. // Type: Method. // Args: argc - (R) An integer that contains the count of arguments that follow in // argv. The argc parameter is always greater than or equal to 1. @@ -483,7 +485,9 @@ bool bHaveArgVersion = false; bool bHaveArgVersionLong = false; bool bHaveArgLog = false; + bool bHaveArgLogDir = false; bool bHaveArgHelp = false; + CMIUtilString strLogDir; bHaveArgInterpret = true; if (bHaveArgs) @@ -512,6 +516,11 @@ { bHaveArgLog = true; } + if (0 == strArg.compare(0,10,"--log-dir=")) + { + strLogDir = strArg.substr(10, CMIUtilString::npos); + bHaveArgLogDir = true; + } if ((0 == strArg.compare("--help")) || (0 == strArg.compare("-h"))) { bHaveArgHelp = true; @@ -524,6 +533,11 @@ CMICmnLog::Instance().SetEnabled(true); } + if (bHaveArgLogDir) + { + bOk = bOk && CMICmnLogMediumFile::Instance().SetLogDir(strLogDir); + } + // Todo: Remove this output when MI is finished. It is temporary to persuade Ecllipse plugin to work. // Eclipse reads this literally and will not work unless it gets this exact version text. // Handle --version option (ignore the --interpreter option if present) @@ -613,7 +627,8 @@ MIRSRC(IDE_MI_APP_ARG_VERSION_LONG), MIRSRC(IDE_MI_APP_ARG_INTERPRETER), MIRSRC(IDE_MI_APP_ARG_EXECUTEABLE), - CMIUtilString::Format(MIRSRC(IDE_MI_APP_ARG_APP_LOG), CMICmnLogMediumFile::Instance().GetFileName().c_str()), + CMIUtilString::Format(MIRSRC(IDE_MI_APP_ARG_APP_LOG), CMICmnLogMediumFile::Instance().GetBaseFileName().c_str()), + MIRSRC(IDE_MI_APP_ARG_APP_LOG_DIR), MIRSRC(IDE_MI_APP_ARG_EXECUTABLE), MIRSRC(IDS_CMD_QUIT_HELP), MIRSRC(IDE_MI_APP_ARG_EXAMPLE)}; Index: tools/lldb-mi/MIUtilDateTimeStd.h =================================================================== --- tools/lldb-mi/MIUtilDateTimeStd.h +++ tools/lldb-mi/MIUtilDateTimeStd.h @@ -30,6 +30,7 @@ CMIUtilString GetDate(void); CMIUtilString GetTime(void); + CMIUtilString GetDateTimeLogFilename(void); // Overrideable: public: Index: tools/lldb-mi/MIUtilDateTimeStd.cpp =================================================================== --- tools/lldb-mi/MIUtilDateTimeStd.cpp +++ tools/lldb-mi/MIUtilDateTimeStd.cpp @@ -71,3 +71,21 @@ return strTime; } + +//++ ------------------------------------------------------------------------------------ +// Details: Retrieve system local current date and time in yyyy-MM-dd--HH-mm-ss format for log file names. +// Type: Method. +// Args: None. +// Return: CMIUtilString - Text description. +// Throws: None. +//-- +CMIUtilString +CMIUtilDateTimeStd::GetDateTimeLogFilename(void) +{ + std::time(&m_rawTime); + const std::tm *pTi = std::localtime(&m_rawTime); + const CMIUtilString strTime(CMIUtilString::Format("%d%02d%02d%02d%02d%02d", pTi->tm_year + 1900, pTi->tm_mon, + pTi->tm_mday, pTi->tm_hour, pTi->tm_min, pTi->tm_sec)); + + return strTime; +} Index: tools/lldb-mi/MIUtilSystemWindows.cpp =================================================================== --- tools/lldb-mi/MIUtilSystemWindows.cpp +++ tools/lldb-mi/MIUtilSystemWindows.cpp @@ -17,6 +17,7 @@ // In-house headers: #include "MIUtilSystemWindows.h" #include "MICmnResources.h" +#include "MIUtilFileStd.h" //++ ------------------------------------------------------------------------------------ // Details: CMIUtilSystemWindows constructor. @@ -135,7 +136,10 @@ bool CMIUtilSystemWindows::GetLogFilesPath(CMIUtilString &vrwFileNamePath) const { - return GetExecutablesPath(vrwFileNamePath); + bool bOk = GetExecutablesPath(vrwFileNamePath); + if (bOk == MIstatus::success) + vrwFileNamePath = CMIUtilFileStd::StripOffFileName(vrwFileNamePath); + return bOk; } #endif // #if defined( _MSC_VER )