[Lldb-commits] [lldb] Colorize output when searching for symbols in lldb (PR #69422)

David Spickett via lldb-commits lldb-commits at lists.llvm.org
Thu Nov 2 08:43:14 PDT 2023


================
@@ -0,0 +1,31 @@
+UNSUPPORTED: system-windows
+
+# RUN: %clang_host -g %S/Inputs/main.c -o %t
+# RUN: %lldb %t -b -o 'settings set use-color true' -o 'image lookup -r -s ma' | FileCheck %s --check-prefix CHECK1
+
+# CHECK1: 3 symbols match the regular expression 'ma' in {{.*}}
+# CHECK1:         Name: {{.+}}31mma{{.+}}0min.c
+# CHECK1:         Summary: {{.+}}`{{.+}}31mma{{.+}}0min at main.c:2
+
+# RUN: %lldb %t -b -o 'settings set use-color true' -o 'image lookup -r -s main.c|foo' | FileCheck %s --check-prefix CHECK2
+
+# CHECK2: 2 symbols match the regular expression 'main.c|foo' in {{.*}}
+# CHECK2:         Name: {{.+}}31mmain.c{{.+}}0m
+# CHECK2:         Summary: {{.+}}`{{.+}}31mfoo{{.+}}0m at main.c:1
+
+# RUN: %lldb %t -b -o 'settings set use-color true' -o 'image lookup -r -s m[abc]' | FileCheck %s --check-prefix CHECK3
+
+# CHECK3: 5 symbols match the regular expression 'm[abc]' in {{.*}}
+# CHECK3:         Name: {{.+}}31mma{{.+}}0min.c
+# CHECK3:         Summary: {{.+}}`{{.+}}31mma{{.+}}0min at main.c:2
+# CHECK3:         Summary: {{.+}}`___lldb_unnamed_sy{{.+}}31mmb{{.+}}0mol36
+# CHECK3:         Summary: {{.+}}`___lldb_unnamed_sy{{.+}}31mmb{{.+}}0mol37
+
+
+# RUN: %lldb %t -b -o 'settings set use-color true' -o 'image lookup -r -s [0-9]' | FileCheck %s --check-prefix CHECK4
+
+# CHECK4: 6 symbols match the regular expression '[0-9]' in {{.*}}
+# CHECK4:         Name: Scrt{{.+}}31m1{{.+}}0m.o
+# CHECK4:         Summary: {{.+}}`completed.{{.+}}31m0{{.+}}0m
+# CHECK4:         Name: __libc_start_main at GLIBC_{{.+}}31m2{{.+}}0m_{{.+}}31m3{{.+}}0m{{.+}}31m4{{.+}}0m
+# CHECK4:         Name: __cxa_finalize at GLIBC_{{.+}}31m2{{.+}}0m_{{.+}}31m2{{.+}}0m_{{.+}}31m5{{.+}}0m
----------------
DavidSpickett wrote:

This one will be a bit tricky running on all the OS we support. I suggest you keep your tests to symbols we know are defined in the user's program.

As if I go to FreeBSD for example, there will be no glibc in the process' address space, it'll be the FreeBSD libc with different names.

So stick to names from main.c.

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


More information about the lldb-commits mailing list