#symbol #cache #download #env-var #file #microsoft

symsrv

A Microsoft symsrv symbol server consumer (downloader + cache)

10 unstable releases (4 breaking)

0.5.3 Jul 30, 2024
0.5.2 May 22, 2024
0.5.1 Apr 11, 2024
0.4.0 Feb 28, 2024
0.1.2 May 17, 2022

#146 in Filesystem

Download history 1079/week @ 2024-07-23 1631/week @ 2024-07-30 1371/week @ 2024-08-06 1348/week @ 2024-08-13 1094/week @ 2024-08-20 1371/week @ 2024-08-27 1296/week @ 2024-09-03 1389/week @ 2024-09-10 1353/week @ 2024-09-17 1620/week @ 2024-09-24 1941/week @ 2024-10-01 2578/week @ 2024-10-08 1595/week @ 2024-10-15 2072/week @ 2024-10-22 1431/week @ 2024-10-29 1498/week @ 2024-11-05

7,387 downloads per month
Used in 12 crates (4 directly)

MIT/Apache

93KB
1.5K SLoC

crates.io page docs.rs page

symsrv

This crate lets you download and cache symbol files from symbol servers, according to the rules from the _NT_SYMBOL_PATH environment variable.

It exposes an async API. Internally it uses reqwest and tokio.

The downloaded symbols are stored on the file system. No automatic expiration or eviction is performed. If you want to enforce a cache size limit or expire old files, you can observe cache file creations and accesses with the SymsrvObserver trait, and then write your own implementation for automatic file cleanup.

Microsoft Documentation

Example

use symsrv::SymsrvDownloader;

// Parse the _NT_SYMBOL_PATH environment variable.
let symbol_path_env = symsrv::get_symbol_path_from_environment();
let symbol_path =
  symbol_path_env.as_deref().unwrap_or("srv**https://msdl.microsoft.com/download/symbols");
let parsed_symbol_path = symsrv::parse_nt_symbol_path(symbol_path);

// Create a downloader which follows the _NT_SYMBOL_PATH recipe.
let mut downloader = SymsrvDownloader::new(parsed_symbol_path);
downloader.set_default_downstream_store(symsrv::get_home_sym_dir());

// Download and cache a PDB file.
let local_path = downloader.get_file("dcomp.pdb", "648B8DD0780A4E22FA7FA89B84633C231").await?;

// Use the PDB file.
open_pdb_at_path(&local_path);

Command line tool symfetch

This repository also contains a small example program called symfetch. You can install it as follows:

cargo install --examples symsrv

Run it with symfetch <filename> <hash> - see symfetch --help for details.

License

Licensed under either of

at your option.

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~9–26MB
~334K SLoC