[PATCHv9,10/14] gdb: add another overload of startswith

Message ID 7ba7f1b02b8cea22c1efaa559b893746423b0fa1.1709651994.git.aburgess@redhat.com
State New
Headers
Series thread-specific breakpoints in just some inferiors |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 success Testing passed
linaro-tcwg-bot/tcwg_gdb_build--master-arm success Testing passed
linaro-tcwg-bot/tcwg_gdb_check--master-arm success Testing passed
linaro-tcwg-bot/tcwg_gdb_check--master-aarch64 success Testing passed

Commit Message

Andrew Burgess March 5, 2024, 3:21 p.m. UTC
  We already have one overload of the startswith function that takes a
std::string_view for both arguments.  A later patch in this series is
going to be improved by having an overload that takes one argument as
a std::string_view and the other argument as a plain 'char *'.

This commit adds the new overload, but doesn't make use of it (yet).
There should be no user visible changes after this commit.
---
 gdbsupport/common-utils.h | 10 ++++++++++
 1 file changed, 10 insertions(+)
  

Patch

diff --git a/gdbsupport/common-utils.h b/gdbsupport/common-utils.h
index 23cd40c0207..2fb22916409 100644
--- a/gdbsupport/common-utils.h
+++ b/gdbsupport/common-utils.h
@@ -100,6 +100,16 @@  startswith (std::string_view string, std::string_view pattern)
 	  && strncmp (string.data (), pattern.data (), pattern.length ()) == 0);
 }
 
+/* Version of startswith that takes a string_view for only one of its
+   arguments.  Return true if STR starts with PREFIX, otherwise return
+   false.  */
+
+static inline bool
+startswith (const char *str, const std::string_view &prefix)
+{
+  return strncmp (str, prefix.data (), prefix.length ()) == 0;
+}
+
 /* Return true if the strings are equal.  */
 
 static inline bool