diff options
author | Dawn Perchik <dawn@burble.org> | 2015-09-17 16:22:30 +0000 |
---|---|---|
committer | Dawn Perchik <dawn@burble.org> | 2015-09-17 16:22:30 +0000 |
commit | b01310008ff743d9736fabff933e739ed97196cf (patch) | |
tree | f197a440b66fc32618b4773d2b2a1352e428b4d5 /lldb/tools/lldb-mi/MIUtilParse.cpp | |
parent | 2e98d57ad42c35ef0c5584ddcf233f3db1c707f1 (diff) | |
download | bcm5719-llvm-b01310008ff743d9736fabff933e739ed97196cf.tar.gz bcm5719-llvm-b01310008ff743d9736fabff933e739ed97196cf.zip |
[lldb-mi] Fix the handling of files in -data-info-line and -symbol-list-lines.
This fixes -data-info-line and -symbol-list-lines to parse the filename
and line correctly when line entries don't have the optional column
number and the filename contains a Windows drive letter. It also fixes
-symbol-list-lines when code from header files is generated.
Reviewed by: abidh, ki.stfu
Subscribers: lldb-commits
Differential Revision: http://reviews.llvm.org/D12115
llvm-svn: 247899
Diffstat (limited to 'lldb/tools/lldb-mi/MIUtilParse.cpp')
-rw-r--r-- | lldb/tools/lldb-mi/MIUtilParse.cpp | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/lldb/tools/lldb-mi/MIUtilParse.cpp b/lldb/tools/lldb-mi/MIUtilParse.cpp new file mode 100644 index 00000000000..27e25b8b743 --- /dev/null +++ b/lldb/tools/lldb-mi/MIUtilParse.cpp @@ -0,0 +1,75 @@ +//===-- MIUtilParse.cpp ----------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// Third party headers: +#include <memory> + +// In-house headers: +#include "MIUtilParse.h" + +//++ ------------------------------------------------------------------------------------ +// Details: CRegexParser constructor. +// Type: Method. +// Args: regexStr - Pointer to the regular expression to compile. +// Return: None. +// Throws: None. +//-- +MIUtilParse::CRegexParser::CRegexParser(const char *regexStr) + : m_isValid(llvm_regcomp(&m_emma, regexStr, REG_EXTENDED) == 0) +{ +} + +//++ ------------------------------------------------------------------------------------ +// Details: CRegexParser destructor. +// Type: Method. +// Args: None. +// Return: None. +// Throws: None. +//-- +MIUtilParse::CRegexParser::~CRegexParser() +{ + // Free up memory held within regex. + if (m_isValid) + llvm_regfree(&m_emma); +} + +//++ ------------------------------------------------------------------------------------ +// Details: CRegexParser regex executer. +// Match the input against the regular expression. Return an error +// if the number of matches is less than minMatches. If the default +// minMatches value of 0 is passed, an error will be returned if +// the number of matches is less than the maxMatches value used to +// initialize Match. +// Type: Method. +// Args: input (R) - Pointer to UTF8 text data to be parsed. +// match (RW) - Reference to Match class. +// minMatches (R) - Minimum number of regex matches expected. +// Return: bool - True = minimum matches were met, +// false = minimum matches were not met or regex failed. +// Throws: None. +//-- +bool +MIUtilParse::CRegexParser::Execute(const char *input, Match& match, size_t minMatches) +{ + if (!m_isValid) + return false; + + std::unique_ptr<llvm_regmatch_t[]> matches(new llvm_regmatch_t[match.m_maxMatches]); // Array of matches + + if (llvm_regexec(&m_emma, input, match.m_maxMatches, matches.get(), 0) != 0) + return false; + + size_t i; + for (i = 0; i < match.m_maxMatches && matches[i].rm_so >= 0; i++) + { + const int n = matches[i].rm_eo - matches[i].rm_so; + match.m_matchStrs[i].assign(input + matches[i].rm_so, n); + } + return i >= minMatches; +} |