Timmmm
Timmmm

Reputation: 96537

How to list more lines of code code in LLDB

How do I get LLDB to list more lines of code in the current frame. By default it only does 7. This is the best I can do so far:

(lldb) f
frame #9: 0x000000010001fce0 DualIssueInstructionSchedulerTest`void std::__1::random_shuffle<std::__1::__wrap_iter<exchange::ExchangeMessage*>, ExchangeWithLotsOfMessages::test_method()::$_5&>(__first=__wrap_iter<exchange::ExchangeMessage *> @ 0x00007ffeefbf5298, __last=__wrap_iter<exchange::ExchangeMessage *> @ 0x00007ffeefbf5290, __rand=0x00007ffeefbf56e0)::$_5&&&) at algorithm:3203
   3200         for (--__last; __first < __last; ++__first, --__d)
   3201         {
   3202             difference_type __i = __rand(__d);
-> 3203             swap(*__first, *(__first + __i));
   3204         }
   3205     }
   3206 }
(lldb) l 3100
   3100     result_type max() const {return b();}
   3101
   3102     friend bool operator==(const uniform_int_distribution& __x,
   3103                            const uniform_int_distribution& __y)
   3104         {return __x.__p_ == __y.__p_;}
   3105     friend bool operator!=(const uniform_int_distribution& __x,
   3106                            const uniform_int_distribution& __y)
   3107             {return !(__x == __y);}
   3108 };
   3109
(lldb) l
   3110 template<class _IntType>
   3111 template<class _URNG>
   3112 typename uniform_int_distribution<_IntType>::result_type
   3113 uniform_int_distribution<_IntType>::operator()(_URNG& __g, const param_type& __p)
   3114 {
   3115     typedef typename conditional<sizeof(result_type) <= sizeof(uint32_t),
   3116                                             uint32_t, uint64_t>::type _UIntType;
   3117     const _UIntType _Rp = __p.b() - __p.a() + _UIntType(1);
   3118     if (_Rp == 1)
   3119         return __p.a();
(lldb) l
   3120     const size_t _Dt = numeric_limits<_UIntType>::digits;
   3121     typedef __independent_bits_engine<_URNG, _UIntType> _Eng;
   3122     if (_Rp == 0)
   3123         return static_cast<result_type>(_Eng(__g, _Dt)());
   3124     size_t __w = _Dt - __clz(_Rp) - 1;
   3125     if ((_Rp & (std::numeric_limits<_UIntType>::max() >> (_Dt - __w))) != 0)
   3126         ++__w;
   3127     _Eng __e(__g, __w);
   3128     _UIntType __u;
   3129     do
(lldb) l
   3130     {
   3131         __u = __e();
   3132     } while (__u >= _Rp);
   3133     return static_cast<result_type>(__u + __p.a());
   3134 }
   3135
   3136 #if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_RANDOM_SHUFFLE) \
   3137   || defined(_LIBCPP_BUILDING_LIBRARY)
   3138 class _LIBCPP_TYPE_VIS __rs_default;
   3139

Is there a way to increase the context for f or lass a range of lines to l?

Upvotes: 3

Views: 4560

Answers (1)

Jim Ingham
Jim Ingham

Reputation: 27110

If you just want to widen the window for one source listing, do:

(lldb) source list -c 40 -l 3100

then just hitting return (to auto-repeat the command) will continue with this count.

There are also two lldb settings that control the default for how much source gets printed:

(lldb) help settings set
...
  stop-line-count-after        -- The number of sources lines to display that come after the current source line when displaying a stopped context.
  stop-line-count-before       -- The number of sources lines to display that come before the current source line when displaying a stopped context.

The "current source line" is the pc if you are looking at the stop listing and the source line you passed to "list" if you are using that command.

Repeated calls to "l" (or just pressing to auto-repeat) will just print the sum of the two number of lines. So you would put:

settings set stop-line-count-before 10
settings set stop-line-count-after 10

or whatever number you like in your ~/.lldbinit to change this behavior.

Upvotes: 8

Related Questions