#include <xbt/log.h>
#include <xbt/sysdep.h>
+#include "mc_object_info.h"
#include "mc_private.h"
+static void MC_dwarf_register_global_variable(mc_object_info_t info, dw_variable_t variable);
+static void MC_register_variable(mc_object_info_t info, dw_frame_t frame, dw_variable_t variable);
+static void MC_dwarf_register_non_global_variable(mc_object_info_t info, dw_frame_t frame, dw_variable_t variable);
+static void MC_dwarf_register_variable(mc_object_info_t info, dw_frame_t frame, dw_variable_t variable);
+
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_dwarf, mc, "DWARF processing");
/** \brief The default DW_TAG_lower_bound for a given DW_AT_language.
case DW_TAG_restrict_type:
case DW_TAG_interface_type:
case DW_TAG_unspecified_type:
- case DW_TAG_mutable_type:
case DW_TAG_shared_type:
return mc_tag_type;
}
Dwarf *dwarf = dwarf_begin(fd, DWARF_C_READ);
if (dwarf == NULL) {
- xbt_die("Your program must be compiled with -g");
+ xbt_die("Your program must be compiled with -g (%s)", info->file_name);
}
// For each compilation unit:
Dwarf_Off offset = 0;
info->functions_index = index;
}
-mc_object_info_t MC_ip_find_object_info(void *ip)
-{
- size_t i;
- for (i = 0; i != mc_object_infos_size; ++i) {
- if (ip >= (void *) mc_object_infos[i]->start_exec
- && ip <= (void *) mc_object_infos[i]->end_exec) {
- return mc_object_infos[i];
- }
- }
- return NULL;
-}
-
-static dw_frame_t MC_find_function_by_ip_and_object(void *ip,
- mc_object_info_t info)
-{
- xbt_dynar_t dynar = info->functions_index;
- mc_function_index_item_t base =
- (mc_function_index_item_t) xbt_dynar_get_ptr(dynar, 0);
- int i = 0;
- int j = xbt_dynar_length(dynar) - 1;
- while (j >= i) {
- int k = i + ((j - i) / 2);
- if (ip < base[k].low_pc) {
- j = k - 1;
- } else if (ip >= base[k].high_pc) {
- i = k + 1;
- } else {
- return base[k].function;
- }
- }
- return NULL;
-}
-
-dw_frame_t MC_find_function_by_ip(void *ip)
-{
- mc_object_info_t info = MC_ip_find_object_info(ip);
- if (info == NULL)
- return NULL;
- else
- return MC_find_function_by_ip_and_object(ip, info);
-}
-
static void MC_post_process_variables(mc_object_info_t info)
{
unsigned cursor = 0;
}
}
+
+/** \brief Fill/lookup the "subtype" field.
+ */
+static void MC_resolve_subtype(mc_object_info_t info, dw_type_t type)
+{
+
+ if (type->dw_type_id == NULL)
+ return;
+ type->subtype = xbt_dict_get_or_null(info->types, type->dw_type_id);
+ if (type->subtype == NULL)
+ return;
+ if (type->subtype->byte_size != 0)
+ return;
+ if (type->subtype->name == NULL)
+ return;
+ // Try to find a more complete description of the type:
+ // We need to fix in order to support C++.
+
+ dw_type_t subtype =
+ xbt_dict_get_or_null(info->full_types_by_name, type->subtype->name);
+ if (subtype != NULL) {
+ type->subtype = subtype;
+ }
+
+}
+
+static void MC_post_process_types(mc_object_info_t info)
+{
+ xbt_dict_cursor_t cursor = NULL;
+ char *origin;
+ dw_type_t type;
+
+ // Lookup "subtype" field:
+ xbt_dict_foreach(info->types, cursor, origin, type) {
+ MC_resolve_subtype(info, type);
+
+ dw_type_t member;
+ unsigned int i = 0;
+ if (type->members != NULL)
+ xbt_dynar_foreach(type->members, i, member) {
+ MC_resolve_subtype(info, member);
+ }
+ }
+}
+
/** \brief Finds informations about a given shared object/executable */
-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, const char *name,
int executable)
{
mc_object_info_t result = MC_new_object_info();
MC_dwarf_register_non_global_variable(info, frame, variable);
}
-void MC_post_process_object_info(mc_object_info_t info)
+void MC_post_process_object_info(mc_process_t process, mc_object_info_t info)
{
xbt_dict_cursor_t cursor = NULL;
char *key = NULL;
// Resolve full_type:
if (type->name && type->byte_size == 0) {
- for (size_t i = 0; i != mc_object_infos_size; ++i) {
+ for (size_t i = 0; i != process->object_infos_size; ++i) {
dw_type_t same_type =
- xbt_dict_get_or_null(mc_object_infos[i]->full_types_by_name,
+ xbt_dict_get_or_null(process->object_infos[i]->full_types_by_name,
type->name);
if (same_type && same_type->name && same_type->byte_size) {
type->full_type = same_type;