Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Write Rust Bindings #152

Draft
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

YangLiuWillow
Copy link

#125 Work in progress.
I created a new directory libcachesim-rs that looks like:

-- libcachesim-rs
     -- bindings
         -- bindings.rs
         -- libwrap_static_fns.a
         -- wrap_static_fns.c
         -- wrap_static_fns.o
     -- src
         -- lib.rs
         -- main.rs
         -- wrapper.rs
     -- build.rs
     -- cargo.toml

In the libcachesim-rs directory, if we run cargo build, the build.rs script will generate the bindings directory and all the files inside this directory. Then we can include the bindings.rs to our lib.rs and write safe Rust wrappers in wrapper.rs. For now, I have pub struct Cache, pub struct Reader, and pub struct Request with all corresponding methods. With these, I write a Rust equivalent test.c file in main.rs.

More Rust wrappers to come.

@1a1a11a
Copy link
Owner

1a1a11a commented Mar 24, 2025

Awesome! Please let me know if you need me to take a look.

@YangLiuWillow
Copy link
Author

I have some questions when testing things out.

How should I create a VSCSI file? I've been trying to run test.c but I can't seem to figure out how to create a VSCSI file other than copy paste the existing ones in data directory and rename them :O.
When I run ./test.out, it gives me this error

[WARN]  03-23-2025 19:34:11    csv.c:61   (tid=8633382976): in_buf_size 1024 is smaller than the first line size 18446744073709551615, the first line will be truncatedAssertion failed: (buf_size < 1024), function csv_detect_header, file csv.c, line 125.
zsh: abort      ../test.out

When running cargo run for main.rs, I get the same error

[WARN]  03-23-2025 19:56:08    csv.c:61   (tid=8633382976): in_buf_size 1024 is smaller than the first line size 18446744073709551615, the first line will be truncatedAssertion failed: (buf_size < 1024), function csv_detect_header, file csv.c, line 125.
zsh: abort      cargo run

I guess I am not as familiar with the code base, but I cannot seem to figure out why for now.

@1a1a11a
Copy link
Owner

1a1a11a commented Mar 24, 2025

We can use csv and oracleGeneral trace formats for testing. The test.c might be outdated.
Take a look at https://github.com/1a1a11a/libCacheSim/tree/develop/libCacheSim/bin/cachesim
and https://github.com/1a1a11a/libCacheSim/blob/develop/doc/quickstart_cachesim.md#use-different-trace-types

csv traces are easy to generate, to generate oracleGeneral trace, you can use traceConv tool

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants