Skip to content

Commit

Permalink
script: Add version info to uftrace_script_info
Browse files Browse the repository at this point in the history
This patch adds script version info to uftrace_script_info and the
script version can be changed when the layout of the script related
struct types are changed.

The script writer has a reponsibility to check the version. The API
version of the script is SCRIPT_API_VERSION and the API version of
uftrace engine is sc_info->api_version.

Signed-off-by: Honggyu Kim <[email protected]>
  • Loading branch information
honggyukim committed Feb 20, 2023
1 parent a154c99 commit 58bcbca
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions cmds/script.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ int command_script(int argc, char *argv[], struct uftrace_opts *opts)
struct uftrace_data handle;
struct uftrace_task_reader *task;
struct uftrace_script_info info = {
.api_version = SCRIPT_API_VERSION,
.name = opts->script_file,
.version = UFTRACE_VERSION,
};
Expand Down
3 changes: 3 additions & 0 deletions include/uftrace/script.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@
#include <stdbool.h>
#include <stdint.h>

#define SCRIPT_API_VERSION 1

/* informantion passed during initialization */
struct uftrace_script_info {
int api_version;
char *name;
char *version;
bool record;
Expand Down
1 change: 1 addition & 0 deletions libmcount/mcount.c
Original file line number Diff line number Diff line change
Expand Up @@ -1742,6 +1742,7 @@ static void atfork_child_handler(void)
static void mcount_script_init(enum uftrace_pattern_type patt_type)
{
struct uftrace_script_info info = {
.api_version = SCRIPT_API_VERSION,
.name = script_str,
.version = UFTRACE_VERSION,
.record = true,
Expand Down

0 comments on commit 58bcbca

Please sign in to comment.