Index: lldb/examples/darwin/heap_find/heap.py =================================================================== --- lldb/examples/darwin/heap_find/heap.py +++ lldb/examples/darwin/heap_find/heap.py @@ -1036,7 +1036,7 @@ callback_baton_t *lldb_info = (callback_baton_t *)baton; if (lldb_info->cstr_len < ptr_size) { const char *begin = (const char *)ptr_addr; - const char *end = begin + ptr_size - info->cstr_len; + const char *end = begin + ptr_size - lldb_info->cstr_len; for (const char *s = begin; s < end; ++s) { if ((int)memcmp(s, lldb_info->cstr, lldb_info->cstr_len) == 0) { if (lldb_info->num_matches < MAX_MATCHES) { Index: lldb/lit/Heap/Inputs/cstr.c =================================================================== --- /dev/null +++ lldb/lit/Heap/Inputs/cstr.c @@ -0,0 +1,17 @@ +#include + +int main(void) { + char *str; + int size = 9; //strlen("patatino") + 1 + str = (char *)malloc(sizeof(char)*size); + *(str+0) = 'p'; + *(str+1) = 'a'; + *(str+2) = 't'; + *(str+3) = 'a'; + *(str+4) = 't'; + *(str+5) = 'i'; + *(str+6) = 'n'; + *(str+7) = 'o'; + *(str+8) = '\0'; + return 0; +} Index: lldb/lit/Heap/heap-cstr.test =================================================================== --- /dev/null +++ lldb/lit/Heap/heap-cstr.test @@ -0,0 +1,10 @@ +# REQUIRES: system-darwin +# RUN: %clang %p/Inputs/cstr.c -g -o %t +# RUN: %lldb -b -s %s -f %t | FileCheck %s + +br set -p return +command script import lldb.macosx.heap +run +cstr "patatino" + +# CHECK: {{.*}}: malloc( 16) -> {{.*}}