Bug 1222342 - gdb history seems almost entirely broken
Summary: gdb history seems almost entirely broken
Status: NEW
Alias: None
Product: openSUSE Tumbleweed
Classification: openSUSE
Component: Development (show other bugs)
Version: Current
Hardware: Other Other
: P5 - None : Normal (vote)
Target Milestone: ---
Assignee: Tom de Vries
QA Contact: E-mail List
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-04-04 21:55 UTC by ell1e
Modified: 2024-05-22 11:25 UTC (History)
2 users (show)

See Also:
Found By: ---
Services Priority:
Business Priority:
Blocker: ---
Marketing QA Status: ---
IT Deployment: ---
matz: needinfo? (el)


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description ell1e 2024-04-04 21:55:35 UTC
For some reason, the gdb history seems almost entirely broken. This might be a user error, but then maybe it would be worth poking upstream about making this somehow more obvious.

EXPECTED BEHAVIOR: I do whatever in gdb for whatever amount of time. Then I use "quit". Then I relaunch it. All the commands I used before should show up when I press up arrow. I don't really care if the order is messed up or if there are duplicates or not, as long as the commands come back in full.

ACTUAL BEHAVIOR: Whenever I use set history save on, I get one of these random things when I launch gdb later: 1. suddenly, the history only has half the commands I used in the previous session, or 2. it works (kind of rare), or 3. the entire history is nuked. What I get seems entirely random, but it's almost impossible to just get the history to work.

AFFECTED VERSION: GNU gdb (GDB; openSUSE Slowroll) 13.2

ADDITIONAL INFO: I'm also using the mozilla symbols.py gdb script ( https://gist.github.com/luser/193572147c401c8a965c#file-symbols-py ) in case that somehow interferes with history. If it does and this is a mozilla problem let me know, I really wouldn't know. I usually use gdb UIs that don't really rely on gdb's own history saving.
Comment 1 Michael Matz 2024-05-16 14:28:45 UTC
In the cases that stuff works unexpectedly, what does

(gdb) show history filename

say, and does the file in question there contain the expected things or not?

Do note that the default filename for saving history is ".gdb_history" in the _current directory_.  So, when you do your gdb session in various directories and don't overwrite the history filename you will be given the history from whatever
happened to be the history the last time you were in that very directory.
(You may want to do a global search for that filename and see if you indeed have
various random incarnations of it)

(Also, assigning to gdb maintainer).
Comment 2 Tom de Vries 2024-05-22 11:25:28 UTC
Saving history is a feature I haven't used before, but I've read the docs now to understand what it's supposed to do.

I agree with Michael that it looks like at least part of the problems reported in comment 0 can be caused by using the default history file which resides in the current directory.

Anyway, I've now enabled it in my .gdbinit, like so:
...
$ cat ~/.gdbinit
set history filename ~/.gdb_history
set history save on
...
and I'll test-drive it for a while.

I've tried out the use case of opening two gdb sessions at the same time, and the resulting history file looks sane, so at first glance there doesn't seem to any truncating going on there.

The reported "the history only has half the commands I used in the previous session" may just be the history size parameter, defaulting to 256 taking effect.