-/* Copyright (c) 2007-2013. The SimGrid Team.
+/* Copyright (c) 2007-2014. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
#include "xbt/parmap.h"
typedef struct s_dw_frame s_dw_frame_t, *dw_frame_t;
+typedef struct s_mc_function_index_item s_mc_function_index_item_t, *mc_function_index_item_t;
/****************************** Snapshots ***********************************/
int SIMIX_pre_mc_compare_snapshots(smx_simcall_t simcall, mc_snapshot_t s1, mc_snapshot_t s2);
void print_comparison_times(void);
-#define MC_DEBUG 1
+//#define MC_DEBUG 1
#define MC_VERBOSE 1
/********************************** DPOR for safety property **************************************/
/********************************** Variables with DWARF **********************************/
+#define MC_OBJECT_INFO_EXECUTABLE 1
+
struct s_mc_object_info {
+ size_t flags;
char* file_name;
char *start_exec, *end_exec; // Executable segment
char *start_rw, *end_rw; // Read-write segment
char *start_ro, *end_ro; // read-only segment
- xbt_dict_t local_variables; // xbt_dict_t<frame_name, dw_frame_t>
+ xbt_dynar_t subprograms; // xbt_dynar_t<dw_frame_t>
xbt_dynar_t global_variables; // xbt_dynar_t<dw_variable_t>
xbt_dict_t types; // xbt_dict_t<origin as hexadecimal string, dw_type_t>
xbt_dict_t types_by_name; // xbt_dict_t<name, dw_type_t> (full defined type only)
+
+ // Here we sort the minimal information for an efficient (and cache-efficient)
+ // lookup of a function given an instruction pointer.
+ // The entries are sorted by low_pc and a binary search can be used to look them up.
+ xbt_dynar_t functions_index;
};
mc_object_info_t MC_new_object_info(void);
-mc_object_info_t MC_find_object_info(memory_map_t maps, char* name);
+mc_object_info_t MC_find_object_info(memory_map_t maps, char* name, int executable);
void MC_free_object_info(mc_object_info_t* p);
void MC_dwarf_get_variables(mc_object_info_t info);
const char* MC_dwarf_attrname(int attr);
const char* MC_dwarf_tagname(int tag);
+dw_frame_t MC_find_function_by_ip(void* ip);
+mc_object_info_t MC_ip_find_object_info(void* ip);
+
extern mc_object_info_t mc_libsimgrid_info;
extern mc_object_info_t mc_binary_info;
+void MC_find_object_address(memory_map_t maps, mc_object_info_t result);
+void MC_post_process_types(mc_object_info_t info);
+
+// ***** Expressions
+
+/** \brief a DWARF expression with optional validity contraints */
+typedef struct s_mc_expression {
+ size_t size;
+ Dwarf_Op* ops;
+ // Optional validity:
+ void* lowpc, *highpc;
+} s_mc_expression_t, *mc_expression_t;
+
+/** A location list (list of location expressions) */
+typedef struct s_mc_location_list {
+ size_t size;
+ mc_expression_t locations;
+} s_mc_location_list_t, *mc_location_list_t;
+
+Dwarf_Off mc_dwarf_resolve_location(mc_expression_t expression, unw_cursor_t* c, void* frame_pointer_address);
+Dwarf_Off mc_dwarf_resolve_locations(mc_location_list_t locations, unw_cursor_t* c, void* frame_pointer_address);
+
+void mc_dwarf_location_list_clear(mc_location_list_t list);
+
+void mc_dwarf_location_list_init_from_expression(mc_location_list_t target, size_t len, Dwarf_Op* ops);
+void mc_dwarf_location_list_init(mc_location_list_t target, mc_object_info_t info, Dwarf_Die* die, Dwarf_Attribute* attr);
+
+// ***** Deprecated locations:
+
typedef enum {
e_dw_loclist,
e_dw_register,
}s_dw_location_t, *dw_location_t;
typedef struct s_dw_location_entry{
- long lowpc;
- long highpc;
+ void* lowpc;
+ void* highpc;
dw_location_t location;
}s_dw_location_entry_t, *dw_location_entry_t;
+// ***** Variables and functions
+
typedef struct s_dw_variable{
Dwarf_Off dwarf_offset; /* Global offset of the field. */
int global;
char *name;
char *type_origin;
+ dw_type_t type;
// Use either of:
- dw_location_t location;
+ s_mc_location_list_t locations;
void* address;
+ size_t start_scope;
+
}s_dw_variable_t, *dw_variable_t;
struct s_dw_frame{
unsigned long int end; /* Dwarf offset of the next sibling */
};
+struct s_mc_function_index_item {
+ void* low_pc, *high_pc;
+ dw_frame_t function;
+};
+
void dw_type_free(dw_type_t t);
void dw_variable_free(dw_variable_t v);
void dw_variable_free_voidp(void *t);
void MC_register_variable(mc_object_info_t info, dw_frame_t frame, dw_variable_t variable);
void MC_dwarf_register_non_global_variable(mc_object_info_t info, dw_frame_t frame, dw_variable_t variable);
void MC_dwarf_register_variable(mc_object_info_t info, dw_frame_t frame, dw_variable_t variable);
+void* MC_object_base_address(mc_object_info_t info);
/********************************** DWARF **********************************/
Dwarf_Off MC_dwarf_resolve_location(unw_cursor_t* c, dw_location_t location, void* frame_pointer_address);
-void* mc_find_frame_base(unw_word_t ip, dw_frame_t frame, unw_cursor_t* unw_cursor);
+void* mc_find_frame_base(void* ip, dw_frame_t frame, unw_cursor_t* unw_cursor);
+
+#define MC_EXPRESSION_STACK_SIZE 64
+
+#define MC_EXPRESSION_OK 0
+#define MC_EXPRESSION_E_UNSUPPORTED_OPERATION 1
+#define MC_EXPRESSION_E_STACK_OVERFLOW 2
+#define MC_EXPRESSION_E_STACK_UNDERFLOW 3
+#define MC_EXPRESSION_E_MISSING_STACK_CONTEXT 4
+#define MC_EXPRESSION_E_MISSING_FRAME_BASE 5
+
+typedef struct s_mc_expression_state {
+ uintptr_t stack[MC_EXPRESSION_STACK_SIZE];
+ size_t stack_size;
+
+ unw_cursor_t* cursor;
+ void* frame_base;
+} s_mc_expression_state_t, *mc_expression_state_t;
+
+int mc_dwarf_execute_expression(size_t n, const Dwarf_Op* ops, mc_expression_state_t state);
/********************************** Miscellaneous **********************************/
char *frame;
unsigned long ip;
char *name;
- char *type;
+ dw_type_t type;
void *address;
int region;
}s_local_variable_t, *local_variable_t;
int completed;
unsigned long src_proc;
unsigned long dst_proc;
+ const char *src_host;
+ const char *dst_host;
char *rdv;
size_t data_size;
void *data;