- for(size_t i=0; i!=locations->size; ++i) {
- mc_expression_t expression = locations->locations + i;
- if( (expression->lowpc==NULL && expression->highpc==NULL)
- || (c && ip >= (unw_word_t) expression->lowpc && ip < (unw_word_t) expression->highpc)) {
- return mc_dwarf_resolve_location(expression, c, frame_pointer_address);
+ mc_expression_t expression = mc_find_expression(locations, ip);
+ if (expression) {
+ mc_dwarf_resolve_location(location,
+ expression, object_info, c,
+ frame_pointer_address, snapshot, process_index);
+ } else {
+ xbt_die("Could not resolve location");
+ }
+}
+
+/** \brief Find the frame base of a given frame
+ *
+ * \param frame
+ * \param unw_cursor
+ */
+void *mc_find_frame_base(dw_frame_t frame, mc_object_info_t object_info,
+ unw_cursor_t * unw_cursor)
+{
+ s_mc_location_t location;
+ mc_dwarf_resolve_locations(&location,
+ &frame->frame_base, object_info,
+ unw_cursor, NULL, NULL, -1);
+ switch(mc_get_location_type(&location)) {
+ case MC_LOCATION_TYPE_ADDRESS:
+ return location.memory_location;
+
+ case MC_LOCATION_TYPE_REGISTER: {
+ // This is a special case.
+ // The register if not the location of the frame base
+ // (a frame base cannot be located in a register)
+ // Instead, DWARF defines this to mean that the register
+ // contains the address of the frame base.
+ unw_word_t word;
+ unw_get_reg(location.cursor, location.register_id, &word);
+ return (void*) word;