[Lldb-commits] [lldb] [lldb] colorize symbols in image lookup with a regex pattern (PR #69422)

David Spickett via lldb-commits lldb-commits at lists.llvm.org
Wed Dec 6 01:55:33 PST 2023


=?utf-8?q?José?= L. Junior <josejunior at 10xengineers.ai>,taalhaataahir0102
 <23100293 at lums.edu.pk>,taalhaataahir0102 <23100293 at lums.edu.pk>,taalhaataahir0102
 <23100293 at lums.edu.pk>,taalhaataahir0102 <23100293 at lums.edu.pk>,
=?utf-8?q?José?= L. Junior <josejunior at 10xengineers.ai>
Message-ID:
In-Reply-To: <llvm.org/llvm/llvm-project/pull/69422 at github.com>


================
@@ -246,8 +246,8 @@ class Address {
   /// \see Address::DumpStyle
   bool Dump(Stream *s, ExecutionContextScope *exe_scope, DumpStyle style,
             DumpStyle fallback_style = DumpStyleInvalid,
-            uint32_t addr_byte_size = UINT32_MAX,
-            bool all_ranges = false) const;
+            uint32_t addr_byte_size = UINT32_MAX, bool all_ranges = false,
+            const char *pattern = nullptr) const;
----------------
DavidSpickett wrote:

I can't speak for Jonas here so just my interpretation - 

If you pass this as llvm::Regex, you're using the type system to signal to anyone reading this code that this is a regex pattern. Whereas using `const char*` and a comment that it is a regex could be missed by the reader.

test_func3 is the ideal here (though you may have to remove const, you'll find that out later). Deleting the copy constructor is usually done when you have a move only type, which is usually something that contains a resource where copying it doesn't make sense.

I think something like `test_func3(strm, std::move(regex2));` might fix it. At least, that's the obvious way to try to move construct the regex inside the optional.

Can you pass `std::make_optional<llvm::Regex>(name)` to func3 maybe?

If all this is too much hassle in the end, using a pointer is the fallback option. As long as the lifetimes are ok which I'm guessing they are. By which I mean, nothing earlier in the callstack is going to destroy the pattern before you end up using it.

https://github.com/llvm/llvm-project/pull/69422


More information about the lldb-commits mailing list