Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[mc] Access memory from another process
[simgrid.git] / src / mc / mc_process.h
1 /* Copyright (c) 2008-2014. The SimGrid Team.
2  * All rights reserved.                                                     */
3
4 /* This program is free software; you can redistribute it and/or modify it
5  * under the terms of the license (GNU LGPL) which comes with this package. */
6
7 #ifndef MC_PROCESS_H
8 #define MC_PROCESS_H
9
10 #include <stdbool.h>
11
12 #include "simgrid_config.h"
13
14 #include <sys/types.h>
15
16 #include "mc_forward.h"
17 #include "mc_memory_map.h"
18
19 SG_BEGIN_DECL()
20
21 typedef enum {
22   MC_PROCESS_NO_FLAG = 0,
23   MC_PROCESS_SELF_FLAG = 1,
24 } e_mc_process_flags_t;
25
26 /** Representation of a process
27  */
28 struct s_mc_process {
29   e_mc_process_flags_t process_flags;
30   pid_t pid;
31   memory_map_t memory_map;
32   void *maestro_stack_start, *maestro_stack_end;
33   mc_object_info_t libsimgrid_info;
34   mc_object_info_t binary_info;
35   mc_object_info_t* object_infos;
36   size_t object_infos_size;
37   int memory_file;
38 };
39
40 void MC_process_init(mc_process_t process, pid_t pid);
41 void MC_process_clear(mc_process_t process);
42
43 static inline
44 bool MC_process_is_self(mc_process_t process)
45 {
46   return process->process_flags & MC_PROCESS_SELF_FLAG;
47 }
48
49 /* Process memory access: */
50
51 /** Read data from a process memory
52  *
53  *  @param process the process
54  *  @param local   local memory address (destination)
55  *  @param remote  target process memory address (source)
56  *  @param len     data size
57  */
58 void MC_process_read(mc_process_t process, void* local, const void* remote, size_t len);
59
60 /** Write data to a process memory
61  *
62  *  @param process the process
63  *  @param local   local memory address (source)
64  *  @param remote  target process memory address (target)
65  *  @param len     data size
66  */
67 void MC_process_write(mc_process_t process, const void* local, void* remote, size_t len);
68
69 /* Functions, variables of the process: */
70
71 mc_object_info_t MC_process_find_object_info(mc_process_t process, void* ip);
72 dw_frame_t MC_process_find_function(mc_process_t process, void* ip);
73
74 SG_END_DECL()
75
76 #endif