Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

Inferior method execution ignores default arguments #20603

Open Quuxplusone opened 10 years ago

Quuxplusone commented 10 years ago
Bugzilla Link PR20604
Status NEW
Importance P normal
Reported by Randy Smith (rdsmith@chromium.org)
Reported on 2014-08-09 14:59:31 -0700
Last modified on 2014-08-17 14:28:38 -0700
Version unspecified
Hardware HP Linux
CC emaste@freebsd.org, jingham@apple.com
Fixed by commit(s)
Attachments test.cc (291 bytes, application/octet-stream)
Blocks
Blocked by
See also
Created attachment 12870
Example method definition with default arg.

If a C++ method is defined as taking a default argument, lldb does not take
that into account in evaluating an "expr" command.  (I first noticed this
trying to use
some of the default std::string methods, specifically the constructor which
takes
a default allocator).

Reproduction: On Linux, compile the attached file with "g++ -g test.cc", then:

$ lldb a.out
(lldb) target create "a.out"
Current executable set to 'a.out' (x86_64).
(lldb) break -f test.cc -l 19
invalid command 'breakpoint -f'
(lldb) break set  -f test.cc -l 19
Breakpoint 1: where = a.out`main + 73 at test.cc:19, address =
0x0000000000400acd
(lldb) run
Process 8036 launching
Process 8036 launched: '/usr/local/google/home/rdsmith/tmp/a.out' (x86_64)
Process 8036 stopped
* thread #1: tid = 8036, 0x00007f7d095486b0, name = 'a.out'
    frame #0:
(lldb) Process 8036 stopped
* thread #1: tid = 8036, 0x0000000000400acd a.out`main(argc=1,
argv=0x00007fff79dcc1b8) + 73 at test.cc:19, name = 'a.out', stop reason = br\
eakpoint 1.1
    frame #0: 0x0000000000400acd a.out`main(argc=1, argv=0x00007fff79dcc1b8) + 73 at test.cc:19
   16
   17     testclass t;
   18
-> 19     t.test_method(8);
   20
   21     std::cout << abc << std::endl;
   22   }
(lldb) expr t.test_method()
error: too few arguments to function call, expected 1, have 0
note: 'test_method' declared here
error: 1 errors parsing expression
(lldb) expr t.test_method(2)
2
(lldb)
Quuxplusone commented 10 years ago

Attached test.cc (291 bytes, application/octet-stream): Example method definition with default arg.

Quuxplusone commented 10 years ago

It doesn't look like clang ever emits the DW_AT_default_value tag, so lldb has no way of knowing that a parameter has a default value or what it is.

So the first step would be to file a bug on clang to generate DW_AT_default_value, then we can do something reasonable with it.

Quuxplusone commented 10 years ago

Filed as http://llvm.org/bugs/show_bug.cgi?id=20690 .