root/ompi/debuggers/ompi_common_dll.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. ompi_fill_in_type_info
  2. ompi_fetch_pointer
  3. ompi_fetch_int
  4. ompi_fetch_bool
  5. ompi_fetch_size_t
  6. ompi_fetch_opal_pointer_array_info
  7. ompi_fetch_opal_pointer_array_item
  8. ompi_get_lib_version

   1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
   2 /*
   3  * Copyright (c) 2007-2014 Cisco Systems, Inc.  All rights reserved.
   4  * Copyright (c) 2004-2013 The University of Tennessee and The University
   5  *                         of Tennessee Research Foundation.  All rights
   6  *                         reserved.
   7  * Copyright (c) 2008-2009 Sun Microsystems, Inc.  All rights reserved.
   8  * Copyright (c) 2012-2013 Inria.  All rights reserved.
   9  * Copyright (c) 2014-2016 Research Organization for Information Science
  10  *                         and Technology (RIST). All rights reserved.
  11  * Copyright (c) 2014      Intel, Inc. All rights reserved.
  12  * Copyright (c) 2015      Los Alamos National Security, LLC.  All rights
  13  *                         reserved.
  14  * $COPYRIGHT$
  15  *
  16  * Additional copyrights may follow
  17  *
  18  * $HEADER$
  19  */
  20 
  21 /**********************************************************************
  22  * Copyright (C) 2000-2004 by Etnus, LLC.
  23  * Copyright (C) 1999 by Etnus, Inc.
  24  * Copyright (C) 1997-1998 Dolphin Interconnect Solutions Inc.
  25  *
  26  * Permission is hereby granted to use, reproduce, prepare derivative
  27  * works, and to redistribute to others.
  28  *
  29  *                                DISCLAIMER
  30  *
  31  * Neither Dolphin Interconnect Solutions, Etnus LLC, nor any of their
  32  * employees, makes any warranty express or implied, or assumes any
  33  * legal liability or responsibility for the accuracy, completeness,
  34  * or usefulness of any information, apparatus, product, or process
  35  * disclosed, or represents that its use would not infringe privately
  36  * owned rights.
  37  *
  38  * This code was written by
  39  * James Cownie: Dolphin Interconnect Solutions. <jcownie@dolphinics.com>
  40  *               Etnus LLC <jcownie@etnus.com>
  41  **********************************************************************/
  42 
  43 #include "ompi_config.h"
  44 
  45 #include "ompi_common_dll_defs.h"
  46 
  47 #include <string.h>
  48 
  49 /* Basic callbacks into the debugger */
  50 const mqs_basic_callbacks *mqs_basic_entrypoints = NULL;
  51 
  52 #if defined(WORDS_BIGENDIAN)
  53 static int host_is_big_endian = 1;
  54 #else
  55 static int host_is_big_endian = 0;
  56 #endif
  57 
  58 /*
  59  * For sanity checking to try to help keep the code in this DLL in
  60  * sync with the real structs out in the main OMPI code base.  If
  61  * we're not compiling this file inside ompi_debugger_sanity.c, then
  62  * ompi_field_offset() won't be defined.  So we define it here to be a
  63  * call to the real function mqs_field_offset.
  64  */
  65 #ifndef ompi_field_offset
  66 #define ompi_field_offset(out_name, qh_type, struct_name, field_name)   \
  67     {                                                                   \
  68         out_name = mqs_field_offset((qh_type), #field_name);            \
  69         if (out_name < 0) {                                             \
  70             fprintf(stderr, "WARNING: Open MPI is unable to find "      \
  71                     "field " #field_name " in the " #struct_name        \
  72                     " type.  This can happen can if Open MPI is built " \
  73                     "without debugging information, or is stripped "    \
  74                     "after building.\n");                               \
  75         }                                                               \
  76     }
  77 #endif
  78 
  79 /*
  80  * Open MPI use a bunch of lists in order to keep track of the
  81  * internal objects. We have to make sure we're able to find all of
  82  * them in the image and compute their ofset in order to be able to
  83  * parse them later.  We need to find the opal_list_item_t, the
  84  * opal_list_t, the opal_free_list_item_t, and the opal_free_list_t.
  85  *
  86  * Once we have these offsets, we should make sure that we have access
  87  * to all requests lists and types. We're looking here only at the
  88  * basic type for the requests as they hold all the information we
  89  * need to export to the debugger.
  90  */
  91 int ompi_fill_in_type_info(mqs_image *image, char **message)
  92 {
  93     char* missing_in_action;
  94     mpi_image_info * i_info = (mpi_image_info *)mqs_get_image_info (image);
  95 
  96     {
  97         mqs_type* qh_type = mqs_find_type( image, "opal_list_item_t", mqs_lang_c );
  98         if( !qh_type ) {
  99             missing_in_action = "opal_list_item_t";
 100             goto type_missing;
 101         }
 102         i_info->opal_list_item_t.type = qh_type;
 103         i_info->opal_list_item_t.size = mqs_sizeof(qh_type);
 104         ompi_field_offset(i_info->opal_list_item_t.offset.opal_list_next,
 105                           qh_type, opal_list_item_t, opal_list_next);
 106     }
 107     {
 108         mqs_type* qh_type = mqs_find_type( image, "opal_list_t", mqs_lang_c );
 109         if( !qh_type ) {
 110             missing_in_action = "opal_list_t";
 111             goto type_missing;
 112         }
 113         i_info->opal_list_t.type = qh_type;
 114         i_info->opal_list_t.size = mqs_sizeof(qh_type);
 115         ompi_field_offset(i_info->opal_list_t.offset.opal_list_sentinel,
 116                           qh_type, opal_list_t, opal_list_sentinel);
 117     }
 118     {
 119         mqs_type* qh_type = mqs_find_type( image, "opal_free_list_item_t", mqs_lang_c );
 120         if( !qh_type ) {
 121             missing_in_action = "opal_free_list_item_t";
 122             goto type_missing;
 123         }
 124         /* This is just an overloaded opal_list_item_t */
 125         i_info->opal_free_list_item_t.type = qh_type;
 126         i_info->opal_free_list_item_t.size = mqs_sizeof(qh_type);
 127     }
 128     {
 129         mqs_type* qh_type = mqs_find_type( image, "opal_free_list_t", mqs_lang_c );
 130 
 131         if( !qh_type ) {
 132             missing_in_action = "opal_free_list_t";
 133             goto type_missing;
 134         }
 135 
 136         i_info->opal_free_list_t.type = qh_type;
 137         i_info->opal_free_list_t.size = mqs_sizeof(qh_type);
 138         ompi_field_offset(i_info->opal_free_list_t.offset.fl_mpool,
 139                           qh_type, opal_free_list_t, fl_mpool);
 140         ompi_field_offset(i_info->opal_free_list_t.offset.fl_allocations,
 141                           qh_type, opal_free_list_t, fl_allocations);
 142         ompi_field_offset(i_info->opal_free_list_t.offset.fl_frag_class,
 143                           qh_type, opal_free_list_t, fl_frag_class);
 144         ompi_field_offset(i_info->opal_free_list_t.offset.fl_frag_size,
 145                           qh_type, opal_free_list_t, fl_frag_size);
 146         ompi_field_offset(i_info->opal_free_list_t.offset.fl_frag_alignment,
 147                           qh_type, opal_free_list_t, fl_frag_alignment);
 148         ompi_field_offset(i_info->opal_free_list_t.offset.fl_max_to_alloc,
 149                           qh_type, opal_free_list_t, fl_max_to_alloc);
 150         ompi_field_offset(i_info->opal_free_list_t.offset.fl_num_per_alloc,
 151                           qh_type, opal_free_list_t, fl_num_per_alloc);
 152         ompi_field_offset(i_info->opal_free_list_t.offset.fl_num_allocated,
 153                           qh_type, opal_free_list_t, fl_num_allocated);
 154     }
 155     {
 156         mqs_type* qh_type = mqs_find_type( image, "opal_hash_table_t", mqs_lang_c );
 157         if( !qh_type ) {
 158             missing_in_action = "opal_hash_table_t";
 159             goto type_missing;
 160         }
 161         i_info->opal_hash_table_t.type = qh_type;
 162         i_info->opal_hash_table_t.size = mqs_sizeof(qh_type);
 163         ompi_field_offset(i_info->opal_hash_table_t.offset.ht_table,
 164                           qh_type, opal_hash_table_t, ht_table);
 165         ompi_field_offset(i_info->opal_hash_table_t.offset.ht_size,
 166                           qh_type, opal_hash_table_t, ht_size);
 167     }
 168     /*
 169      * Now let's look for all types required for reading the requests.
 170      */
 171     {
 172         mqs_type* qh_type = mqs_find_type( image, "ompi_request_t", mqs_lang_c );
 173         if( !qh_type ) {
 174             missing_in_action = "ompi_request_t";
 175             goto type_missing;
 176         }
 177         i_info->ompi_request_t.type = qh_type;
 178         i_info->ompi_request_t.size = mqs_sizeof(qh_type);
 179         ompi_field_offset(i_info->ompi_request_t.offset.req_type,
 180                           qh_type, ompi_request_t, req_type);
 181         ompi_field_offset(i_info->ompi_request_t.offset.req_status,
 182                           qh_type, ompi_request_t, req_status);
 183         ompi_field_offset(i_info->ompi_request_t.offset.req_complete,
 184                           qh_type, ompi_request_t, req_complete);
 185         ompi_field_offset(i_info->ompi_request_t.offset.req_state,
 186                           qh_type, ompi_request_t, req_state);
 187         ompi_field_offset(i_info->ompi_request_t.offset.req_f_to_c_index,
 188                           qh_type, ompi_request_t, req_f_to_c_index);
 189     }
 190     {
 191         mqs_type* qh_type = mqs_find_type( image, "mca_pml_base_request_t", mqs_lang_c );
 192         if( !qh_type ) {
 193             missing_in_action = "mca_pml_base_request_t";
 194             goto type_missing;
 195         }
 196         i_info->mca_pml_base_request_t.type = qh_type;
 197         i_info->mca_pml_base_request_t.size = mqs_sizeof(qh_type);
 198         ompi_field_offset(i_info->mca_pml_base_request_t.offset.req_addr,
 199                           qh_type, mca_pml_base_request_t, req_addr);
 200         ompi_field_offset(i_info->mca_pml_base_request_t.offset.req_count,
 201                           qh_type, mca_pml_base_request_t, req_count);
 202         ompi_field_offset(i_info->mca_pml_base_request_t.offset.req_peer,
 203                           qh_type, mca_pml_base_request_t, req_peer);
 204         ompi_field_offset(i_info->mca_pml_base_request_t.offset.req_tag,
 205                           qh_type, mca_pml_base_request_t, req_tag);
 206         ompi_field_offset(i_info->mca_pml_base_request_t.offset.req_comm,
 207                           qh_type, mca_pml_base_request_t, req_comm);
 208         ompi_field_offset(i_info->mca_pml_base_request_t.offset.req_datatype,
 209                           qh_type, mca_pml_base_request_t, req_datatype);
 210         ompi_field_offset(i_info->mca_pml_base_request_t.offset.req_proc,
 211                           qh_type, mca_pml_base_request_t, req_proc);
 212         ompi_field_offset(i_info->mca_pml_base_request_t.offset.req_sequence,
 213                           qh_type, mca_pml_base_request_t, req_sequence);
 214         ompi_field_offset(i_info->mca_pml_base_request_t.offset.req_type,
 215                           qh_type, mca_pml_base_request_t, req_type);
 216         ompi_field_offset(i_info->mca_pml_base_request_t.offset.req_pml_complete,
 217                           qh_type, mca_pml_base_request_t, req_pml_complete);
 218     }
 219     {
 220         mqs_type* qh_type = mqs_find_type( image, "mca_pml_base_send_request_t", mqs_lang_c );
 221         if( !qh_type ) {
 222             missing_in_action = "mca_pml_base_send_request_t";
 223             goto type_missing;
 224         }
 225         i_info->mca_pml_base_send_request_t.type = qh_type;
 226         i_info->mca_pml_base_send_request_t.size = mqs_sizeof(qh_type);
 227         ompi_field_offset(i_info->mca_pml_base_send_request_t.offset.req_addr,
 228                           qh_type, mca_pml_base_send_request_t, req_addr);
 229         ompi_field_offset(i_info->mca_pml_base_send_request_t.offset.req_bytes_packed,
 230                           qh_type, mca_pml_base_send_request_t, req_bytes_packed);
 231         ompi_field_offset(i_info->mca_pml_base_send_request_t.offset.req_send_mode,
 232                           qh_type, mca_pml_base_send_request_t, req_send_mode);
 233     }
 234     {
 235         mqs_type* qh_type = mqs_find_type( image, "mca_pml_base_recv_request_t", mqs_lang_c );
 236         if( !qh_type ) {
 237             missing_in_action = "mca_pml_base_recv_request_t";
 238             goto type_missing;
 239         }
 240         i_info->mca_pml_base_recv_request_t.type = qh_type;
 241         i_info->mca_pml_base_recv_request_t.size = mqs_sizeof(qh_type);
 242         ompi_field_offset(i_info->mca_pml_base_recv_request_t.offset.req_bytes_packed,
 243                           qh_type, mca_pml_base_recv_request_t, req_bytes_packed);
 244     }
 245     /*
 246      * Gather information about the received fragments and theirs headers.
 247      */
 248 #if 0  /* Disabled until I find a better way */
 249     {
 250         mqs_type* qh_type = mqs_find_type( image, "mca_pml_ob1_common_hdr_t", mqs_lang_c );
 251         if( !qh_type ) {
 252             missing_in_action = "mca_pml_ob1_common_hdr_t";
 253             goto type_missing;
 254         }
 255         i_info->mca_pml_ob1_common_hdr_t.type = qh_type;
 256         i_info->mca_pml_ob1_common_hdr_t.size = mqs_sizeof(qh_type);
 257         ompi_field_offset(i_info->mca_pml_ob1_common_hdr_t.offset.hdr_type,
 258                           qh_type, mca_pml_ob1_common_hdr_t, hdr_type);
 259         ompi_field_offset(i_info->mca_pml_ob1_common_hdr_t.offset.hdr_flags,
 260                           qh_type, mca_pml_ob1_common_hdr_t, hdr_flags);
 261     }
 262     {
 263         mqs_type* qh_type = mqs_find_type( image, "mca_pml_ob1_match_hdr_t", mqs_lang_c );
 264         if( !qh_type ) {
 265             missing_in_action = "mca_pml_ob1_match_hdr_t";
 266             goto type_missing;
 267         }
 268         i_info->mca_pml_ob1_match_hdr_t.type = qh_type;
 269         i_info->mca_pml_ob1_match_hdr_t.size = mqs_sizeof(qh_type);
 270         ompi_field_offset(i_info->mca_pml_ob1_match_hdr_t.offset.hdr_common,
 271                           qh_type, mca_pml_ob1_match_hdr_t, hdr_common);
 272         ompi_field_offset(i_info->mca_pml_ob1_match_hdr_t.offset.hdr_ctx,
 273                           qh_type, mca_pml_ob1_match_hdr_t, hdr_ctx);
 274         ompi_field_offset(i_info->mca_pml_ob1_match_hdr_t.offset.hdr_src,
 275                           qh_type, mca_pml_ob1_match_hdr_t, hdr_src);
 276         ompi_field_offset(i_info->mca_pml_ob1_match_hdr_t.offset.hdr_tag,
 277                           qh_type, mca_pml_ob1_match_hdr_t, hdr_tag);
 278         ompi_field_offset(i_info->mca_pml_ob1_match_hdr_t.offset.hdr_seq,
 279                           qh_type, mca_pml_ob1_match_hdr_t, hdr_seq);
 280     }
 281     {
 282         mqs_type* qh_type = mqs_find_type( image, "mca_pml_ob1_recv_frag_t", mqs_lang_c );
 283         if( !qh_type ) {
 284             missing_in_action = "mca_pml_ob1_recv_frag_t";
 285             goto type_missing;
 286         }
 287         i_info->mca_pml_ob1_recv_frag_t.type = qh_type;
 288         i_info->mca_pml_ob1_recv_frag_t.size = mqs_sizeof(qh_type);
 289         ompi_field_offset(i_info->mca_pml_ob1_recv_frag_t.offset.hdr,
 290                           qh_type, mca_pml_ob1_recv_frag_t, hdr);
 291         ompi_field_offset(i_info->mca_pml_ob1_recv_frag_t.offset.request,
 292                           qh_type, mca_pml_ob1_recv_frag_t, request);
 293     }
 294 #endif
 295     /*
 296      * And now let's look at the communicator and group structures.
 297      */
 298     {
 299         mqs_type* qh_type = mqs_find_type( image, "opal_pointer_array_t", mqs_lang_c );
 300         if( !qh_type ) {
 301             missing_in_action = "opal_pointer_array_t";
 302             goto type_missing;
 303         }
 304         i_info->opal_pointer_array_t.type = qh_type;
 305         i_info->opal_pointer_array_t.size = mqs_sizeof(qh_type);
 306         ompi_field_offset(i_info->opal_pointer_array_t.offset.lowest_free,
 307                           qh_type, opal_pointer_array_t, lowest_free);
 308         ompi_field_offset(i_info->opal_pointer_array_t.offset.number_free,
 309                           qh_type, opal_pointer_array_t, number_free);
 310         ompi_field_offset(i_info->opal_pointer_array_t.offset.size,
 311                           qh_type, opal_pointer_array_t, size);
 312         ompi_field_offset(i_info->opal_pointer_array_t.offset.addr,
 313                           qh_type, opal_pointer_array_t, addr);
 314     }
 315     {
 316         mqs_type* qh_type = mqs_find_type( image, "ompi_communicator_t", mqs_lang_c );
 317         if( !qh_type ) {
 318             missing_in_action = "ompi_communicator_t";
 319             goto type_missing;
 320         }
 321         i_info->ompi_communicator_t.type = qh_type;
 322         i_info->ompi_communicator_t.size = mqs_sizeof(qh_type);
 323         ompi_field_offset(i_info->ompi_communicator_t.offset.c_name,
 324                           qh_type, ompi_communicator_t, c_name);
 325         ompi_field_offset(i_info->ompi_communicator_t.offset.c_contextid,
 326                           qh_type, ompi_communicator_t, c_contextid);
 327         ompi_field_offset(i_info->ompi_communicator_t.offset.c_my_rank,
 328                           qh_type, ompi_communicator_t, c_my_rank);
 329         ompi_field_offset(i_info->ompi_communicator_t.offset.c_local_group,
 330                           qh_type, ompi_communicator_t, c_local_group);
 331         ompi_field_offset(i_info->ompi_communicator_t.offset.c_remote_group,
 332                           qh_type, ompi_communicator_t, c_remote_group);
 333         ompi_field_offset(i_info->ompi_communicator_t.offset.c_flags,
 334                           qh_type, ompi_communicator_t, c_flags);
 335         ompi_field_offset(i_info->ompi_communicator_t.offset.c_f_to_c_index,
 336                           qh_type, ompi_communicator_t, c_f_to_c_index);
 337         ompi_field_offset(i_info->ompi_communicator_t.offset.c_topo,
 338                           qh_type, ompi_communicator_t, c_topo);
 339         ompi_field_offset(i_info->ompi_communicator_t.offset.c_keyhash,
 340                           qh_type, ompi_communicator_t, c_keyhash);
 341     }
 342     {
 343         mqs_type* qh_type, *cart_type, *graph_type, *dist_graph_type;
 344         int offset = 0;
 345 
 346         missing_in_action = "mca_topo_base_module_t";
 347         qh_type = mqs_find_type(image, missing_in_action, mqs_lang_c);
 348         if( !qh_type ) {
 349             goto type_missing;
 350         }
 351         i_info->mca_topo_base_module_t.type = qh_type;
 352         i_info->mca_topo_base_module_t.size = mqs_sizeof(qh_type);
 353 
 354         /* The topo module contains multiple unions.  These fields are
 355            outside those unions. */
 356         ompi_field_offset(i_info->mca_topo_base_module_t.offset.mtc,
 357                           qh_type, mca_topo_base_module_t, mtc);
 358         ompi_field_offset(i_info->mca_topo_base_module_t.offset.reorder,
 359                           qh_type, mca_topo_base_module_t, reorder);
 360 
 361         /* By definition, the base offsets are 0 in the union.
 362            Above we've got the base union offset, so now look up the
 363            individual fields in the cart, graph and dist_graph structs and
 364            add them to the base union offset.  Then we have the offset of
 365            that field from the mca_topo_base_module_2_1_0_t type. */
 366 
 367         /* Cart type */
 368         missing_in_action = "mca_topo_base_comm_cart_2_2_0_t";
 369         cart_type = mqs_find_type(image, missing_in_action, mqs_lang_c);
 370         if (!cart_type) {
 371             goto type_missing;
 372         }
 373         ompi_field_offset(i_info->mca_topo_base_module_t.offset.mtc_cart.ndims,
 374                           cart_type, mca_topo_base_comm_cart_2_2_0_t,
 375                           ndims);
 376         ompi_field_offset(i_info->mca_topo_base_module_t.offset.mtc_cart.dims,
 377                           cart_type, mca_topo_base_comm_cart_2_2_0_t,
 378                           dims);
 379         ompi_field_offset(i_info->mca_topo_base_module_t.offset.mtc_cart.periods,
 380                           cart_type, mca_topo_base_comm_cart_2_2_0_t,
 381                           periods);
 382         ompi_field_offset(i_info->mca_topo_base_module_t.offset.mtc_cart.coords,
 383                           cart_type, mca_topo_base_comm_cart_2_2_0_t,
 384                           coords);
 385         i_info->mca_topo_base_module_t.offset.mtc_cart.ndims   += offset;
 386         i_info->mca_topo_base_module_t.offset.mtc_cart.dims    += offset;
 387         i_info->mca_topo_base_module_t.offset.mtc_cart.periods += offset;
 388         i_info->mca_topo_base_module_t.offset.mtc_cart.coords  += offset;
 389 
 390         /* Graph type */
 391         missing_in_action = "mca_topo_base_comm_graph_2_2_0_t";
 392         graph_type = mqs_find_type(image, missing_in_action, mqs_lang_c);
 393         if (!graph_type) {
 394             goto type_missing;
 395         }
 396         ompi_field_offset(i_info->mca_topo_base_module_t.offset.mtc_graph.nnodes,
 397                           graph_type, mca_topo_base_comm_graph_2_2_0_t,
 398                           nnodes);
 399         ompi_field_offset(i_info->mca_topo_base_module_t.offset.mtc_graph.index,
 400                           graph_type, mca_topo_base_comm_graph_2_2_0_t,
 401                           index);
 402         ompi_field_offset(i_info->mca_topo_base_module_t.offset.mtc_graph.edges,
 403                           graph_type, mca_topo_base_comm_graph_2_2_0_t,
 404                           edges);
 405         i_info->mca_topo_base_module_t.offset.mtc_graph.nnodes += offset;
 406         i_info->mca_topo_base_module_t.offset.mtc_graph.index  += offset;
 407         i_info->mca_topo_base_module_t.offset.mtc_graph.edges  += offset;
 408 
 409         /* Distributed Graph type */
 410         missing_in_action = "mca_topo_base_comm_dist_graph_2_2_0_t";
 411         dist_graph_type = mqs_find_type(image, missing_in_action, mqs_lang_c);
 412         if (!dist_graph_type) {
 413             goto type_missing;
 414         }
 415         ompi_field_offset(i_info->mca_topo_base_module_t.offset.mtc_dist_graph.in,
 416                           dist_graph_type, mca_topo_base_comm_dist_graph_2_2_0_t,
 417                           in);
 418         ompi_field_offset(i_info->mca_topo_base_module_t.offset.mtc_dist_graph.inw,
 419                           dist_graph_type, mca_topo_base_comm_dist_graph_2_2_0_t,
 420                           inw);
 421         ompi_field_offset(i_info->mca_topo_base_module_t.offset.mtc_dist_graph.out,
 422                           dist_graph_type, mca_topo_base_comm_dist_graph_2_2_0_t,
 423                           out);
 424         ompi_field_offset(i_info->mca_topo_base_module_t.offset.mtc_dist_graph.outw,
 425                           dist_graph_type, mca_topo_base_comm_dist_graph_2_2_0_t,
 426                           outw);
 427         ompi_field_offset(i_info->mca_topo_base_module_t.offset.mtc_dist_graph.indegree,
 428                           dist_graph_type, mca_topo_base_comm_dist_graph_2_2_0_t,
 429                           indegree);
 430         ompi_field_offset(i_info->mca_topo_base_module_t.offset.mtc_dist_graph.outdegree,
 431                           dist_graph_type, mca_topo_base_comm_dist_graph_2_2_0_t,
 432                           outdegree);
 433         ompi_field_offset(i_info->mca_topo_base_module_t.offset.mtc_dist_graph.weighted,
 434                           dist_graph_type, mca_topo_base_comm_dist_graph_2_2_0_t,
 435                           weighted);
 436     }
 437     {
 438         mqs_type* qh_type = mqs_find_type( image, "ompi_group_t", mqs_lang_c );
 439         if( !qh_type ) {
 440             missing_in_action = "ompi_group_t";
 441             goto type_missing;
 442         }
 443         i_info->ompi_group_t.type = qh_type;
 444         i_info->ompi_group_t.size = mqs_sizeof(qh_type);
 445         ompi_field_offset(i_info->ompi_group_t.offset.grp_proc_count,
 446                           qh_type, ompi_group_t, grp_proc_count);
 447         ompi_field_offset(i_info->ompi_group_t.offset.grp_proc_pointers,
 448                           qh_type, ompi_group_t, grp_proc_pointers);
 449         ompi_field_offset(i_info->ompi_group_t.offset.grp_my_rank,
 450                           qh_type, ompi_group_t, grp_my_rank);
 451         ompi_field_offset(i_info->ompi_group_t.offset.grp_flags,
 452                           qh_type, ompi_group_t, grp_flags);
 453     }
 454     {
 455         mqs_type* qh_type = mqs_find_type( image, "ompi_status_public_t", mqs_lang_c );
 456         if( !qh_type ) {
 457             missing_in_action = "ompi_status_public_t";
 458             goto type_missing;
 459         }
 460         i_info->ompi_status_public_t.type = qh_type;
 461         i_info->ompi_status_public_t.size = mqs_sizeof(qh_type);
 462         ompi_field_offset(i_info->ompi_status_public_t.offset.MPI_SOURCE,
 463                           qh_type, ompi_status_public_t, MPI_SOURCE);
 464         ompi_field_offset(i_info->ompi_status_public_t.offset.MPI_TAG,
 465                           qh_type, ompi_status_public_t, MPI_TAG);
 466         ompi_field_offset(i_info->ompi_status_public_t.offset.MPI_ERROR,
 467                           qh_type, ompi_status_public_t, MPI_ERROR);
 468         ompi_field_offset(i_info->ompi_status_public_t.offset._ucount,
 469                           qh_type, ompi_status_public_t, _ucount);
 470         ompi_field_offset(i_info->ompi_status_public_t.offset._cancelled,
 471                           qh_type, ompi_status_public_t, _cancelled);
 472     }
 473     {
 474         mqs_type* qh_type = mqs_find_type( image, "ompi_datatype_t", mqs_lang_c );
 475         if( !qh_type ) {
 476             missing_in_action = "ompi_datatype_t";
 477             goto type_missing;
 478         }
 479         i_info->ompi_datatype_t.type = qh_type;
 480         i_info->ompi_datatype_t.size = mqs_sizeof(qh_type);
 481         ompi_field_offset(i_info->ompi_datatype_t.offset.name,
 482                           qh_type, ompi_datatype_t, name);
 483 
 484         /* get ompi_datatype_t super.size which requires the offset
 485          * of super and then the offset of size in opal_datatype_t.
 486          */
 487         {
 488             int super_offset = 0;
 489 
 490             ompi_field_offset(super_offset,
 491                               qh_type, ompi_datatype_t, super);
 492 
 493             qh_type = mqs_find_type( image, "opal_datatype_t", mqs_lang_c );
 494             if( !qh_type ) {
 495                 missing_in_action = "opal_datatype_t";
 496                 goto type_missing;
 497             }
 498             ompi_field_offset(i_info->ompi_datatype_t.offset.size,
 499                               qh_type, opal_datatype_t, size);
 500             i_info->ompi_datatype_t.offset.size += super_offset;
 501         }
 502     }
 503 
 504     /* All the types are here. Let's succesfully return. */
 505     *message = NULL;
 506     return mqs_ok;
 507 
 508  type_missing:
 509     /*
 510      * One of the required types is missing in the image. We are
 511      * unable to extract the information we need from the pointers. We
 512      * did our best but here we're at our limit. Give up!
 513      */
 514     *message = missing_in_action;
 515     fprintf(stderr, "WARNING: Open MPI is unable to find debugging information about the \"%s\" type.  This can happen if Open MPI was built without debugging information, or was stripped after building.\n",
 516            missing_in_action);
 517     return err_missing_type;
 518 }
 519 
 520 /***********************************************************************
 521  * Functions to access the image memory. They are specialized based    *
 522  * on the type we want to access and the debugged process architecture *
 523  ***********************************************************************/
 524 mqs_taddr_t ompi_fetch_pointer (mqs_process *proc, mqs_taddr_t addr,
 525                                 mpi_process_info *p_info)
 526 {
 527     int isize = p_info->sizes.pointer_size;
 528     char buffer[8];                  /* ASSUME the type fits in 8 bytes */
 529     mqs_taddr_t res = 0;
 530 
 531     if (mqs_ok == mqs_fetch_data (proc, addr, isize, buffer))
 532         mqs_target_to_host (proc, buffer,
 533                             ((char *)&res) + (host_is_big_endian ? sizeof(mqs_taddr_t)-isize : 0),
 534                             isize);
 535 
 536     return res;
 537 } /* fetch_pointer */
 538 
 539 /***********************************************************************/
 540 mqs_tword_t ompi_fetch_int (mqs_process *proc, mqs_taddr_t addr,
 541                             mpi_process_info *p_info)
 542 {
 543     int isize = p_info->sizes.int_size;
 544     char buffer[8];                  /* ASSUME the type fits in 8 bytes */
 545     mqs_tword_t res = 0;
 546 
 547     if (mqs_ok == mqs_fetch_data (proc, addr, isize, buffer)) {
 548         mqs_target_to_host (proc, buffer,
 549                             ((char *)&res) + (host_is_big_endian ? sizeof(mqs_tword_t)-isize : 0),
 550                             isize);
 551     }
 552     return res;
 553 } /* fetch_int */
 554 
 555 /***********************************************************************/
 556 mqs_tword_t ompi_fetch_bool(mqs_process *proc, mqs_taddr_t addr,
 557                             mpi_process_info *p_info)
 558 {
 559     int isize = p_info->sizes.bool_size;
 560     mqs_tword_t res = 0;
 561 
 562     mqs_fetch_data (proc, addr, isize, &res);
 563     return (0 == res ? 0 : 1);
 564 } /* fetch_bool */
 565 
 566 /***********************************************************************/
 567 mqs_taddr_t ompi_fetch_size_t(mqs_process *proc, mqs_taddr_t addr,
 568                               mpi_process_info *p_info)
 569 {
 570     int isize = p_info->sizes.size_t_size;
 571     char buffer[8];                  /* ASSUME the type fits in 8 bytes */
 572     mqs_taddr_t res = 0;
 573 
 574     if (mqs_ok == mqs_fetch_data (proc, addr, isize, buffer))
 575         mqs_target_to_host (proc, buffer,
 576                             ((char *)&res) + (host_is_big_endian ? sizeof(mqs_taddr_t)-isize : 0),
 577                             isize);
 578 
 579     return res;
 580 } /* fetch_size_t */
 581 
 582 /***********************************************************************/
 583 
 584 int ompi_fetch_opal_pointer_array_info(mqs_process *proc, mqs_taddr_t addr,
 585                                        mpi_process_info *p_info,
 586                                        int *size, int *lowest_free,
 587                                        int *number_free)
 588 {
 589     mqs_image *image = mqs_get_image(proc);
 590     mpi_image_info *i_info = (mpi_image_info *) mqs_get_image_info(image);
 591 
 592     *size = ompi_fetch_int(proc,
 593                            addr + i_info->opal_pointer_array_t.offset.size,
 594                            p_info);
 595     *lowest_free = ompi_fetch_int(proc,
 596                                   addr + i_info->opal_pointer_array_t.offset.lowest_free,
 597                                   p_info);
 598     *number_free = ompi_fetch_int(proc,
 599                                   addr + i_info->opal_pointer_array_t.offset.number_free,
 600                                   p_info);
 601     return mqs_ok;
 602 }
 603 
 604 /***********************************************************************/
 605 
 606 int ompi_fetch_opal_pointer_array_item(mqs_process *proc, mqs_taddr_t addr,
 607                                        mpi_process_info *p_info, int index,
 608                                        mqs_taddr_t *item)
 609 {
 610     mqs_image *image = mqs_get_image(proc);
 611     mpi_image_info *i_info = (mpi_image_info *) mqs_get_image_info(image);
 612     int size, lowest_free, number_free;
 613     mqs_taddr_t base;
 614 
 615     if (index < 0) {
 616         return mqs_no_information;
 617     }
 618 
 619     ompi_fetch_opal_pointer_array_info(proc, addr, p_info, &size,
 620                                        &lowest_free, &number_free);
 621     if (index >= size) {
 622         return mqs_no_information;
 623     }
 624 
 625     base = ompi_fetch_pointer(proc,
 626                               addr + i_info->opal_pointer_array_t.offset.addr,
 627                               p_info);
 628     *item = ompi_fetch_pointer(proc,
 629                                base + index * p_info->sizes.pointer_size,
 630                                p_info);
 631 
 632     return mqs_ok;
 633 }
 634 
 635 int ompi_get_lib_version(char * buf, int size) {
 636     int ret;
 637     ret = snprintf(buf, size-1, "Open MPI v%d.%d.%d%s%s%s%s%s%s%s%s%s",
 638                    OMPI_MAJOR_VERSION, OMPI_MINOR_VERSION, OMPI_RELEASE_VERSION,
 639                    (strlen(OMPI_GREEK_VERSION) > 0)?OMPI_GREEK_VERSION:"",
 640                    (strlen(OPAL_PACKAGE_STRING) > 0)?", package: ":"",
 641                    (strlen(OPAL_PACKAGE_STRING) > 0)?OPAL_PACKAGE_STRING:"",
 642                    (strlen(OPAL_IDENT_STRING)> 0)?", ident: ":"",
 643                    (strlen(OPAL_IDENT_STRING)> 0)?OMPI_IDENT_STRING:"",
 644                    (strlen(OMPI_REPO_REV) > 0)?", repo rev: ":"",
 645                    (strlen(OMPI_REPO_REV) > 0)?OMPI_REPO_REV:"",
 646                    (strlen(OMPI_RELEASE_DATE) > 0)?", ":"",
 647                    (strlen(OMPI_RELEASE_DATE) > 0)?OMPI_RELEASE_DATE:"");
 648     buf[size-1] = '\0';
 649     return ret;
 650 }

/* [<][>][^][v][top][bottom][index][help] */