[lldb-dev] [Bug 20108] New: Teach 'br set' a new option: stop if the stack matches a given stack-pattern

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Jun 23 13:07:39 PDT 2014


http://llvm.org/bugs/show_bug.cgi?id=20108

            Bug ID: 20108
           Summary: Teach 'br set' a new option: stop if the stack matches
                    a given stack-pattern
           Product: lldb
           Version: unspecified
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: All Bugs
          Assignee: lldb-dev at cs.uiuc.edu
          Reporter: james.widman at gmail.com
    Classification: Unclassified

Suppose a future lldb provides a built-in command, 'stackpat', which takes a
name argument that can later be used to refer to a pattern---given as a
multi-line sequence when the command is entered---that matches zero or more
stacks.

As a convenience, stackpat would also take an option, -b, that causes the
topmost frame of the pattern to be implicitly passed either to 'br set' or to
_regexp-break.

Example session:

% cat -n foo.c
     1    void h() {}
     2    void g() { h(); }
     3    void f() { h(); g(); }
     4    int main(int argc, char *argv[])
     5    {
     6        h();
     7        g();
     8        f();
     9        return 0;
    10    }
% cc -g foo.c -o a.out
% lldb -x ./a.out
Current executable set to './a.out' (x86_64).
(lldb) stackpat x -b
Enter frame patterns (just like args to 'breakpoint set' or 'b'). Type DONE to
end.
> h
> g
> f
> DONE
Breakpoint 1: where = a.out`h + 4 at foo.c:1, address = 0x0000000100000f44,
stackpat=x
(lldb) process launch
Process 55500 launched: './a.out' (x86_64)
Process 55500 stopped
* thread #1: tid = 0x1c8077, 0x0000000100000f44 a.out`h + 4 at foo.c:1, queue =
'com.apple.main-thread', stop reason = breakpoint 1.1
    frame #0: 0x0000000100000f44 a.out`h + 4 at foo.c:1
-> 1       void h() {}
   2       void g() { h(); }
   3       void f() { h(); g(); }
   4       int main(int argc, char *argv[])
   5       {
   6           h();
   7           g();
(lldb) bt
* thread #1: tid = 0x1c8077, 0x0000000100000f44 a.out`h + 4 at foo.c:1, queue =
'com.apple.main-thread', stop reason = breakpoint 1.1
  * frame #0: 0x0000000100000f44 a.out`h + 4 at foo.c:1
    frame #1: 0x0000000100000f59 a.out`g + 9 at foo.c:2
    frame #2: 0x0000000100000f6e a.out`f + 14 at foo.c:3
    frame #3: 0x0000000100000f95 a.out`main(argc=1, argv=0x00007fff5fbfebc0) +
37 at foo.c:8
(lldb)

---


Here's an example with C++, where it isn't always clear which template
arguments you want to use in the function name regex. Example:

% cat -n foo.cpp
     1
     2    namespace __Some_lib_impl
     3    {
     4        struct apparently_unrelated_class {};
     5    }
     6
     7    namespace N
     8    {
     9        template<class T>
    10            struct stuff { typedef
__Some_lib_impl::apparently_unrelated_class U; };
    11    } /* N */
    12
    13
    14    template<class T> void tn() {}
    15    template<class T> void t2() { tn< typename N::stuff<T>::U >(); }
    16    template<class T> void t1() { t2<T>(); }
    17    template<class T> void t0() { t1<T>(); }
    18    int main(int argc, char *argv[])
    19    {
    20        tn<int>();
    21        t0<double>();
    22        return 0;
    23    }
% cc -g foo.cpp
% lldb -x ./a.out
Current executable set to './a.out' (x86_64).
(lldb) stackpat y -b
Enter frame patterns (just like args to 'breakpoint set' or 'b'). Type DONE to
end.
> tn
> ...
> t0
> main
> DONE
Breakpoint 1: 1 location, stackpat = y
(lldb) r
Process 55605 launched: './a.out' (x86_64)
Process 55605 stopped
* thread #1: tid = 0x1ca1b3, 0x0000000100000f64 a.out`void
tn<__Some_lib_impl::apparently_unrelated_class>() + 4 at foo.cpp:14, queue =
'com.apple.main-thread', stop reason = breakpoint 1.1
    frame #0: 0x0000000100000f64 a.out`void
tn<__Some_lib_impl::apparently_unrelated_class>() + 4 at foo.cpp:14
   11      } /* N */
   12
   13
-> 14      template<class T> void tn() {}
   15      template<class T> void t2() { tn< typename N::stuff<T>::U >(); }
   16      template<class T> void t1() { t2<T>(); }
   17      template<class T> void t0() { t1<T>(); }
(lldb) bt
* thread #1: tid = 0x1ca1b3, 0x0000000100000f64 a.out`void
tn<__Some_lib_impl::apparently_unrelated_class>() + 4 at foo.cpp:14, queue =
'com.apple.main-thread', stop reason = breakpoint 2.1
  * frame #0: 0x0000000100000f64 a.out`void
tn<__Some_lib_impl::apparently_unrelated_class>() + 4 at foo.cpp:14
    frame #1: 0x0000000100000f59 a.out`void t2<double>() + 9 at foo.cpp:15
    frame #2: 0x0000000100000f49 a.out`void t1<double>() + 9 at foo.cpp:16
    frame #3: 0x0000000100000f39 a.out`void t0<double>() + 9 at foo.cpp:17
    frame #4: 0x0000000100000f10 a.out`main(argc=1, argv=0x00007fff5fbfebd0) +
32 at foo.cpp:21
(lldb)

The stackpat name ("x", "y" above) could then be re-used in other 'br set'
commands or in other stackpat commands.

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-dev/attachments/20140623/486d91f3/attachment.html>


More information about the lldb-dev mailing list