spyffe created this revision.
spyffe added a project: LLDB.
Herald added subscribers: arichardson, aprantl, sdardis.
The IR dynamic checks are self-contained functions whose job is to
- verify that pointers referenced in an expression are valid at runtime; and
- verify that selectors sent to Objective-C objects by an expression are
actually supported by that object.
These dynamic checks forward-declare all the functions they use and should not
require any external debug information. The way they ensure this is by marking
all the names they use with a dollar sign (`$`). The expression parser
recognizes such symbols and perform no lookups for them.
This patch fixes three issues surrounding the use of the dollar sign:
- to fix a MIPS issue, the name of the pointer checker was changed from
starting with `$` to starting with `_$`, but this was not properly ignored; and
- the Objective-C object checker used a temporary variable that did not start
with `$`.
- the Objective-C object checker used an externally-defined struct (`struct
objc_selector`) but didn't need to.
The patch also reformats the string containing the Objective-C object checker,
which was mangled horribly when the code was transformed to a uniform width of
80 columns.
Repository:
rL LLVM
https://reviews.llvm.org/D38153
Files:
source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
Index: source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
===================================================================
--- source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
+++ source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
@@ -812,84 +812,44 @@
int len = 0;
if (m_has_object_getClass) {
len = ::snprintf(check_function_code, sizeof(check_function_code),
- "extern \"C\" void *gdb_object_getClass(void *); "
- " \n"
- "extern \"C\" int printf(const char *format, ...); "
- " \n"
- "extern \"C\" void "
- " \n"
- "%s(void *$__lldb_arg_obj, void *$__lldb_arg_selector) "
- " \n"
- "{ "
- " \n"
- " if ($__lldb_arg_obj == (void *)0) "
- " \n"
- " return; // nil is ok "
- " \n"
- " if (!gdb_object_getClass($__lldb_arg_obj)) "
- " \n"
- " *((volatile int *)0) = 'ocgc'; "
- " \n"
- " else if ($__lldb_arg_selector != (void *)0) "
- " \n"
- " { "
- " \n"
- " signed char responds = (signed char) [(id) "
- "$__lldb_arg_obj \n"
- " "
- "respondsToSelector: \n"
- " (struct "
- "objc_selector *) $__lldb_arg_selector]; \n"
- " if (responds == (signed char) 0) "
- " \n"
- " *((volatile int *)0) = 'ocgc'; "
- " \n"
- " } "
- " \n"
- "} "
- " \n",
- name);
+ "extern \"C\" void *gdb_object_getClass(void *); \n"
+ "extern \"C\" int printf(const char *format, ...); \n"
+ "extern \"C\" void \n"
+ "%s(void *$__lldb_arg_obj, void *$__lldb_arg_selector) {\n"
+ " if ($__lldb_arg_obj == (void *)0) \n"
+ " return; // nil is ok \n"
+ " if (!gdb_object_getClass($__lldb_arg_obj)) { \n"
+ " *((volatile int *)0) = 'ocgc'; \n"
+ " } else if ($__lldb_arg_selector != (void *)0) { \n"
+ " signed char $responds = (signed char) \n"
+ " [(id)$__lldb_arg_obj respondsToSelector: \n"
+ " (void *) $__lldb_arg_selector]; \n"
+ " if ($responds == (signed char) 0) \n"
+ " *((volatile int *)0) = 'ocgc'; \n"
+ " } \n"
+ "} \n"
+ , name);
} else {
len = ::snprintf(check_function_code, sizeof(check_function_code),
- "extern \"C\" void *gdb_class_getClass(void *); "
- " \n"
- "extern \"C\" int printf(const char *format, ...); "
- " \n"
- "extern \"C\" void "
- " \n"
- "%s(void *$__lldb_arg_obj, void *$__lldb_arg_selector) "
- " \n"
- "{ "
- " \n"
- " if ($__lldb_arg_obj == (void *)0) "
- " \n"
- " return; // nil is ok "
- " \n"
- " void **$isa_ptr = (void **)$__lldb_arg_obj; "
- " \n"
- " if (*$isa_ptr == (void *)0 || "
- "!gdb_class_getClass(*$isa_ptr)) \n"
- " *((volatile int *)0) = 'ocgc'; "
- " \n"
- " else if ($__lldb_arg_selector != (void *)0) "
- " \n"
- " { "
- " \n"
- " signed char responds = (signed char) [(id) "
- "$__lldb_arg_obj \n"
- " "
- "respondsToSelector: \n"
- " (struct "
- "objc_selector *) $__lldb_arg_selector]; \n"
- " if (responds == (signed char) 0) "
- " \n"
- " *((volatile int *)0) = 'ocgc'; "
- " \n"
- " } "
- " \n"
- "} "
- " \n",
- name);
+ "extern \"C\" void *gdb_class_getClass(void *); \n"
+ "extern \"C\" int printf(const char *format, ...); \n"
+ "extern \"C\" void \n"
+ "%s(void *$__lldb_arg_obj, void *$__lldb_arg_selector) {\n"
+ " if ($__lldb_arg_obj == (void *)0) \n"
+ " return; // nil is ok \n"
+ " void **$isa_ptr = (void **)$__lldb_arg_obj; \n"
+ " if (*$isa_ptr == (void *)0 || \n"
+ " !gdb_class_getClass(*$isa_ptr)) \n"
+ " *((volatile int *)0) = 'ocgc'; \n"
+ " else if ($__lldb_arg_selector != (void *)0) { \n"
+ " signed char $responds = (signed char) \n"
+ " [(id)$__lldb_arg_obj respondsToSelector: \n"
+ " (void *) $__lldb_arg_selector]; \n"
+ " if ($responds == (signed char) 0) \n"
+ " *((volatile int *)0) = 'ocgc'; \n"
+ " } \n"
+ "} \n"
+ , name);
}
assert(len < (int)sizeof(check_function_code));
Index: source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
===================================================================
--- source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
+++ source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
@@ -809,6 +809,9 @@
} while (0);
}
+ if (name_unique_cstr[0] == '_' && name_unique_cstr[1] == '$')
+ return;
+
if (name_unique_cstr[0] == '$' && !namespace_decl) {
static ConstString g_lldb_class_name("$__lldb_class");
Index: source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
===================================================================
--- source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
+++ source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
@@ -648,6 +648,8 @@
// The ClangASTSource is not responsible for finding $-names.
if (name_unique_cstr[0] == '$')
return;
+ if (name_unique_cstr[0] == '_' && name_unique_cstr[1] == '$')
+ return;
if (module_sp && namespace_decl) {
CompilerDeclContext found_namespace_decl;
_______________________________________________
lldb-commits mailing list
[email protected]
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits