summaryrefslogtreecommitdiff
path: root/utils/mcpu-run-options.h
blob: e809e5d02d3c58bf07f3c61ff6a33a36aa9d69b1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#ifndef __MCPU_RUN_OPTIONS_H__
#define __MCPU_RUN_OPTIONS_H__ 1

#include <stddef.h>

#include <libmcpu.h>

#include "mcpu-tool-options.h"

typedef enum __print_kind
{
  PRINT_NONE = 0,
  PRINT_INTEGER_REGISTER,
  PRINT_REAL_REGISTER,
  PRINT_INTEGER_MEMORY,
  PRINT_REAL_MEMORY,
  PRINT_RAW_MEMORY
} print_kind;

typedef enum __memory_kind
{
  MEMORY_NONE = 0,
  MEMORY_DATA,
  MEMORY_CONTROL,
  MEMORY_HEAP,
  MEMORY_INPUT,
  MEMORY_OUTPUT,
  MEMORY_TRACE
} memory_kind;

typedef struct __print_spec
{
  print_kind       kind;
  memory_kind      memory;
  unsigned int     bits;
  __mpu_uint64_t   address;
  __mpu_uint64_t   count;
} print_spec;

typedef enum __action_kind
{
  ACTION_NONE = 0,
  ACTION_PRINT_INTEGER_REGISTER,
  ACTION_PRINT_REAL_REGISTER,
  ACTION_SET_INTEGER_REGISTER,
  ACTION_SET_REAL_REGISTER,
  ACTION_PRINT_INTEGER_MEMORY,
  ACTION_PRINT_REAL_MEMORY,
  ACTION_SET_INTEGER_MEMORY,
  ACTION_SET_REAL_MEMORY,
  ACTION_PRINT_RAW_MEMORY
} action_kind;

typedef struct __action_item
{
  unsigned int     bits;
  __mpu_uint64_t   address;
  char            *value;
} action_item;

typedef struct __stage_action
{
  action_kind      kind;
  memory_kind      memory;
  action_item     *item;
  size_t           count;
  print_spec       raw;
} stage_action;

typedef struct __stage_action_list
{
  stage_action    *action;
  size_t           count;
  size_t           capacity;
} stage_action_list;

typedef struct mcpu_run_options mcpu_run_options;
struct mcpu_run_options
{
  mcpu_tool_options common;
  print_spec        output;
  stage_action_list before_run;
  stage_action_list after_init;
  stage_action_list on_step;
  stage_action_list after_run;
  unsigned int      digits;
  __mpu_uint64_t    steps;
  int               steps_set;
  int               init_only;
  const char       *exe;
  const char       *env_ldpreload;
  const char       *ldpreload;
  int               program_argc;
  char            **program_argv;
};

void mcpu_run_options_init( mcpu_run_options *options, const char *progname );
void mcpu_run_options_free( mcpu_run_options *options );
int  mcpu_run_handle_options( mcpu_run_options *options,
                              int argc, char **argv );
void mcpu_run_usage( const mcpu_run_options *options );
int  mcpu_run_resolve_preload( const mcpu_run_options *options,
                               char **resolved, char *err, size_t errsz );

#endif /* __MCPU_RUN_OPTIONS_H__ */