Skip to content

Commit

Permalink
use standardized docs directive
Browse files Browse the repository at this point in the history
  • Loading branch information
aviramha committed Jun 3, 2024
1 parent 3dbb044 commit 8479f65
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ jobs:
- name: Build Gum documentation
run: |
cd frida-gum
cargo rustdoc --features "event-sink invocation-listener" -- --cfg doc_cfg
cargo rustdoc --features "event-sink invocation-listener"
check-nostd:
name: Check no_std
runs-on: ubuntu-latest
Expand Down
1 change: 0 additions & 1 deletion frida-gum/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,3 @@ maintenance = { status = "experimental" }

[package.metadata.docs.rs]
features = ["event-sink", "invocation-listener", "stalker-observer", "stalker-params"]
rustdoc-args = ["--cfg", "doc_cfg"]
10 changes: 5 additions & 5 deletions frida-gum/src/interceptor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use core::ffi::c_void;
#[cfg(feature = "invocation-listener")]
mod invocation_listener;
#[cfg(feature = "invocation-listener")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "invocation-listener")))]
#[cfg_attr(docsrs, doc(cfg(feature = "invocation-listener")))]
pub use invocation_listener::*;

/// Function hooking engine interface.
Expand Down Expand Up @@ -47,7 +47,7 @@ impl<'a> Interceptor<'a> {
/// The provided address *must* point to the start of a function in a valid
/// memory region.
#[cfg(feature = "invocation-listener")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "invocation-listener")))]
#[cfg_attr(docsrs, doc(cfg(feature = "invocation-listener")))]
pub fn attach<I: InvocationListener>(
&mut self,
f: NativePointer,
Expand All @@ -66,7 +66,7 @@ impl<'a> Interceptor<'a> {
///
/// The provided address *must* point to a valid instruction.
#[cfg(feature = "invocation-listener")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "invocation-listener")))]
#[cfg_attr(docsrs, doc(cfg(feature = "invocation-listener")))]
pub fn attach_instruction<I: ProbeListener>(
&mut self,
instr: NativePointer,
Expand All @@ -85,7 +85,7 @@ impl<'a> Interceptor<'a> {
///
/// The listener *must* have been attached with [`Interceptor::attach()`].
#[cfg(feature = "invocation-listener")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "invocation-listener")))]
#[cfg_attr(docsrs, doc(cfg(feature = "invocation-listener")))]
pub fn detach(&mut self, listener: NativePointer) {
unsafe {
gum_sys::gum_interceptor_detach(
Expand Down Expand Up @@ -192,7 +192,7 @@ impl<'a> Interceptor<'a> {
///
/// Should only be called from within a hook or replacement function.
#[cfg(feature = "invocation-listener")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "invocation-listener")))]
#[cfg_attr(docsrs, doc(cfg(feature = "invocation-listener")))]
pub fn current_invocation() -> InvocationContext<'a> {
InvocationContext::from_raw(unsafe { gum_sys::gum_interceptor_get_current_invocation() })
}
Expand Down
5 changes: 2 additions & 3 deletions frida-gum/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
)),
no_std
)]
#![cfg_attr(doc_cfg, feature(doc_cfg))]
#![deny(warnings)]
#![allow(clippy::needless_doctest_main)]
#![allow(clippy::missing_safety_doc)]
Expand Down Expand Up @@ -115,10 +114,10 @@ mod debug_symbol;
pub use debug_symbol::*;

#[cfg(feature = "backtrace")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "backtrace")))]
#[cfg_attr(docsrs, doc(cfg(feature = "backtrace")))]
mod backtracer;
#[cfg(feature = "backtrace")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "backtrace")))]
#[cfg_attr(docsrs, doc(cfg(feature = "backtrace")))]
pub use backtracer::*;

#[doc(hidden)]
Expand Down
12 changes: 6 additions & 6 deletions frida-gum/src/stalker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ mod transformer;
pub use transformer::*;

#[cfg(feature = "event-sink")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "event-sink")))]
#[cfg_attr(docsrs, doc(cfg(feature = "event-sink")))]
pub struct NoneEventSink;

#[cfg(feature = "event-sink")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "event-sink")))]
#[cfg_attr(docsrs, doc(cfg(feature = "event-sink")))]
impl EventSink for NoneEventSink {
fn query_mask(&mut self) -> EventMask {
unreachable!()
Expand Down Expand Up @@ -199,7 +199,7 @@ impl<'a> Stalker<'a> {
/// If reusing an existing [`Transformer`], make sure to call [`Stalker::garbage_collect()`]
/// periodically.
#[cfg(feature = "event-sink")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "event-sink")))]
#[cfg_attr(docsrs, doc(cfg(feature = "event-sink")))]
pub fn follow<S: EventSink>(
&mut self,
thread_id: usize,
Expand Down Expand Up @@ -231,7 +231,7 @@ impl<'a> Stalker<'a> {
/// If reusing an existing [`Transformer`], make sure to call [`Stalker::garbage_collect()`]
/// periodically.
#[cfg(feature = "event-sink")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "event-sink")))]
#[cfg_attr(docsrs, doc(cfg(feature = "event-sink")))]
pub fn follow_me<S: EventSink>(
&mut self,
transformer: &Transformer,
Expand All @@ -253,7 +253,7 @@ impl<'a> Stalker<'a> {
/// If reusing an existing [`Transformer`], make sure to call [`Stalker::garbage_collect()`]
/// periodically.
#[cfg(not(feature = "event-sink"))]
#[cfg_attr(doc_cfg, doc(cfg(not(feature = "event-sink"))))]
#[cfg_attr(docsrs, doc(cfg(not(feature = "event-sink"))))]
pub fn follow_me(&mut self, transformer: &Transformer) {
unsafe {
gum_sys::gum_stalker_follow_me(
Expand Down Expand Up @@ -297,7 +297,7 @@ impl<'a> Stalker<'a> {
}

#[cfg(feature = "stalker-observer")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "stalker-observer")))]
#[cfg_attr(docsrs, doc(cfg(feature = "stalker-observer")))]
pub fn set_observer<O: StalkerObserver>(&mut self, observer: &mut O) {
let obs = stalker_observer_transform(observer);
unsafe {
Expand Down
8 changes: 4 additions & 4 deletions frida-gum/src/stalker/event_sink.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use {

#[derive(FromPrimitive)]
#[repr(u32)]
#[cfg_attr(doc_cfg, doc(cfg(feature = "event-sink")))]
#[cfg_attr(docsrs, doc(cfg(feature = "event-sink")))]
pub enum EventMask {
None = gum_sys::_GumEventType_GUM_NOTHING as u32,
Call = gum_sys::_GumEventType_GUM_CALL as u32,
Expand All @@ -26,7 +26,7 @@ pub enum EventMask {
Compile = gum_sys::_GumEventType_GUM_COMPILE as u32,
}

#[cfg_attr(doc_cfg, doc(cfg(feature = "event-sink")))]
#[cfg_attr(docsrs, doc(cfg(feature = "event-sink")))]
#[derive(Debug, Clone, Hash, PartialEq, Eq)]
pub enum Event {
Call {
Expand All @@ -52,7 +52,7 @@ pub enum Event {
},
}

#[cfg_attr(doc_cfg, doc(cfg(feature = "event-sink")))]
#[cfg_attr(docsrs, doc(cfg(feature = "event-sink")))]
impl From<GumEvent> for Event {
fn from(event: GumEvent) -> Event {
match num::FromPrimitive::from_u32(unsafe { event.type_ }).unwrap() {
Expand Down Expand Up @@ -97,7 +97,7 @@ impl From<GumEvent> for Event {
}
}

#[cfg_attr(doc_cfg, doc(cfg(feature = "event-sink")))]
#[cfg_attr(docsrs, doc(cfg(feature = "event-sink")))]
pub trait EventSink {
fn query_mask(&mut self) -> EventMask;
fn start(&mut self);
Expand Down
2 changes: 1 addition & 1 deletion frida-gum/src/stalker/observer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

use {core::ffi::c_void, frida_gum_sys as gum_sys};

#[cfg_attr(doc_cfg, doc(cfg(feature = "stalker-observer")))]
#[cfg_attr(docsrs, doc(cfg(feature = "stalker-observer")))]
pub trait StalkerObserver {
fn notify_backpatch(&mut self, backpatch: *const gum_sys::GumBackpatch, size: gum_sys::gsize);
fn switch_callback(
Expand Down
1 change: 0 additions & 1 deletion frida/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,3 @@ maintenance = { status = "experimental" }

[package.metadata.docs.rs]
features = []
rustdoc-args = ["--cfg", "doc_cfg"]
1 change: 0 additions & 1 deletion frida/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

//! Frida bindings for Rust.
#![cfg_attr(doc_cfg, feature(doc_cfg))]
#![deny(warnings)]
#![deny(missing_docs)]
#![allow(clippy::missing_safety_doc)]
Expand Down

0 comments on commit 8479f65

Please sign in to comment.