zoukankan      html  css  js  c++  java
  • gdb vector

    原文地址:http://blog.csdn.net/xiedejun1984/article/details/5752945

    示例指令:

    print "%s",(*(eles._M_impl._M_start)@1).content


    p *(eles._M_impl._M_start)@1

    $10 = {{

        title = "【海波】US News 2011年最新美国大学综合排名独家解读_波涛兄弟_新浪博客", 

        content = 

        "    【评分体系变动】  这是US NEWS  改变评分体系后,第一次发布美国大学排名,主要变化如下     1.       Peer Assessment  的权重由原来的25%降至22.5%   2.        首次加入了高中升学顾问对于大学的评价,他们的评价对于分数的权重为7.5%   3.        大学的Dean评分的权重由25%锐减至15%    因此,从某种意义上来说,在"...

      }}

    1. update your gdb

    gdb 7.0版本之后,如果在gdb中调用:

    (gdb) print myVector

    将会得到如下结果:

    $1 = std::vector of length 3, capacity 4 = {10, 20, 30}


    2. GDB STL Utilities

    http://www.stanford.edu/~afn/gdb_stl_utils/


    3. 打印数组

    gdb 7之前的版本不能直接打印vector,但是vector的内部实现是用数组array,所以找到array地址就可以打印出vector内容。

    1) 打印整个vector

    (gdb) print *(myVector._M_impl._M_start)@myVector.size()

    2) 打印第N个成员

    print *(myVector._M_impl._M_start)@N


    4. 自己实现打印函数,用gdb call调用该函数

    1) dump函数实现

    1. void dump(vector<int>& myVector)  
    2. {  
    3.     vector<int>::iterator it = myVector.begin();  
    4.     count << "[";   
    5.     for (; it != myVector.end(); ++it)  
    6.         count << *(it) << ", ";   
    7.     count << "]";   
    8. }  

    2) gdb调用:

    (gdb)call dump(youVector)

    完 

  • 相关阅读:
    75. Sort Colors
    101. Symmetric Tree
    121. Best Time to Buy and Sell Stock
    136. Single Number
    104. Maximum Depth of Binary Tree
    70. Climbing Stairs
    64. Minimum Path Sum
    62. Unique Paths
    css知识点3
    css知识点2
  • 原文地址:https://www.cnblogs.com/wangkangluo1/p/2169080.html
Copyright © 2011-2022 走看看