diff options
Diffstat (limited to 'lldb/source')
| -rw-r--r-- | lldb/source/Core/ArchSpec.cpp | 4 | ||||
| -rw-r--r-- | lldb/source/Core/Log.cpp | 1 | ||||
| -rw-r--r-- | lldb/source/Core/Section.cpp | 1 | ||||
| -rw-r--r-- | lldb/source/Host/macosx/Host.mm | 1 | ||||
| -rw-r--r-- | lldb/source/Target/Process.cpp | 1 | ||||
| -rw-r--r-- | lldb/source/Target/ThreadList.cpp | 1 | ||||
| -rw-r--r-- | lldb/source/Target/ThreadPlan.cpp | 1 | ||||
| -rw-r--r-- | lldb/source/Utility/CMakeLists.txt | 2 | ||||
| -rw-r--r-- | lldb/source/Utility/ConvertEnum.cpp | 110 | ||||
| -rw-r--r-- | lldb/source/Utility/NameMatches.cpp | 50 | ||||
| -rw-r--r-- | lldb/source/lldb.cpp | 94 |
11 files changed, 171 insertions, 95 deletions
diff --git a/lldb/source/Core/ArchSpec.cpp b/lldb/source/Core/ArchSpec.cpp index 8c12d5b06a6..be3f84b06aa 100644 --- a/lldb/source/Core/ArchSpec.cpp +++ b/lldb/source/Core/ArchSpec.cpp @@ -18,7 +18,7 @@ #include "llvm/Support/COFF.h" #include "llvm/Support/ELF.h" #include "llvm/Support/Host.h" -#include "lldb/Utility/SafeMachO.h" + #include "lldb/Core/RegularExpression.h" #include "lldb/Core/StringList.h" #include "lldb/Host/Endian.h" @@ -27,6 +27,8 @@ #include "lldb/Target/Process.h" #include "lldb/Target/RegisterContext.h" #include "lldb/Target/Thread.h" +#include "lldb/Utility/NameMatches.h" +#include "lldb/Utility/SafeMachO.h" #include "Plugins/Process/Utility/ARMDefines.h" #include "Plugins/Process/Utility/InstructionUtils.h" diff --git a/lldb/source/Core/Log.cpp b/lldb/source/Core/Log.cpp index 2ac538470a6..57b888a3bac 100644 --- a/lldb/source/Core/Log.cpp +++ b/lldb/source/Core/Log.cpp @@ -27,6 +27,7 @@ #include "lldb/Host/ThisThread.h" #include "lldb/Host/TimeValue.h" #include "lldb/Interpreter/Args.h" +#include "lldb/Utility/NameMatches.h" #include "llvm/ADT/SmallString.h" #include "llvm/Support/raw_ostream.h" diff --git a/lldb/source/Core/Section.cpp b/lldb/source/Core/Section.cpp index ea33a62b775..9a3f220beb4 100644 --- a/lldb/source/Core/Section.cpp +++ b/lldb/source/Core/Section.cpp @@ -12,6 +12,7 @@ #include "lldb/Symbol/ObjectFile.h" #include "lldb/Target/SectionLoadList.h" #include "lldb/Target/Target.h" +#include "lldb/Utility/ConvertEnum.h" #include <limits> diff --git a/lldb/source/Host/macosx/Host.mm b/lldb/source/Host/macosx/Host.mm index 3eb5a0e4079..86f9d712857 100644 --- a/lldb/source/Host/macosx/Host.mm +++ b/lldb/source/Host/macosx/Host.mm @@ -55,6 +55,7 @@ #include "lldb/Target/Platform.h" #include "lldb/Target/Process.h" #include "lldb/Utility/CleanUp.h" +#include "lldb/Utility/NameMatches.h" #include "cfcpp/CFCBundle.h" #include "cfcpp/CFCMutableArray.h" diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp index 9cade965da3..b1aad10fa41 100644 --- a/lldb/source/Target/Process.cpp +++ b/lldb/source/Target/Process.cpp @@ -51,6 +51,7 @@ #include "lldb/Target/ThreadPlan.h" #include "lldb/Target/ThreadPlanBase.h" #include "lldb/Target/UnixSignals.h" +#include "lldb/Utility/NameMatches.h" #include "Plugins/Process/Utility/InferiorCallPOSIX.h" using namespace lldb; diff --git a/lldb/source/Target/ThreadList.cpp b/lldb/source/Target/ThreadList.cpp index db4407b4b57..b175859f2f2 100644 --- a/lldb/source/Target/ThreadList.cpp +++ b/lldb/source/Target/ThreadList.cpp @@ -17,6 +17,7 @@ #include "lldb/Target/Thread.h" #include "lldb/Target/ThreadPlan.h" #include "lldb/Target/Process.h" +#include "lldb/Utility/ConvertEnum.h" using namespace lldb; using namespace lldb_private; diff --git a/lldb/source/Target/ThreadPlan.cpp b/lldb/source/Target/ThreadPlan.cpp index f2d7a187db5..80852b7f790 100644 --- a/lldb/source/Target/ThreadPlan.cpp +++ b/lldb/source/Target/ThreadPlan.cpp @@ -22,6 +22,7 @@ #include "lldb/Target/Thread.h" #include "lldb/Target/Process.h" #include "lldb/Target/Target.h" +#include "lldb/Utility/ConvertEnum.h" using namespace lldb; using namespace lldb_private; diff --git a/lldb/source/Utility/CMakeLists.txt b/lldb/source/Utility/CMakeLists.txt index cafc649c829..293ef4a0a7a 100644 --- a/lldb/source/Utility/CMakeLists.txt +++ b/lldb/source/Utility/CMakeLists.txt @@ -3,10 +3,12 @@ set(LLVM_NO_RTTI 1) add_lldb_library(lldbUtility ARM_DWARF_Registers.cpp ARM64_DWARF_Registers.cpp + ConvertEnum.cpp JSON.cpp KQueue.cpp LLDBAssert.cpp ModuleCache.cpp + NameMatches.cpp PseudoTerminal.cpp Range.cpp RegisterNumber.cpp diff --git a/lldb/source/Utility/ConvertEnum.cpp b/lldb/source/Utility/ConvertEnum.cpp new file mode 100644 index 00000000000..e108f5e7542 --- /dev/null +++ b/lldb/source/Utility/ConvertEnum.cpp @@ -0,0 +1,110 @@ +//===-- ConvertEnum.cpp -----------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +#include "lldb/Utility/ConvertEnum.h" + +using namespace lldb; +using namespace lldb_private; + +const char * +lldb_private::GetVoteAsCString(Vote vote) +{ + switch (vote) + { + case eVoteNo: + return "no"; + case eVoteNoOpinion: + return "no opinion"; + case eVoteYes: + return "yes"; + } + return "invalid"; +} + +const char * +lldb_private::GetSectionTypeAsCString(lldb::SectionType sect_type) +{ + switch (sect_type) + { + case eSectionTypeInvalid: + return "invalid"; + case eSectionTypeCode: + return "code"; + case eSectionTypeContainer: + return "container"; + case eSectionTypeData: + return "data"; + case eSectionTypeDataCString: + return "data-cstr"; + case eSectionTypeDataCStringPointers: + return "data-cstr-ptr"; + case eSectionTypeDataSymbolAddress: + return "data-symbol-addr"; + case eSectionTypeData4: + return "data-4-byte"; + case eSectionTypeData8: + return "data-8-byte"; + case eSectionTypeData16: + return "data-16-byte"; + case eSectionTypeDataPointers: + return "data-ptrs"; + case eSectionTypeDebug: + return "debug"; + case eSectionTypeZeroFill: + return "zero-fill"; + case eSectionTypeDataObjCMessageRefs: + return "objc-message-refs"; + case eSectionTypeDataObjCCFStrings: + return "objc-cfstrings"; + case eSectionTypeDWARFDebugAbbrev: + return "dwarf-abbrev"; + case eSectionTypeDWARFDebugAranges: + return "dwarf-aranges"; + case eSectionTypeDWARFDebugFrame: + return "dwarf-frame"; + case eSectionTypeDWARFDebugInfo: + return "dwarf-info"; + case eSectionTypeDWARFDebugLine: + return "dwarf-line"; + case eSectionTypeDWARFDebugLoc: + return "dwarf-loc"; + case eSectionTypeDWARFDebugMacInfo: + return "dwarf-macinfo"; + case eSectionTypeDWARFDebugPubNames: + return "dwarf-pubnames"; + case eSectionTypeDWARFDebugPubTypes: + return "dwarf-pubtypes"; + case eSectionTypeDWARFDebugRanges: + return "dwarf-ranges"; + case eSectionTypeDWARFDebugStr: + return "dwarf-str"; + case eSectionTypeELFSymbolTable: + return "elf-symbol-table"; + case eSectionTypeELFDynamicSymbols: + return "elf-dynamic-symbols"; + case eSectionTypeELFRelocationEntries: + return "elf-relocation-entries"; + case eSectionTypeELFDynamicLinkInfo: + return "elf-dynamic-link-info"; + case eSectionTypeDWARFAppleNames: + return "apple-names"; + case eSectionTypeDWARFAppleTypes: + return "apple-types"; + case eSectionTypeDWARFAppleNamespaces: + return "apple-namespaces"; + case eSectionTypeDWARFAppleObjC: + return "apple-objc"; + case eSectionTypeEHFrame: + return "eh-frame"; + case eSectionTypeCompactUnwind: + return "compact-unwind"; + case eSectionTypeOther: + return "regular"; + } + return "unknown"; +} diff --git a/lldb/source/Utility/NameMatches.cpp b/lldb/source/Utility/NameMatches.cpp new file mode 100644 index 00000000000..e10c47e4fd9 --- /dev/null +++ b/lldb/source/Utility/NameMatches.cpp @@ -0,0 +1,50 @@ +//===-- NameMatches.cpp -----------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +#include "lldb/Core/RegularExpression.h" +#include "lldb/Utility/NameMatches.h" + +#include "llvm/ADT/StringRef.h" + +using namespace lldb_private; + +bool +lldb_private::NameMatches(const char *name, NameMatchType match_type, const char *match) +{ + if (match_type == eNameMatchIgnore) + return true; + + if (name == match) + return true; + + if (name && match) + { + llvm::StringRef name_sref(name); + llvm::StringRef match_sref(match); + switch (match_type) + { + case eNameMatchIgnore: // This case cannot occur: tested before + return true; + case eNameMatchEquals: + return name_sref == match_sref; + case eNameMatchContains: + return name_sref.find(match_sref) != llvm::StringRef::npos; + case eNameMatchStartsWith: + return name_sref.startswith(match_sref); + case eNameMatchEndsWith: + return name_sref.endswith(match_sref); + case eNameMatchRegularExpression: + { + RegularExpression regex(match); + return regex.Execute(name); + } + break; + } + } + return false; +} diff --git a/lldb/source/lldb.cpp b/lldb/source/lldb.cpp index 80330442201..75b270ff3a7 100644 --- a/lldb/source/lldb.cpp +++ b/lldb/source/lldb.cpp @@ -466,97 +466,3 @@ lldb_private::GetVersion () return g_version_str.c_str(); #endif } - -const char * -lldb_private::GetVoteAsCString (Vote vote) -{ - switch (vote) - { - case eVoteNo: return "no"; - case eVoteNoOpinion: return "no opinion"; - case eVoteYes: return "yes"; - } - return "invalid"; -} - - -const char * -lldb_private::GetSectionTypeAsCString (SectionType sect_type) -{ - switch (sect_type) - { - case eSectionTypeInvalid: return "invalid"; - case eSectionTypeCode: return "code"; - case eSectionTypeContainer: return "container"; - case eSectionTypeData: return "data"; - case eSectionTypeDataCString: return "data-cstr"; - case eSectionTypeDataCStringPointers: return "data-cstr-ptr"; - case eSectionTypeDataSymbolAddress: return "data-symbol-addr"; - case eSectionTypeData4: return "data-4-byte"; - case eSectionTypeData8: return "data-8-byte"; - case eSectionTypeData16: return "data-16-byte"; - case eSectionTypeDataPointers: return "data-ptrs"; - case eSectionTypeDebug: return "debug"; - case eSectionTypeZeroFill: return "zero-fill"; - case eSectionTypeDataObjCMessageRefs: return "objc-message-refs"; - case eSectionTypeDataObjCCFStrings: return "objc-cfstrings"; - case eSectionTypeDWARFDebugAbbrev: return "dwarf-abbrev"; - case eSectionTypeDWARFDebugAranges: return "dwarf-aranges"; - case eSectionTypeDWARFDebugFrame: return "dwarf-frame"; - case eSectionTypeDWARFDebugInfo: return "dwarf-info"; - case eSectionTypeDWARFDebugLine: return "dwarf-line"; - case eSectionTypeDWARFDebugLoc: return "dwarf-loc"; - case eSectionTypeDWARFDebugMacInfo: return "dwarf-macinfo"; - case eSectionTypeDWARFDebugPubNames: return "dwarf-pubnames"; - case eSectionTypeDWARFDebugPubTypes: return "dwarf-pubtypes"; - case eSectionTypeDWARFDebugRanges: return "dwarf-ranges"; - case eSectionTypeDWARFDebugStr: return "dwarf-str"; - case eSectionTypeELFSymbolTable: return "elf-symbol-table"; - case eSectionTypeELFDynamicSymbols: return "elf-dynamic-symbols"; - case eSectionTypeELFRelocationEntries: return "elf-relocation-entries"; - case eSectionTypeELFDynamicLinkInfo: return "elf-dynamic-link-info"; - case eSectionTypeDWARFAppleNames: return "apple-names"; - case eSectionTypeDWARFAppleTypes: return "apple-types"; - case eSectionTypeDWARFAppleNamespaces: return "apple-namespaces"; - case eSectionTypeDWARFAppleObjC: return "apple-objc"; - case eSectionTypeEHFrame: return "eh-frame"; - case eSectionTypeCompactUnwind: return "compact-unwind"; - case eSectionTypeOther: return "regular"; - } - return "unknown"; - -} - -bool -lldb_private::NameMatches (const char *name, - NameMatchType match_type, - const char *match) -{ - if (match_type == eNameMatchIgnore) - return true; - - if (name == match) - return true; - - if (name && match) - { - llvm::StringRef name_sref(name); - llvm::StringRef match_sref(match); - switch (match_type) - { - case eNameMatchIgnore: // This case cannot occur: tested before - return true; - case eNameMatchEquals: return name_sref == match_sref; - case eNameMatchContains: return name_sref.find (match_sref) != llvm::StringRef::npos; - case eNameMatchStartsWith: return name_sref.startswith (match_sref); - case eNameMatchEndsWith: return name_sref.endswith (match_sref); - case eNameMatchRegularExpression: - { - RegularExpression regex (match); - return regex.Execute (name); - } - break; - } - } - return false; -} |

