eclipse-cdt-cloud / eclipse-cdt-cloud/cdt-gdb-adapter

How to support GDB’s symbol index cache?

Open
#567 5 comments 0 reactions 1 assignee Claimed by @cwalther View on GitHub
Dominant language
TypeScript
Stars
39
Forks
56
Avg merge
3d 9h
Merged PRs (30d)
2

Description

I have recently happened upon a GDB feature that speeds up starting a debug session a lot: the [automatic symbol index cache](https://sourceware.org/gdb/current/onlinedocs/gdb.html/Index-Files.html#Automatic-symbol-index-cache). In my testing, it reduces the time taken by the `-file-exec-and-symbols` command, which previously made up the bulk of starting a debug session, from about 12 seconds to about 1 second when the same binary had been used before.

The problem is, the commands to enable this need to be issued before `-file-exec-and-symbols`, and there is currently none among the `preConnectCommands`, `initCommands`, and similar configuration options that is executed that early. So I need some additions to the adapter, and I would like to discuss which.

Also, the commands to use differ between GDB versions: on my GDB 11, they are

```
-gdb-set index-cache directory /path/to/cache/directory
-gdb-set index-cache on
```

whereas in [GDB 12 and later](https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=7bc5c369) they are

```
-gdb-set index-cache directory /path/to/cache/directory
-gdb-set index-cache enabled on
```

(the old variant may still work as a deprecated alias, but I have not checked up to which version).

I can think of two ways of supporting this:
1. Add another `…Commands` setting (`preProgramCommands`?) that is executed at an appropriate time. This is very flexible and potentially also useful for other purposes, but maybe having too many of them is confusing?
2. Add specific settings for the index cache:
- either separate `index-cache` (boolean) and `index-cache-directory` (string)
- or a combined `index-cache` that can be set to `true` to enable the cache with the default directory or to a string to enable the cache in that directory (probably nobody wants to set a directory but not enable the cache?).

This would also allow us to handle the GDB version difference internally so the user does not need to care about it. But maybe we don’t want to go down the route of having options for every single GDB feature?

Any opinions? Other ideas? I have no strong preference myself.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.