From 719b91d18a3869b2a8ed44f904fc50f952dfa18f Mon Sep 17 00:00:00 2001 From: Jordan Wiens Date: Tue, 28 Feb 2023 16:29:51 -0500 Subject: another example on applying a type to memory where none exists --- docs/guide/type.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'docs/guide') diff --git a/docs/guide/type.md b/docs/guide/type.md index 1ad59dfa..090e7196 100644 --- a/docs/guide/type.md +++ b/docs/guide/type.md @@ -604,6 +604,19 @@ current_function.parameter_vars[0].type = Type.pointer(bv.arch, Type.char()) >>> bv.get_data_var_at(here).type = Type.char() ``` +#### Applying a type where non exists yet + +In some instances you may need to first create a `DataVariable` before you can set the type at a given location: + +```python +>>> bv.get_data_var_at(here) +# Nothing there yet! +>>> bv.define_user_data_var(here, "char*") + +``` + +Note that most of the APIs that take a Type object also take a C-style type string as a convenience helper as demonstrated as a difference between the last two examples. + ### Headers Importing a header goes through the same code path as parsing source directly. You will just have to read the file and specify the appropriate command-line arguments as an array. See [above](#import-header-file) for directions for choosing arguments. -- cgit v1.3.1