void foo(LLDB_NAMESPACE::SBThread* thread) { LLDB_NAMESPACE::SBFrame frame = thread->GetSelectedFrame(); LLDB_NAMESPACE::SBValueList args = frame.GetVariables(LLDB_NAMESPACE::eVarLocArgs); LLDB_NAMESPACE::SBValue arg1 = args.GetValueAtIndex(0); LLDB_NAMESPACE::SBValue arg2 = args.GetValueAtIndex(1); if (arg1.GetValueType() != LLDB_NAMESPACE::ValueType::eTypeInt) { LLDB_LOG_ERROR("arg1 is not an integer!"); } if (!arg2.GetPointer() notNull) { LLDB_LOG_ERROR("arg2 is null!"); } }
void printString(char* string notNull) { std::cout << string << std::endl; } int main() { char* str = "Hello, world!"; printString(str); return 0; }In this example, we have a simple function that takes a non-null char pointer as a parameter and prints it to the console. In our main function, we declare a char pointer and assign it a string. We then call our printString function with this pointer as the parameter. Both of these examples use the LLPointer notNull operator to ensure that the pointer being passed to a function or being checked is not null. This helps prevent runtime errors and crashes in our code.