Files
clang-p2996/lldb/test/API/tools/lldb-dap/breakpoint/main.cpp
jeffreytan81 f175b9647c Improve VSCode DAP logpoint value summary (#71723)
Currently VSCode logpoint uses `SBValue::GetValue` to get the value for
printing. This is not providing an intuitive result for std::string or
char * -- it shows the pointer value instead of the string content.

This patch improves by prefers `SBValue::GetSummary()` before using
`SBValue::GetValue()`.

---------

Co-authored-by: jeffreytan81 <jeffreytan@fb.com>
2023-11-08 16:48:55 -08:00

50 lines
1.0 KiB
C++

#include <dlfcn.h>
#include <stdexcept>
#include <stdio.h>
int twelve(int i) {
return 12 + i; // break 12
}
int thirteen(int i) {
return 13 + i; // break 13
}
namespace a {
int fourteen(int i) {
return 14 + i; // break 14
}
} // namespace a
int main(int argc, char const *argv[]) {
#if defined(__APPLE__)
const char *libother_name = "libother.dylib";
#else
const char *libother_name = "libother.so";
#endif
void *handle = dlopen(libother_name, RTLD_NOW);
if (handle == nullptr) {
fprintf(stderr, "%s\n", dlerror());
exit(1);
}
const char *message = "Hello from main!";
int (*foo)(int) = (int (*)(int))dlsym(handle, "foo");
if (foo == nullptr) {
fprintf(stderr, "%s\n", dlerror());
exit(2);
}
foo(12); // before loop
for (int i = 0; i < 10; ++i) {
int x = twelve(i) + thirteen(i) + a::fourteen(i); // break loop
}
printf("%s\n", message);
try {
throw std::invalid_argument("throwing exception for testing");
} catch (...) {
puts("caught exception...");
}
return 0; // after loop
}