Skip to content

Commit

Permalink
docs updated for repl concepts section
Browse files Browse the repository at this point in the history
  • Loading branch information
psifertex committed Dec 1, 2023
1 parent f1d9742 commit 5770259
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions docs/dev/concepts.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ print("test")

and then checking the `Log` pane where you will see an `Analysis update took #.###` message. This is a convenience the UI does for you just like if you were to change a type or create a function, you almost always want the analysis to be updated. However, in scripts you run yourself as plugins or via the "Run Script" command, you may not get the same results mid-execution until after the entire script is finished running.

To achieve the same results when writing a stand-alone plugin, you'd need to use [`current_function.reanalyze()`](https://api.binary.ninja/binaryninja.function-module.html#binaryninja.function.Function.reanalyze), [`bv.update_analysis_and_wait()`](https://api.binary.ninja/binaryninja.binaryview-module.html#binaryninja.binaryview.BinaryView.update_analysis_and_wait), or similar methods.

Another difference in the REPL / scripting console is that the scripting console is not executing on the main thread. This means that if you wish to interact with the UI via QT or BN UI APIs from the console (for example, to [trigger an action via string](https://gist.github.com/psifertex/6fbc7532f536775194edd26290892ef7#file-trigger_actions-py)), you'd need to use [`mainthread.execute_on_main_thread_and_wait()`](https://api.binary.ninja/binaryninja.mainthread-module.html#binaryninja.mainthread.execute_on_main_thread_and_wait) or similar.

![Scriping Console ><](../img/console.png "Python Scripting Console")

## Operating on IL versus Native
Expand Down
2 changes: 1 addition & 1 deletion docs/guide/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -673,7 +673,7 @@ From here, you can add any custom functions or objects you want to be available
#### "Run Script..."

???+ Danger "Warning"
When you run commands in the scripting console, the UI will automatically update analysis. This is because quite often when you make a change in the console you expect it to be immediately reflected in the UI. The same is not true when running a script where you must trigger `bv.update_analysis_and_wait()` or `current_function.reanalze()` to experience the same behavior.
When you run commands in the scripting console, the UI will automatically update analysis. This is because quite often when you make a change in the console you expect it to be immediately reflected in the UI. The same is not true when running a script where you must trigger `bv.update_analysis_and_wait()` or `current_function.reanalyze()` to experience the same behavior.

The "Run Script..." option in the File Menu allows loading a python script from your filesystem and executing it
within the console. It can also be run via the Command Palette or bound to a key.
Expand Down
2 changes: 1 addition & 1 deletion python/function.py
Original file line number Diff line number Diff line change
Expand Up @@ -2734,7 +2734,7 @@ def set_int_display_type(

def reanalyze(self, update_type: FunctionUpdateType = FunctionUpdateType.UserFunctionUpdate) -> None:
"""
``reanalyze`` causes this functions to be reanalyzed. This function does not wait for the analysis to finish.
``reanalyze`` causes this function to be reanalyzed. This function does not wait for the analysis to finish.
:param enums.FunctionUpdateType update_type: (optional) Desired update type
Expand Down

0 comments on commit 5770259

Please sign in to comment.