"errror: reference to '...' is ambiguous" message in LLDB
When I try to print a local variable in LLDB, e.g. with po foo, and there's a function with the same name, I get this message:
error: reference to 'foo' is ambiguous
candidate found by name lookup is 'foo'
candidate found by name lookup is 'some_module::some_struct::{{impl}}::foo'
Just found this bug. Is there a workaround / something you can pass to lldb to make it print the local variable?
Michael Hewson at 2018-06-27 18:06:15
I have encountered this bug as well.
samg31 at 2018-07-03 15:22:36
frame variable varnamedid the job as a workaround for me.Lukas at 2018-08-07 05:57:29
Having a pair of single quotation mark around the variable name can solve this issue, but I found this trick by randomly trying and I reached this issue when I'm digging more into this issue...
Zeyi (Rice) Fan at 2019-01-03 06:08:20
I was able to get the info by first just directly printing out the memory address for the object:
example (
requestis the local variable name here)>>> (lldb) frame variable request (NSMutableURLRequest *) request = 0x00006000002df950 >>> (lldb) po 0x00006000002df950 <NSMutableURLRequest: 0x6000002df950> { URL: http://example.com }epai at 2019-05-28 18:08:42
Any update on this?
Alexander Regueiro at 2019-08-17 21:09:37
I ran into this running the
rustctest suite and lldb 8.0.0.It looks like I can always repro with a program like this:
fn main() { let ascii = 123; println!("hi"); }After breaking at
println!, we can elicit:(lldb) p ascii error: reference to 'ascii' is ambiguous candidate found by name lookup is 'ascii' candidate found by name lookup is 'core::ascii'It looks like I can repro this by having my local var shadow any direct submodule of
core(array,unique, &c).This may be related to this lldb (todo) "project": Fix local variable lookup in the lldb expression parser
In lldb,
printis an alias forexpr, whereasframe variabledoesn't use the expression parser:The “frame variable” command is not a full expression parser but it does support a few simple operations [...]
— https://lldb.llvm.org/use/tutorial.html#examining-stack-frame-state
It also looks like this project, if completed, would at least provide a workaround: Expression parser needs syntax for “{symbol,type} A in CU B.cpp”
Joe Ranweiler at 2019-09-01 01:35:34
See also:
We have a not-yet-implemented scheme to allow some syntax like:
(lldb) expr $$foo.c$bar(5)that would mean: look up the version of bar defined in foo.c and call that. [...]— http://lists.llvm.org/pipermail/lldb-dev/2016-June/010623.html
Joe Ranweiler at 2019-09-01 01:46:37