debug information for stl containers in Atmel Studio 7

Go To Last Post
6 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I've created a C++ project for an Atmel CortexM4 processor.

 

I am unable to debug stl containers, specifically std::vector<int>, using Atmel Studio 7.

 

Code:

std::vector<int> v;
v.reserve(20);
  ~~~~~~~

Debugger watch:

v	                                            {...}
|--->    std::vector<int, std::allocator<int> >	    std::_Vector_base<int, std::allocator<int> >	{std::_Vector_base<int, std::allocator<int> >}	std::_Vector_base<int, std::allocator<int> >

Can't go inside members of v (they are not presented).

Furthermore, Visual Assist doesn't recognize the vector members (no auto-complete, ~~~~~~~~ line below member function calls)

 

Is there a GCC compiler or linker flag I should insert to allow debugging?

I'm compiling w/o optimizations, with maximum debugging information (-g3, -ggdb).

 

Last Edited: Thu. May 4, 2017 - 11:22 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

On the whole C and C++ library code is never supplied with source.

 

The way DWARF debugging works is that the generated code does not contain the actual lines of C that generated the code. It simply contains references to source files and line numbers. So somewhere in the code that built STL there is probably a vector.cpp or something that forms part of the STL. The man who builds the compiler for you has the source files of all compiler and all the library code on his machine. Lets say he has that in /home/fred/armgcc/stl/utils/vector.cpp and the line that implements std::vector<int> is on line 451. So the STL code will include "/home/fred/armgcc/stl/utils/vector.cpp, like 451"

 

But when that STL binary arrives on your PC you don't have /home/fred and you definitely don't have vector.cpp so this reference would make no sense. As such all the library code is either just built without -g in the first place. Or, if for development, it contains the -g references then the "strip" utility will be used on it before it is distributed.

 

So, no, you aren't going to be able to step into the source of the lib.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

STL containers are implemented in their respective header file, not in source files.

   vector, for example : vector.h, stl_vector.h.

Here is an example of the implementation of push_back, one of 'vector's functions:

      // [23.2.4.3] modifiers
      /**
       *  @brief  Add data to the end of the %vector.
       *  @param  __x  Data to be added.
       *
       *  This is a typical stack operation.  The function creates an
       *  element at the end of the %vector and assigns the given data
       *  to it.  Due to the nature of a %vector this operation can be
       *  done in constant time if the %vector has preallocated space
       *  available.
       */
      void
      push_back(const value_type& __x)
      {
	if (this->_M_impl._M_finish != this->_M_impl._M_end_of_storage)
	  {
	    _Alloc_traits::construct(this->_M_impl, this->_M_impl._M_finish,
	                             __x);
	    ++this->_M_impl._M_finish;
	  }
	else
#if __cplusplus >= 201103L
	  _M_emplace_back_aux(__x);
#else
	  _M_insert_aux(end(), __x);
#endif
      }

 

It exists in the gnu toolchain supplied with Atmel 7, under : 

Atmel\Studio\7.0\toolchain\arm\arm-gnu-toolchain\arm-none-eabi\include\c++\6.2.1\bits

 

So, lack of source code is not the reason for not stepping into STL code. Maybe something to do with templated code?

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

My question is why would you even want to debug standard library code? Surely you don't want to step INTO the reserve function of std::vector?

My digital portfolio: www.jamisonjerving.com

My game company: www.polygonbyte.com

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

Moved to ARM side.

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I have no wish to debug the standard library.

I want to debug my code easily with the ability to watch STL object members (variables, not functions), w/o needing to add log-prints.

For example, the number of elements stored in a vector object ( or other members that allow to calculate this number ).

 

Last Edited: Fri. May 5, 2017 - 06:37 AM