Skip to content
This repository was archived by the owner on May 21, 2019. It is now read-only.
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit afe0200

Browse files
committedOct 5, 2017
Work around a bug in the C++ expression parser.
When the expression parser does name resolution for local variables in C++ closures it doesn't give the local name priority over other global symbols of the same name. heap.py uses "info" which is a fairly common name, and so the commands in it fail. This is a workaround, just use lldb_info not info. <rdar://problem/34026140> git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@314959 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 9f4fdc3 commit afe0200

File tree

1 file changed

+47
-47
lines changed

1 file changed

+47
-47
lines changed
 

‎examples/darwin/heap_find/heap.py

Lines changed: 47 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -576,19 +576,19 @@ def dump_stack_history_entries(options, result, addr, history):
576576
unsigned idx;
577577
malloc_stack_entry entries[MAX_HISTORY];
578578
} $malloc_stack_history;
579-
$malloc_stack_history info = { (task_t)mach_task_self(), 0 };
579+
$malloc_stack_history lldb_info = { (task_t)mach_task_self(), 0 };
580580
uint32_t max_stack_frames = MAX_FRAMES;
581581
enumerate_callback_t callback = [] (mach_stack_logging_record_t stack_record, void *baton) -> void {
582-
$malloc_stack_history *info = ($malloc_stack_history *)baton;
583-
if (info->idx < MAX_HISTORY) {
584-
malloc_stack_entry *stack_entry = &(info->entries[info->idx]);
582+
$malloc_stack_history *lldb_info = ($malloc_stack_history *)baton;
583+
if (lldb_info->idx < MAX_HISTORY) {
584+
malloc_stack_entry *stack_entry = &(lldb_info->entries[lldb_info->idx]);
585585
stack_entry->address = stack_record.address;
586586
stack_entry->type_flags = stack_record.type_flags;
587587
stack_entry->argument = stack_record.argument;
588588
stack_entry->num_frames = 0;
589589
stack_entry->frames[0] = 0;
590590
stack_entry->frames_err = (kern_return_t)__mach_stack_logging_frames_for_uniqued_stack (
591-
info->task,
591+
lldb_info->task,
592592
stack_record.stack_identifier,
593593
stack_entry->frames,
594594
(uint32_t)MAX_FRAMES,
@@ -597,10 +597,10 @@ def dump_stack_history_entries(options, result, addr, history):
597597
if (stack_entry->num_frames < MAX_FRAMES)
598598
stack_entry->frames[stack_entry->num_frames] = 0;
599599
}
600-
++info->idx;
600+
++lldb_info->idx;
601601
};
602-
(kern_return_t)__mach_stack_logging_enumerate_records (info.task, (uint64_t)0x%x, callback, &info);
603-
info''' % (options.max_frames, options.max_history, addr)
602+
(kern_return_t)__mach_stack_logging_enumerate_records (lldb_info.task, (uint64_t)0x%x, callback, &lldb_info);
603+
lldb_info''' % (options.max_frames, options.max_history, addr)
604604

605605
frame = lldb.debugger.GetSelectedTarget().GetProcess(
606606
).GetSelectedThread().GetSelectedFrame()
@@ -924,18 +924,18 @@ def ptr_refs(debugger, command, result, dict):
924924
void *ptr;
925925
} callback_baton_t;
926926
range_callback_t range_callback = [](task_t task, void *baton, unsigned type, uintptr_t ptr_addr, uintptr_t ptr_size) -> void {
927-
callback_baton_t *info = (callback_baton_t *)baton;
927+
callback_baton_t *lldb_info = (callback_baton_t *)baton;
928928
typedef void* T;
929929
const unsigned size = sizeof(T);
930930
T *array = (T*)ptr_addr;
931931
for (unsigned idx = 0; ((idx + 1) * sizeof(T)) <= ptr_size; ++idx) {
932-
if (array[idx] == info->ptr) {
933-
if (info->num_matches < MAX_MATCHES) {
934-
info->matches[info->num_matches].addr = (void*)ptr_addr;
935-
info->matches[info->num_matches].size = ptr_size;
936-
info->matches[info->num_matches].offset = idx*sizeof(T);
937-
info->matches[info->num_matches].type = type;
938-
++info->num_matches;
932+
if (array[idx] == lldb_info->ptr) {
933+
if (lldb_info->num_matches < MAX_MATCHES) {
934+
lldb_info->matches[lldb_info->num_matches].addr = (void*)ptr_addr;
935+
lldb_info->matches[lldb_info->num_matches].size = ptr_size;
936+
lldb_info->matches[lldb_info->num_matches].offset = idx*sizeof(T);
937+
lldb_info->matches[lldb_info->num_matches].type = type;
938+
++lldb_info->num_matches;
939939
}
940940
}
941941
}
@@ -1033,18 +1033,18 @@ def cstr_refs(debugger, command, result, dict):
10331033
unsigned cstr_len;
10341034
} callback_baton_t;
10351035
range_callback_t range_callback = [](task_t task, void *baton, unsigned type, uintptr_t ptr_addr, uintptr_t ptr_size) -> void {
1036-
callback_baton_t *info = (callback_baton_t *)baton;
1037-
if (info->cstr_len < ptr_size) {
1036+
callback_baton_t *lldb_info = (callback_baton_t *)baton;
1037+
if (lldb_info->cstr_len < ptr_size) {
10381038
const char *begin = (const char *)ptr_addr;
10391039
const char *end = begin + ptr_size - info->cstr_len;
10401040
for (const char *s = begin; s < end; ++s) {
1041-
if ((int)memcmp(s, info->cstr, info->cstr_len) == 0) {
1042-
if (info->num_matches < MAX_MATCHES) {
1043-
info->matches[info->num_matches].addr = (void*)ptr_addr;
1044-
info->matches[info->num_matches].size = ptr_size;
1045-
info->matches[info->num_matches].offset = s - begin;
1046-
info->matches[info->num_matches].type = type;
1047-
++info->num_matches;
1041+
if ((int)memcmp(s, lldb_info->cstr, lldb_info->cstr_len) == 0) {
1042+
if (lldb_info->num_matches < MAX_MATCHES) {
1043+
lldb_info->matches[lldb_info->num_matches].addr = (void*)ptr_addr;
1044+
lldb_info->matches[lldb_info->num_matches].size = ptr_size;
1045+
lldb_info->matches[lldb_info->num_matches].offset = s - begin;
1046+
lldb_info->matches[lldb_info->num_matches].type = type;
1047+
++lldb_info->num_matches;
10481048
}
10491049
}
10501050
}
@@ -1135,17 +1135,17 @@ def malloc_info_impl(debugger, result, options, args):
11351135
void *ptr;
11361136
} callback_baton_t;
11371137
range_callback_t range_callback = [](task_t task, void *baton, unsigned type, uintptr_t ptr_addr, uintptr_t ptr_size) -> void {
1138-
callback_baton_t *info = (callback_baton_t *)baton;
1139-
if (info->num_matches == 0) {
1140-
uint8_t *p = (uint8_t *)info->ptr;
1138+
callback_baton_t *lldb_info = (callback_baton_t *)baton;
1139+
if (lldb_info->num_matches == 0) {
1140+
uint8_t *p = (uint8_t *)lldb_info->ptr;
11411141
uint8_t *lo = (uint8_t *)ptr_addr;
11421142
uint8_t *hi = lo + ptr_size;
11431143
if (lo <= p && p < hi) {
1144-
info->matches[info->num_matches].addr = (void*)ptr_addr;
1145-
info->matches[info->num_matches].size = ptr_size;
1146-
info->matches[info->num_matches].offset = p - lo;
1147-
info->matches[info->num_matches].type = type;
1148-
info->num_matches = 1;
1144+
lldb_info->matches[lldb_info->num_matches].addr = (void*)ptr_addr;
1145+
lldb_info->matches[lldb_info->num_matches].size = ptr_size;
1146+
lldb_info->matches[lldb_info->num_matches].offset = p - lo;
1147+
lldb_info->matches[lldb_info->num_matches].type = type;
1148+
lldb_info->num_matches = 1;
11491149
}
11501150
}
11511151
};
@@ -1397,24 +1397,24 @@ def objc_refs(debugger, command, result, dict):
13971397
typedef Class (*class_getSuperclass_type)(void *isa);
13981398
range_callback_t range_callback = [](task_t task, void *baton, unsigned type, uintptr_t ptr_addr, uintptr_t ptr_size) -> void {
13991399
class_getSuperclass_type class_getSuperclass_impl = (class_getSuperclass_type)class_getSuperclass;
1400-
callback_baton_t *info = (callback_baton_t *)baton;
1400+
callback_baton_t *lldb_info = (callback_baton_t *)baton;
14011401
if (sizeof(Class) <= ptr_size) {
14021402
Class *curr_class_ptr = (Class *)ptr_addr;
14031403
Class *matching_class_ptr = (Class *)bsearch (curr_class_ptr,
1404-
(const void *)info->classes,
1405-
sizeof(info->classes)/sizeof(Class),
1404+
(const void *)lldb_info->classes,
1405+
sizeof(lldb_info->classes)/sizeof(Class),
14061406
sizeof(Class),
1407-
info->compare_callback);
1407+
lldb_info->compare_callback);
14081408
if (matching_class_ptr) {
14091409
bool match = false;
1410-
if (info->isa) {
1410+
if (lldb_info->isa) {
14111411
Class isa = *curr_class_ptr;
1412-
if (info->isa == isa)
1412+
if (lldb_info->isa == isa)
14131413
match = true;
1414-
else { // if (info->objc.match_superclasses) {
1414+
else { // if (lldb_info->objc.match_superclasses) {
14151415
Class super = class_getSuperclass_impl(isa);
14161416
while (super) {
1417-
if (super == info->isa) {
1417+
if (super == lldb_info->isa) {
14181418
match = true;
14191419
break;
14201420
}
@@ -1425,12 +1425,12 @@ def objc_refs(debugger, command, result, dict):
14251425
else
14261426
match = true;
14271427
if (match) {
1428-
if (info->num_matches < MAX_MATCHES) {
1429-
info->matches[info->num_matches].addr = (void*)ptr_addr;
1430-
info->matches[info->num_matches].size = ptr_size;
1431-
info->matches[info->num_matches].offset = 0;
1432-
info->matches[info->num_matches].type = type;
1433-
++info->num_matches;
1428+
if (lldb_info->num_matches < MAX_MATCHES) {
1429+
lldb_info->matches[lldb_info->num_matches].addr = (void*)ptr_addr;
1430+
lldb_info->matches[lldb_info->num_matches].size = ptr_size;
1431+
lldb_info->matches[lldb_info->num_matches].offset = 0;
1432+
lldb_info->matches[lldb_info->num_matches].type = type;
1433+
++lldb_info->num_matches;
14341434
}
14351435
}
14361436
}

0 commit comments

Comments
 (0)
This repository has been archived.