class BuildIDIndex

Defined at line 31 of file ../../src/developer/debug/zxdb/symbols/build_id_index.h

This class provides symbol files from disk or remote servers.

It can get files from different sources:

1. "ids.txt", which contains the mapping from Build IDs to ELF files.

2. ".build-id" directory, where an ELF file with Build ID "xxyyyy" is arranged at xx/yyyy.debug.

3. use a "symbol-index" file to get a list of "ids.txt" or ".build-id" directories.

4. explicitly given elf file path, or a directory of ELF files.

5. A symbol server, e.g., "gs://fuchsia-artifacts/debug".

Public Members

static const int kStatusIsFolder

Public Methods

Entry EntryForBuildID (const std::string & build_id)

Return the entry associated with the given build_id. This is the designated way to obtain

information from a BuildIDIndex.

The return value could include empty strings for missing values. If the build_id is not found

anywhere, the entry will include 3 empty strings for debug_info, binary and build_dir.

This function also caches the result for symbol files found in .build-id directory. Thus any

subsequent calls will just get the same cached entry, even if the symbol files are created on

the filesystem later. In this case, AddOneFile can be used to force indexing a file.

Defined at line 31 of file ../../src/developer/debug/zxdb/symbols/build_id_index.cc

void BuildIDIndex ()

Defined at line 71 of file ../../src/developer/debug/zxdb/symbols/build_id_index.h

void ~BuildIDIndex ()

Defined at line 72 of file ../../src/developer/debug/zxdb/symbols/build_id_index.h

void ClearAll ()

Clears all symbol sources. No symbols can be loaded after this call until Add*() is called.

Defined at line 80 of file ../../src/developer/debug/zxdb/symbols/build_id_index.cc

bool AddOneFile (const std::string & file_name)

Manually inserts a mapping of a build ID to a file name. The file is probed for its build ID

and type, and if not found or not a valid ELF file, it is ignored and we return false.

The added mapping will remain across cache clears.

Defined at line 88 of file ../../src/developer/debug/zxdb/symbols/build_id_index.cc

void AddBuildIDMappingForTest (const std::string & build_id, const std::string & file_name)

Manually inserts a mapping of a build ID to a file name with the given type.

Defined at line 70 of file ../../src/developer/debug/zxdb/symbols/build_id_index.cc

void AddIdsTxt (const std::string & ids_txt, const std::string & build_dir)

Adds an "ids.txt" file that maps build ID to file paths. Will verify that the path is already

there and ignore it if so. An optional build_dir could be supplemented to help look up the

source code.

Defined at line 92 of file ../../src/developer/debug/zxdb/symbols/build_id_index.cc

void AddBuildIdDir (const std::string & dir, const std::string & build_dir)

Adds a GNU-style symbol repository to the search index. The path given should contain files of

the form ab/cdefg.debug, where abcdefg is the build ID. An optional build_dir could be

supplemented to help look up the source code.

Defined at line 104 of file ../../src/developer/debug/zxdb/symbols/build_id_index.cc

std::filesystem::path GetCacheDir ()

Returns the path to the cache directory or an empty path if it's not set.

Defined at line 114 of file ../../src/developer/debug/zxdb/symbols/build_id_index.h

void AddSymbolServer (const std::string & url, bool require_authentication)

Adds a symbol server.

Defined at line 114 of file ../../src/developer/debug/zxdb/symbols/build_id_index.cc

void SetCacheDir (const std::string & cache_dir)

cache_dir saves the downloaded symbol files. Its layout is the same as a build_id_dir but it

also features garbage collection.

Defined at line 127 of file ../../src/developer/debug/zxdb/symbols/build_id_index.cc

void AddSymbolIndexFile (const std::string & path)

Add a symbol-index file that indexes various symbol sources.

Two versions of symbol-index files are supported currently:

- A plain text file separated by newlines and tabs, usually located at

~/.fuchsia/debug/symbol-index.

- A rich JSON format that supports includes, globbing, usually located at

~/.fuchsia/debug/symbol-index.json.

Defined at line 150 of file ../../src/developer/debug/zxdb/symbols/build_id_index.cc

void AddSymbolIndex (const std::string & contents, const std::filesystem::path & relative_to)

Add symbol-index configuration from a JSON string. Paths in the top-level contents

are resolved relative to the provided argument.

Defined at line 133 of file ../../src/developer/debug/zxdb/symbols/build_id_index.cc

const BuildIDMap & build_id_to_files ()

Getters, mainly used in tests.

Defined at line 149 of file ../../src/developer/debug/zxdb/symbols/build_id_index.h

const std::vector<BuildIdDir> & build_id_dirs ()

Defined at line 150 of file ../../src/developer/debug/zxdb/symbols/build_id_index.h

const std::vector<IdsTxt> & ids_txts ()

Defined at line 151 of file ../../src/developer/debug/zxdb/symbols/build_id_index.h

const std::vector<SymbolServer> & symbol_servers ()

Defined at line 152 of file ../../src/developer/debug/zxdb/symbols/build_id_index.h

void AddPlainFileOrDir (const std::string & path)

Adds a file or directory to the symbol search index. If the path is a file this class will try

to parse it as an ELF file and add it to the index if it is. If the path is a directory, all

files in that directory will be indexed.

Will ignore the path if it's already loaded.

Defined at line 156 of file ../../src/developer/debug/zxdb/symbols/build_id_index.cc

StatusList GetStatus ()

Returns the status of the symbols. This will force the cache to be fresh

so may cause I/O.

Defined at line 164 of file ../../src/developer/debug/zxdb/symbols/build_id_index.cc

void ClearCache ()

Clears all cached build IDs. They will be reloaded when required.

Defined at line 169 of file ../../src/developer/debug/zxdb/symbols/build_id_index.cc

int ParseIDs (const std::string & input, const std::filesystem::path & containing_dir, const std::string & build_dir, BuildIDMap * output)

Parses a build ID mapping file (ids.txt). This is separated and public only for testing

purposes. The results are added to the output. Returns the number of items loaded.

Defined at line 172 of file ../../src/developer/debug/zxdb/symbols/build_id_index.cc

Records