回答
從SVN
svn://gcc.gnu.org/svn/gcc/trunk/libstdc++-v3/python
獲取蟒蛇觀衆以下內容添加到您的~/.gdbinit
python
import sys
sys.path.insert(0, '/path/to/pretty-printers/dir')
from libstdcxx.v6.printers import register_libstdcxx_printers
register_libstdcxx_printers (None)
end
然後打印應該只是工作:
std::map<int, std::string> the_map;
the_map[23] = "hello";
the_map[1024] = "world";
在GDB:
(gdb) print the_map
$1 = std::map with 2 elements = { [23] = "hello", [1024] = "world" }
要回到舊視圖使用print /r
(/r
爲原料)。
可能的重複以及如何實際在GDB中使用它來打印內容?有什麼需要設置。 thx – vehomzzz 2010-03-23 12:18:47
一旦加載代碼在.gdbinit中,那麼打印應該只是工作,回到舊的視圖,你做一個打印/ r(/ r是原始的) (格式顯然很糟糕,我的道歉) std :: map
考慮修改您的答案,包括您的評論此信息。這種格式不會太糟糕。 – camh 2010-04-21 13:18:14
的libstdcxx_printers包括最近版本的GCC,所以如果你使用GCC 4.5以後,那麼你不需要做任何事情,漂亮的打印工作的很好。
(gdb) p v
$1 = std::vector of length 3, capacity 3 = {std::set with 3 elements = {
[0] = 1, [1] = 2, [2] = 3}, std::set with 2 elements = {[0] = 12,
[1] = 13}, std::set with 1 elements = {[0] = 23}}
(gdb) p v[1]
$2 = std::set with 2 elements = {[0] = 12, [1] = 13}
要禁用漂亮的印刷使用p/r
或print/r
獲得「原始」輸出。
- 1. 如何使用GDB調試器查看__asm__內容?
- 2. 通過gdb觀看stl向量的內容
- 3. 查看Cookie容器包含的內容?
- 4. MEF並查看容器中的內容
- 5. 如何查看blob內容
- 6. STL:容器的容器
- 7. 查看內容
- 8. 內容查看器Android
- 9. 如何查看DbgPrint的內容?
- 10. STL容器內存問題
- 11. 別名未使用修改STL容器的實際內容
- 12. 同時使用STL容器
- 13. 如何查看查詢表的內容
- 14. 如何在GDB中漂亮地打印STL容器?
- 15. stl兼容的容器
- 16. GDB:漂亮的打印類包含STL容器
- 17. 的UITableViewCell的內容查看的內容不可見使用UISearchDisplayController
- 18. 如何查看Github用戶內容?
- 19. Android:如何使用調試器查看數組內容
- 20. Liferay:如何從網頁內容中使用PDF查看器
- 21. 使用STL容器UPPER_BOUND&LOWER_BOUND在地圖
- 22. C++ STL容器
- 23. jsPDF:查看PDF的內容
- 24. ADBanner查看內容
- 25. 內容查看ViewModelLocator.AutowireViewModel
- 26. 如何在default.aspx中查看內容佔位符的內容?
- 27. 如何使用icc編譯器檢查gdb中std :: vector的內容?
- 28. 如何查看chrome中的IndexedDB內容?
- 29. 如何查看FactoryGirl輸出的內容?
- 30. 如何查看Body Tag的內容?
gdb的數字版本是你在談論 – 2010-03-22 12:12:05
7及以上版本。謝謝。 – vehomzzz 2010-03-22 12:17:38
[如何漂亮地打印GDB中的STL容器?](https://stackoverflow.com/questions/11606048/how-to-pretty-print-stl-containers-in-gdb) – 2017-09-24 10:25:55