From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9059 invoked by alias); 21 Jul 2014 18:00:45 -0000 Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org Received: (qmail 9046 invoked by uid 89); 21 Jul 2014 18:00:44 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.9 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD,SPF_PASS autolearn=ham version=3.3.2 X-HELO: cliff.cs.toronto.edu Received: from cliff.cs.toronto.edu (HELO cliff.cs.toronto.edu) (128.100.3.120) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Mon, 21 Jul 2014 18:00:43 +0000 Received: from apps0.cs.toronto.edu ([128.100.3.40] helo=ara-vm-ku1404-3 ident=matei) by cliff.cs.toronto.edu with esmtp (Exim 4.76) (envelope-from ) id 1X9HtB-0000bz-G1 for gdb@sourceware.org; Mon, 21 Jul 2014 14:00:41 -0400 Date: Mon, 21 Jul 2014 18:00:00 -0000 From: Matei David To: gdb@sourceware.org Subject: help with pretty printers Message-ID: <20140721140045.3b722065@ara-vm-ku1404-3> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="MP_/erj8sD6+WtgBQ5vJcX_Bc/C" X-SW-Source: 2014-07/txt/msg00020.txt.bz2 --MP_/erj8sD6+WtgBQ5vJcX_Bc/C Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Content-Disposition: inline Content-length: 3136 Hi, I'm working on a pretty printer for boost::intrusive ("bi") data structures, and I'm having trouble accessing certain types and methods in gdb. Consider the attached cpp file. I'm using stock Kubuntu 14.04: Linux 3.13.0-32-generic #57-Ubuntu SMP x86_64 gcc (Ubuntu 4.8.2-19ubuntu1) 4.8.2 boost 1.55.0 GNU gdb (Ubuntu 7.7-0ubuntu3.1) 7.7 I'm compiling with: g++ -O0 -ggdb3 -fno-inline -std=c++11 -Wall -Wextra -pedantic -o test-intrusive-list test-intrusive-list.cpp If I break at line 40 (return), I get: (gdb) p l1.begin() Cannot evaluate function -- may be inlined (gdb) My goal here is to write a printer for bi::list. Because this template class is customized by various traits classes at compile time, traversing it at runtime is not as simple as accessing various struct fields. Instead, I need to use some of the methods embedded in the specific instantiation I deal with. The definition of bi::list is in /usr/include/boost/intrusive/list.hpp I'll briefly decode it here: - bi::list is a public bi::list_impl - a bi::list_impl has a root "node" with pointers to a circular linked list of "value" elements - each "value" has an embedded "node" part which is used to traverse the list - given a node n from a list l, access to the next node in that list is done through the static method l::node_traits::get_next(n) found in the traits class l::node_traits - different bi::list instantiations may use different fields of "value" to maintain list node pointers - for a bi::list_impl l, the root node is l.data_.root_plus_size_.root_, or equivalently, l.get_root_node() - the first element in l is: list_impl<...>::node_traits::get_next(l.get_root_node()) or, * (l.begin()) As I described above, for some reason I am unable to call l.begin(). I then tried to access the traits method by hand, but I can't do that either: (gdb) ptype/rmt l1 type = class boost::intrusive::list, (boost::intrusive::link_mode_type)0> >, void, void> : public boost::intrusive::list_impl, (boost::intrusive::link_mode_type)0>, unsigned long, true> { } (gdb) ptype/rmt boost::intrusive::list_impl, (boost::intrusive::link_mode_type)0>, unsigned long, true>::node_traits There is no field named node_traits (gdb) p l1.data_.root_plus_size_.root_ $2 = {_val = 0, _prev_1 = 0x7fffffffd4a0, _next_1 = 0x7fffffffd4a0, _prev_2 = 0x7fffffffd5e0, _next_2 = 0x0} (gdb) p boost::intrusive::list_impl, (boost::intrusive::link_mode_type)0>, unsigned long, true>::node_traits::get_next(l1.data_.root_plus_size_.root_) No type node_traits" within class or namespace "boost::intrusive::list_impl, (boost::intrusive::link_mode_type)0>, unsigned long, true>". Am I missing some debugging symbols here? Are there some other compile flags I can try? Is there something else I could try to find and call the get_next() method? Thanks, Matei --MP_/erj8sD6+WtgBQ5vJcX_Bc/C Content-Type: text/x-c++src Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=test-intrusive-list.cpp Content-length: 1266 #include #include namespace bi = boost::intrusive; struct A { A(int i = 0) : _val(i) {} int _val; A* _prev_1; A* _next_1; A* _prev_2; A* _next_2; }; template struct NT_1 { typedef A node; typedef typename bi::pointer_traits::template rebind_pointer::type node_ptr; typedef typename bi::pointer_traits::template rebind_pointer::type const_node_ptr; static node_ptr get_next(const node_ptr& n) { return n->_next_1; } static node_ptr get_next(const const_node_ptr& n) { return n->_next_1; } static void set_next(const node_ptr& n, const node_ptr& next){ n->_next_1 = next; } static node_ptr get_previous(const node_ptr& n) { return n->_prev_1; } static node_ptr get_previous(const const_node_ptr& n) { return n->_prev_1; } static void set_previous(const node_ptr& n, const node_ptr& prev) { n->_prev_1 = prev; } }; typedef bi::trivial_value_traits< NT_1, bi::normal_link > VT_1; typedef bi::list< A, bi::value_traits< VT_1 > > List_1; int main() { List_1 l1; A a(42); l1.push_front(a); return 0; } --MP_/erj8sD6+WtgBQ5vJcX_Bc/C--