让GDB在调试时完全打印一个大的std :: map [英] Having GDB print a big std::map fully while debugging

查看:1203
本文介绍了让GDB在调试时完全打印一个大的std :: map的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究使用大地图的算法.我尝试在纸上进行跟踪时将算法与GDB一起使用,以查看出错的地方. 但是随着地图变大,GDB将其缩写并停止显示我需要的下一个值:

I'm working on an algorithm which uses a big map. I'm trying to follow the algorithm along with GDB while doing it on paper to see where it goes wrong. But as the map gets big, GDB abbreviates it and stop showing the next values, which I need:

(gdb) p R
$1 = std::map with 140 elements = {[0] = "", [1] = "e", [2] = "", [3] = "", [4] = "", [5] = "", [6] = "", [7] = "", [8] = "a", [9] = "a", [10] = "", [11] = "", [12] = "", [13] = "", [14] = "", 
  [15] = "", [16] = "a", [17] = "b", [18] = "", [19] = "", [20] = "", [21] = "", [22] = "b", [23] = "", [24] = "", [25] = "a", [26] = "", [27] = "", [28] = "", [29] = "", [30] = "", [31] = "b", 
  [32] = "", [33] = "a", [34] = "", [35] = "", [36] = "", [37] = "", [38] = "", [39] = "", [40] = "(b|a)", [41] = "e", [42] = "", [43] = "", [44] = "", [45] = "", [46] = "", [47] = "", [48] = "", 
  [49] = "", [50] = "", [51] = "a*.a", [52] = "", [53] = "", [54] = "", [55] = "", [56] = "", [57] = "", [58] = "", [59] = "", [60] = "", [61] = "", [62] = "", [63] = "", [64] = "", [65] = "a", 
  [66] = "b", [67] = "", [68] = "", [69] = "", [70] = "", [71] = "", [72] = "b.a*.a", [73] = "", [74] = "a", [75] = "", [76] = "", [77] = "", [78] = "", [79] = "", [80] = "b", [81] = "", [82] = "a", 
  [83] = "", [84] = "", [85] = "", [86] = "", [87] = "", [88] = "", [89] = "(b|a)", [90] = "e", [91] = "", [92] = "", [93] = "", [94] = "", [95] = "", [96] = "", [97] = "", [98] = "", [99] = ""...}

我尝试使用p R [100]访问元素,但GDB不理解此语法:

I've tried to access elements with p R[100] but GDB doesn't understand this syntax:

(gdb) p R[100]
Attempt to take address of value not located in memory.

我听说GDB使用漂亮的打印机(即python脚本)在命令print中进行漂亮的显示,但是我不确定在打印我的std :: map时是哪一个漂亮的打印机.不知道如何修改它. 另外,我真的不知道如何在STL容器中处理内存(我还没有研究分配器和东西),所以不确定我是否要输入该代码.

I've heard that GDB uses pretty-printers which are python scripts to make a pretty display with the command print, but I'm not sure which pretty-printer exactly when I print my std::map and I'm not sure how to modify it. Also I don't really know how memory is handled (I didn't study allocators and stuff yet) in STL containers so I'm not sure I want to go into that code.

您知道打印所有内容的更简单方法吗?还是必须修改漂亮打印机? (如果可以,请给我提示要修改的文件和注册更改的命令?).

Do you know any simpler way to print everything? Or must I modify pretty-printers? (if so can you give me a hint on which file to modify and which commands to register the changes please?).

推荐答案

您知道打印所有内容的更简单方法吗?

Do you know any simpler way to print everything ?

(gdb) set print elements 0

文档.

这篇关于让GDB在调试时完全打印一个大的std :: map的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆