Skip to content

Commit

Permalink
Add documentatoin to document the --preamble argument
Browse files Browse the repository at this point in the history
Signed-off-by: Ramzi El-khater <ramzie@meta.com>
  • Loading branch information
ramzie80 committed Aug 24, 2022
1 parent e34fbb0 commit b526b38
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,14 @@ You can mark all fakes with the weak attribute like so:
See the example project that demonstrates the above approach: _./examples/weak_linking_.
## Specifying a preamble in the mock funtion name
You can make fff add a preamble to the mock function names by passing the argument --preamble <string> to fakegen.rb when generating fff.h. This is useful if one needs to build with the real function included for whatever reason. Note that references to the real function will need to change to refer to the mock function.
For example, we can name the mock of function foo() as __wrap_foo() and use the GNU linker option -Wl,--wrap foo to re-route all references to foo() to __wrap_foo() (see https://ftp.gnu.org/old-gnu/Manuals/ld-2.9.1/html_node/ld_3.html). Now, inside __wrap_foo() we can invoke foo() in addition to instrumentation. We can leverage the 'foo_fake.custom_fake' field to call the real version of foo(), this will now be named as
__real_foo()
## Find Out More
Look under the examples directory for full length examples in both C and C++.
Expand Down

0 comments on commit b526b38

Please sign in to comment.