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] = ""...}
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.
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?).
in a directory of your choice (i.e. $(HOME)/distribs/gdb_printers). You will get 'python' subdirectory in the checkout directory. This makes pretty printing usable via command-line interface of gdb ( >(gdb) p my_std_string ).
The usual way to examine data in your program is with the print command (abbreviated p ), or its synonym inspect . It evaluates and prints the value of an expression of the language your program is written in (see section Using GDB with Different Languages).
The ptype [ARG] command will print the type. Show activity on this post.
Do you know any simpler way to print everything ?
(gdb) set print elements 0
Documentation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With