How to grep on gdb print

前端 未结 3 1480
灰色年华
灰色年华 2021-02-07 22:31

Is there a way to grep on the output of print command in gdb? In my case, I am debugging a core dump using gdb and the object I am debugging contains hell lots of elements. I am

3条回答
  •  不要未来只要你来
    2021-02-07 23:03

    (gdb) print *this | grep

    The "standard" way to achieve this is to use Meta-X gdb in emacs.

    An alternative:

    (gdb) set logging on
    (gdb) print *this
    (gdb) set logging off
    (gdb) shell grep attribute gdb.txt
    

    The patch mentioned by cnicutar sure looks attractive compared to the above. I am guessing the reason it (or its equivalent) was never submitted is that most GDB maintainers use emacs, and so don't have this problem in the first place.

提交回复
热议问题