如何使gdb保存命令历史? [英] How can I make gdb save the command history?

查看:268
本文介绍了如何使gdb保存命令历史?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何设置 gdb ,以便保存命令历史记录?当启动新的 gdb 会话时,我想使用向上箭头键访问上一个会话的命令。

How can I set up gdb so that it saves the command history? When starting a new gdb session I'd like to use the arrow up keys to access the commands of the previous sessions.

推荐答案

命令历史涵盖在 GDB手册,22.3命令历史记录。创建一个文件 $ HOME / .gdbinit ,将其权限更改为 0600 ,并添加以下内容:

Command history is covered in the GDB manual, 22.3 Command History. Create a file $HOME/.gdbinit, change its permissions to 0600, and add the following content:

set history save on

您可以设置以下命令保存的过去命令数。该命令被描述为设置gdb在其历史列表中保留的命令数,默认为环境变量GDBHISTSIZE的值,如果未设置此变量,则为256。GDBHISTSIZE的非数值为如果大小是无限制的,或者如果GDBHISTSIZE是负数或空字符串,那么历史列表中的gdb命令数量是无限制的

You can set the number of past commands saved with the following. The command is described as "Set the number of commands which gdb keeps in its history list. This defaults to the value of the environment variable GDBHISTSIZE, or to 256 if this variable is not set. Non-numeric values of GDBHISTSIZE are ignored. If size is unlimited or if GDBHISTSIZE is either a negative number or the empty string, then the number of commands gdb keeps in the history list is unlimited".

set history size <size>

相关命令是设置历史记录remove-duplicateates< count> 。该命令被描述为控制在命令历史记录列表中删除重复的历史记录条目。如果count不为零,gdb将回顾最后一个计数历史记录条目,并删除第一个条目当前条目被添加到命令历史列表中,如果count是无限制的,那么这个lookbehind是无界的,如果count为0,则删除重复的历史记录条目被禁用

A related command is set history remove-duplicates <count>. The command is described as "Control the removal of duplicate history entries in the command history list. If count is non-zero, gdb will look back at the last count history entries and remove the first entry that is a duplicate of the current entry being added to the command history list. If count is unlimited then this lookbehind is unbounded. If count is 0, then removal of duplicate history entries is disabled".

set history remove-duplicates <count>

默认情况下,gdb将历史记录保存到文件./.gdb_history 在当前目录。如果您希望您的命令历史不依赖于您所在的目录,还包括:

By default, gdb saves the history into the file ./.gdb_history in the current directory. If you want your command history not to depend on the directory you are in, also include:

set history filename ~/.gdb_history

这篇关于如何使gdb保存命令历史?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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