Skip to content

Commit d0207a4

Browse files
committed
Add internal dockerfile major version switch and option to disable symbolic system-wide coverage for user-provided only
1 parent da469d6 commit d0207a4

File tree

12 files changed

+176
-50
lines changed

12 files changed

+176
-50
lines changed

.github/builder/Dockerfile-internal renamed to .github/builder/Dockerfile-internal-6

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ COPY .github/builder/rsrc/lld-5.0.2.src.tar.xz /install/lld-5.0.2.src.tar.xz
1212
COPY .github/builder/rsrc/cfe-5.0.2.src.tar.xz /install/cfe-5.0.2.src.tar.xz
1313
COPY .github/builder/rsrc/llvm-5.0.2.src.tar.xz /install/llvm-5.0.2.src.tar.xz
1414
COPY .github/builder/rsrc/rpms /install/rpms
15-
COPY .github/builder/rsrc/simics /simics
15+
COPY .github/builder/rsrc/simics-6 /simics
1616
COPY .github/builder/rsrc/ispm /simics/ispm
1717

1818
RUN yum -y install /install/rpms/*.rpm && yum clean all
@@ -58,7 +58,7 @@ RUN ispm settings install-dir /simics && \
5858
RUN RUSTFLAGS="-C linker=clang -C link-arg=-fuse-ld=$(which ld.lld)" && \
5959
export RUSTFLAGS && \
6060
cargo install cargo-simics-build && \
61-
SIMICS_PACKAGE_VERSION="$(ispm packages --list | grep 1000 | awk '{print $3}' | cut -d '.' -f1).$(grep -E '^version = ' < Cargo.toml | sed -n '$p' | grep -oE '\"[^\"]+\"' | tr -d '\"' | cut -d'.' -f2-)" && \
61+
SIMICS_PACKAGE_VERSION="$(ispm packages --list-installed | grep 1000 | awk '{print $3}' | cut -d '.' -f1).$(grep -E '^version = ' < Cargo.toml | sed -n '$p' | grep -oE '\"[^\"]+\"' | tr -d '\"' | cut -d'.' -f2-)" && \
6262
export SIMICS_PACKAGE_VERSION && \
6363
cargo simics-build -r && \
6464
mkdir -p /packages-internal && \
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# hadolint global ignore=DL3033,SC3044
2+
FROM fedora:20
3+
4+
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
5+
6+
ENV PATH="${PATH}:/root/.cargo/bin/"
7+
8+
COPY .github/builder/rsrc/rust-nightly-x86_64-unknown-linux-gnu.tar.xz /install/rust-nightly-x86_64-unknown-linux-gnu.tar.xz
9+
COPY .github/builder/rsrc/make-4.4.1.tar.gz /install/make-4.4.1.tar.gz
10+
COPY .github/builder/rsrc/cmake-3.29.3-linux-x86_64.tar.gz /install/cmake-3.29.3-linux-x86_64.tar.gz
11+
COPY .github/builder/rsrc/lld-5.0.2.src.tar.xz /install/lld-5.0.2.src.tar.xz
12+
COPY .github/builder/rsrc/cfe-5.0.2.src.tar.xz /install/cfe-5.0.2.src.tar.xz
13+
COPY .github/builder/rsrc/llvm-5.0.2.src.tar.xz /install/llvm-5.0.2.src.tar.xz
14+
COPY .github/builder/rsrc/rpms /install/rpms
15+
COPY .github/builder/rsrc/simics-7 /simics
16+
COPY .github/builder/rsrc/ispm /simics/ispm
17+
18+
RUN yum -y install /install/rpms/*.rpm && yum clean all
19+
20+
RUN tar -C /install -xvf /install/rust-nightly-x86_64-unknown-linux-gnu.tar.xz && \
21+
/install/rust-nightly-x86_64-unknown-linux-gnu/install.sh && \
22+
mkdir -p /make && \
23+
tar -C /make --strip-components=1 -xf /install/make-4.4.1.tar.gz && \
24+
pushd /make && \
25+
./configure && \
26+
make && \
27+
make install && \
28+
make clean && \
29+
popd && \
30+
tar -C /usr/local/ --strip-components=1 -xf /install/cmake-3.29.3-linux-x86_64.tar.gz && \
31+
mkdir -p /llvm/tools/clang && \
32+
mkdir -p /llvm/tools/lld && \
33+
tar -C /llvm --strip-components=1 -xf /install/llvm-5.0.2.src.tar.xz && \
34+
tar -C /llvm/tools/clang --strip-components=1 -xf /install/cfe-5.0.2.src.tar.xz && \
35+
tar -C /llvm/tools/lld --strip-components=1 -xf /install/lld-5.0.2.src.tar.xz && \
36+
mkdir -p /llvm/build && \
37+
pushd /llvm/build && \
38+
cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE="MinSizeRel" -DLLVM_TARGETS_TO_BUILD="X86" .. && \
39+
make -j "$(nproc)" && \
40+
make install && \
41+
make clean && \
42+
rm -rf /llvm/build/ && \
43+
popd && \
44+
rm -rf /make /llvm
45+
46+
WORKDIR /
47+
48+
ENV PATH="${PATH}:/simics/ispm/"
49+
ENV PATH="${PATH}:/root/.cargo/bin/"
50+
51+
COPY . /tsffs/
52+
53+
WORKDIR /tsffs/
54+
55+
RUN ispm settings install-dir /simics && \
56+
ispm packages --list
57+
58+
RUN RUSTFLAGS="-C linker=clang -C link-arg=-fuse-ld=$(which ld.lld)" && \
59+
export RUSTFLAGS && \
60+
cargo install cargo-simics-build && \
61+
SIMICS_PACKAGE_VERSION="$(ispm packages --list-installed | grep 1000 | awk '{print $3}' | cut -d '.' -f1).$(grep -E '^version = ' < Cargo.toml | sed -n '$p' | grep -oE '\"[^\"]+\"' | tr -d '\"' | cut -d'.' -f2-)" && \
62+
export SIMICS_PACKAGE_VERSION && \
63+
cargo simics-build -r && \
64+
mkdir -p /packages-internal && \
65+
cp target/release/*.ispm /packages-internal

.github/builder/common.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/bin/bash
22

3-
# NOTE: Do not just copy-paste scripts/build.sh!
3+
# NOTE: The `use-keyboxd` option in ~/.gnupg/common.conf should be disabled for this script's GPG routines to
4+
# work correctly!
45

56
set -e
67

@@ -233,4 +234,4 @@ download_and_verify_builder_deps() {
233234
download_and_verify_cmake
234235
download_and_verify_simics
235236
download_and_verify_builder_rpms
236-
}
237+
}

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ version = "0.2.2"
2121

2222
[package.metadata.simics]
2323
package-number = 31337
24-
version = "6.1.4"
24+
version = "6.1.5"
2525

2626
[lib]
2727
crate-type = ["cdylib", "rlib"]

scripts/build-internal.sh

Lines changed: 41 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@
1111

1212
set -e
1313

14+
MAJOR_VERSION="${1}"
15+
16+
if [ -z "${MAJOR_VERSION}" ]; then
17+
MAJOR_VERSION="7"
18+
fi
19+
1420
SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)
1521
ROOT_DIR="${SCRIPT_DIR}/../"
1622
BUILDER_DIR="${ROOT_DIR}/.github/builder/"
@@ -31,32 +37,47 @@ if [ ! -d "${BUILDER_DIR}/rsrc/ispm" ]; then
3137
cp -a "${ISPM_DIR}" "${BUILDER_DIR}/rsrc/ispm"
3238
fi
3339

34-
if [ ! -d "${BUILDER_DIR}/rsrc/simics" ]; then
35-
echo "Simics packages not found. Installing..."
36-
mkdir -p "${BUILDER_DIR}/rsrc/simics"
37-
ispm packages --install-dir "${BUILDER_DIR}/rsrc/simics" -i \
38-
1000-latest \
39-
1020-latest \
40-
1030-latest \
41-
1031-latest \
42-
2050-latest \
43-
2053-latest \
44-
2096-latest \
45-
4094-latest \
46-
6010-latest \
47-
7801-latest \
48-
8112-latest \
49-
8126-latest \
50-
8144-latest \
40+
install_major_version() {
41+
WANTED_MAJOR_VERSION="${1}"
42+
ispm packages --install-dir "${BUILDER_DIR}/rsrc/simics-${WANTED_MAJOR_VERSION}" -i \
43+
"1000-${WANTED_MAJOR_VERSION}.latest" \
44+
"1020-${WANTED_MAJOR_VERSION}.latest" \
45+
"1030-${WANTED_MAJOR_VERSION}.latest" \
46+
"1031-${WANTED_MAJOR_VERSION}.latest" \
47+
"2050-${WANTED_MAJOR_VERSION}.latest" \
48+
"2053-${WANTED_MAJOR_VERSION}.latest" \
49+
"2096-${WANTED_MAJOR_VERSION}.latest" \
50+
"4094-${WANTED_MAJOR_VERSION}.latest" \
51+
"6010-${WANTED_MAJOR_VERSION}.latest" \
52+
"7801-${WANTED_MAJOR_VERSION}.latest" \
53+
"8112-${WANTED_MAJOR_VERSION}.latest" \
54+
"8126-${WANTED_MAJOR_VERSION}.latest" \
55+
"8144-${WANTED_MAJOR_VERSION}.latest" \
5156
--non-interactive
52-
fi
57+
}
5358

5459
download_and_verify_builder_deps
5560

61+
if [ "${MAJOR_VERSION}" -eq "7" ]; then
62+
DOCKERFILE="${BUILDER_DIR}/Dockerfile-internal-7"
63+
if [ ! -d "${BUILDER_DIR}/rsrc/simics-7" ]; then
64+
echo "Simics 7 packages not found. Installing..."
65+
install_major_version 7
66+
fi
67+
fi
68+
69+
if [ "${MAJOR_VERSION}" -eq "6" ]; then
70+
DOCKERFILE="${BUILDER_DIR}/Dockerfile-internal-6"
71+
if [ ! -d "${BUILDER_DIR}/rsrc/simics-6" ]; then
72+
echo "Simics 6 packages not found. Installing..."
73+
install_major_version 6
74+
fi
75+
fi
76+
5677
unset SIMICS_BASE
5778
docker build \
58-
-t "${IMAGE_NAME}" -f "${BUILDER_DIR}/Dockerfile-internal" "${ROOT_DIR}"
79+
-t "${IMAGE_NAME}" -f "${DOCKERFILE}" "${ROOT_DIR}"
5980
docker create --name "${CONTAINER_NAME}" "${IMAGE_NAME}" bash
6081
mkdir -p "${ROOT_DIR}/packages-internal"
6182
docker cp "${CONTAINER_NAME}:/packages-internal" "${ROOT_DIR}/"
62-
docker rm -f "${CONTAINER_NAME}"
83+
docker rm -f "${CONTAINER_NAME}"

src/haps/mod.rs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use std::time::SystemTime;
88
use crate::{
99
arch::ArchitectureOperations,
1010
magic::MagicNumber,
11+
os::DebugInfoConfig,
1112
state::{SolutionKind, StopReason},
1213
ManualStartInfo, Tsffs,
1314
};
@@ -62,7 +63,10 @@ impl Tsffs {
6263
start_processor_raw,
6364
&self.debuginfo_download_directory,
6465
self.guess_pdb_function_size,
65-
&self.debug_info,
66+
DebugInfoConfig {
67+
system: self.symbolic_coverage_system,
68+
user_debug_info: &self.debug_info,
69+
},
6670
)?;
6771
}
6872
self.get_and_write_testcase()?;
@@ -222,7 +226,10 @@ impl Tsffs {
222226
processor,
223227
&self.debuginfo_download_directory,
224228
self.guess_pdb_function_size,
225-
&self.debug_info,
229+
DebugInfoConfig {
230+
system: self.symbolic_coverage_system,
231+
user_debug_info: &self.debug_info,
232+
},
226233
)?;
227234
}
228235

@@ -265,7 +272,10 @@ impl Tsffs {
265272
processor,
266273
&self.debuginfo_download_directory,
267274
self.guess_pdb_function_size,
268-
&self.debug_info,
275+
DebugInfoConfig {
276+
system: self.symbolic_coverage_system,
277+
user_debug_info: &self.debug_info,
278+
},
269279
)?;
270280
}
271281

src/lib.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,14 @@ pub(crate) struct Tsffs {
415415
/// to a tuple of (exe path, debuginfo path) where debuginfo is either a PDB or DWARF
416416
/// file
417417
pub debug_info: HashMap<String, Vec<PathBuf>>,
418+
#[class(attribute(optional, default = lookup_file("%simics%")?.join("debuginfo-source")))]
419+
/// Directory in which source files are located. Source files do not need to be arranged in
420+
/// the same directory structure as the compiled source, and are looked up by hash.
421+
pub debuginfo_source_directory: PathBuf,
422+
#[class(attribute(optional, default = false))]
423+
/// Whether symbolic coverage should be collected for system components by downloading
424+
/// executable and debug info files where possible.
425+
pub symbolic_coverage_system: bool,
418426

419427
/// Handle for the core simulation stopped hap
420428
stop_hap_handle: HapHandle,

src/os/mod.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
11
#![allow(unused)]
22

3+
use std::{collections::HashMap, path::PathBuf};
4+
35
pub mod windows;
6+
7+
#[derive(Debug, Clone)]
8+
pub struct DebugInfoConfig<'a> {
9+
pub system: bool,
10+
pub user_debug_info: &'a HashMap<String, Vec<PathBuf>>,
11+
}

src/os/windows/debug_info.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ use windows::Win32::System::{
2020
SystemServices::IMAGE_DOS_HEADER,
2121
};
2222

23+
use crate::os::DebugInfoConfig;
24+
2325
use super::{
2426
pdb::{CvInfoPdb70, Export},
2527
util::{read_virtual, read_virtual_dtb},
@@ -40,12 +42,12 @@ impl<'a> DebugInfo<'a> {
4042
base: u64,
4143
download_directory: P,
4244
not_found_full_name_cache: &mut HashSet<String>,
43-
user_debug_info: &HashMap<String, Vec<PathBuf>>,
45+
user_debug_info: DebugInfoConfig,
4446
) -> Result<Self>
4547
where
4648
P: AsRef<Path>,
4749
{
48-
if let Some(info) = user_debug_info.get(name) {
50+
if let Some(info) = user_debug_info.user_debug_info.get(name) {
4951
debug!(
5052
get_object("tsffs")?,
5153
"Have user-provided debug info for {name}"
@@ -177,12 +179,12 @@ impl<'a> DebugInfo<'a> {
177179
download_directory: P,
178180
directory_table_base: u64,
179181
not_found_full_name_cache: &mut HashSet<String>,
180-
user_debug_info: &HashMap<String, Vec<PathBuf>>,
182+
user_debug_info: DebugInfoConfig,
181183
) -> Result<Self>
182184
where
183185
P: AsRef<Path>,
184186
{
185-
if let Some(info) = user_debug_info.get(name) {
187+
if let Some(info) = user_debug_info.user_debug_info.get(name) {
186188
debug!(
187189
get_object("tsffs")?,
188190
"Have user-provided debug info for {name}"

src/os/windows/kernel.rs

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,13 @@ use windows::Win32::System::{
1515
},
1616
};
1717

18-
use crate::os::windows::{
19-
debug_info::DebugInfo,
20-
idt::IdtEntry64,
21-
util::{read_nul_terminated_string, read_unicode_string, read_virtual},
18+
use crate::os::{
19+
windows::{
20+
debug_info::DebugInfo,
21+
idt::IdtEntry64,
22+
util::{read_nul_terminated_string, read_unicode_string, read_virtual},
23+
},
24+
DebugInfoConfig,
2225
};
2326

2427
use super::{
@@ -181,7 +184,7 @@ impl KernelInfo {
181184
base: u64,
182185
download_directory: P,
183186
not_found_full_name_cache: &mut HashSet<String>,
184-
user_debug_info: &HashMap<String, Vec<PathBuf>>,
187+
user_debug_info: DebugInfoConfig,
185188
) -> Result<Self>
186189
where
187190
P: AsRef<Path>,
@@ -258,7 +261,7 @@ impl KernelInfo {
258261
processor: *mut ConfObject,
259262
download_directory: P,
260263
not_found_full_name_cache: &mut HashSet<String>,
261-
user_debug_info: &HashMap<String, Vec<PathBuf>>,
264+
user_debug_info: DebugInfoConfig,
262265
) -> Result<Vec<Module>>
263266
where
264267
P: AsRef<Path>,
@@ -313,7 +316,7 @@ impl KernelInfo {
313316
base,
314317
download_directory.as_ref(),
315318
not_found_full_name_cache,
316-
user_debug_info,
319+
user_debug_info.clone(),
317320
)
318321
})
319322
.ok();
@@ -382,7 +385,7 @@ impl KernelInfo {
382385
processor: *mut ConfObject,
383386
download_directory: P,
384387
not_found_full_name_cache: &mut HashSet<String>,
385-
user_debug_info: &HashMap<String, Vec<PathBuf>>,
388+
user_debug_info: DebugInfoConfig,
386389
) -> Result<Process>
387390
where
388391
P: AsRef<Path>,
@@ -427,7 +430,7 @@ impl KernelInfo {
427430
processor: *mut ConfObject,
428431
download_directory: P,
429432
not_found_full_name_cache: &mut HashSet<String>,
430-
user_debug_info: &HashMap<String, Vec<PathBuf>>,
433+
user_debug_info: DebugInfoConfig,
431434
) -> Result<Vec<Process>>
432435
where
433436
P: AsRef<Path>,
@@ -477,7 +480,7 @@ impl KernelInfo {
477480
self.build,
478481
download_directory.as_ref(),
479482
not_found_full_name_cache,
480-
user_debug_info,
483+
user_debug_info.clone(),
481484
)
482485
.unwrap_or_default(),
483486
});

0 commit comments

Comments
 (0)