00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 #include "defs.h"
00039
00040 #include "symtab.h"
00041 #include "strtab.h"
00042 #include "cxx_memory.h"
00043 #include "dwarf_DST.h"
00044 #include "dwarf_DST_producer.h"
00045 #include "dwarf_DST_mem.h"
00046 #include "clone.h"
00047 #include "clone_DST_utils.h"
00048
00049
00050 INT num_gen_names = 1;
00051
00052 #ifndef _LEGO_CLONER
00053 extern MEM_POOL Ipo_mem_pool;
00054 #endif
00055
00056 const DST_INFO_IDX foreign_origin = DST_FOREIGN_INIT;
00057
00058
00059 #define GET_ABSTRACT_ORIGIN(x) ((caller_file_dst == callee_file_dst)? get_abstract_origin(x): foreign_origin)
00060
00061
00062 #if !defined(_STANDALONE_INLINER)
00063 static char *
00064 create_ipa_internal_name(void)
00065 {
00066 char *name;
00067
00068 #if defined(__GNUC__)
00069
00070
00071 #if defined(_LEGO_CLONER)
00072 name = (char *) CXX_NEW(char[strlen("***ipa_intnl***")+20],
00073 MEM_src_pool_ptr);
00074 #else
00075 name = (char *) CXX_NEW(char[strlen("***ipa_intnl***")+20],
00076 &Ipo_mem_pool);
00077 #endif // _LEGO_CLONER
00078 #else
00079 name = (char *)CXX_NEW(char[strlen("***ipa_intnl***")+20],
00080 #ifndef _LEGO_CLONER
00081 &Ipo_mem_pool);
00082 #else
00083 MEM_src_pool_ptr);
00084 #endif
00085 #endif // __GNUC__
00086
00087 if (name)
00088 sprintf(name, "%s_%d", "***ipa_intnl***", num_gen_names++);
00089 return (name);
00090 }
00091 #endif // !defined(_STANDALONE_INLINER)
00092
00093
00094 static DST_IDX
00095 get_abstract_origin(DST_IDX concrete_instance)
00096 {
00097 DST_INFO *dst = DST_INFO_IDX_TO_PTR(concrete_instance);
00098
00099 if (DST_IS_FOREIGN_OBJ(concrete_instance))
00100 return concrete_instance;
00101
00102 switch (DST_INFO_tag(dst)) {
00103 case DW_TAG_inlined_subroutine:
00104 {
00105 DST_INLINED_SUBROUTINE *attr =
00106 DST_ATTR_IDX_TO_PTR(DST_INFO_attributes(dst),
00107 DST_INLINED_SUBROUTINE);
00108 if (DST_IS_NULL(DST_INLINED_SUBROUTINE_abstract_origin(attr)))
00109 return concrete_instance;
00110 else
00111 return get_abstract_origin(DST_INLINED_SUBROUTINE_abstract_origin(attr));
00112 }
00113
00114 case DW_TAG_label:
00115 {
00116 DST_LABEL *attr = DST_ATTR_IDX_TO_PTR(DST_INFO_attributes(dst), DST_LABEL);
00117 if (DST_IS_NULL(DST_LABEL_abstract_origin(attr)))
00118 return concrete_instance;
00119 else
00120 return get_abstract_origin(DST_LABEL_abstract_origin(attr));
00121 }
00122
00123 case DW_TAG_variable:
00124 {
00125 DST_VARIABLE *attr = DST_ATTR_IDX_TO_PTR(DST_INFO_attributes(dst), DST_VARIABLE);
00126 if (DST_IS_NULL(DST_VARIABLE_def_abstract_origin(attr)))
00127 return concrete_instance;
00128 else
00129 return get_abstract_origin(DST_VARIABLE_def_abstract_origin(attr));
00130 }
00131
00132 case DW_TAG_formal_parameter:
00133 {
00134 DST_FORMAL_PARAMETER *attr = DST_ATTR_IDX_TO_PTR(DST_INFO_attributes (dst), DST_FORMAL_PARAMETER);
00135 if (DST_IS_NULL(DST_FORMAL_PARAMETER_abstract_origin(attr)))
00136 return concrete_instance;
00137 else
00138 return get_abstract_origin(DST_FORMAL_PARAMETER_abstract_origin(attr));
00139 }
00140
00141 case DW_TAG_lexical_block:
00142 {
00143 DST_LEXICAL_BLOCK *attr = DST_ATTR_IDX_TO_PTR(DST_INFO_attributes (dst), DST_LEXICAL_BLOCK);
00144 if (DST_IS_NULL(DST_LEXICAL_BLOCK_abstract_origin(attr)))
00145 return concrete_instance;
00146 else
00147 return get_abstract_origin(DST_LEXICAL_BLOCK_abstract_origin(attr));
00148 }
00149
00150 case DW_TAG_unspecified_parameters:
00151 {
00152 DST_UNSPECIFIED_PARAMETERS *attr = DST_ATTR_IDX_TO_PTR(DST_INFO_attributes (dst), DST_UNSPECIFIED_PARAMETERS);
00153 if (DST_IS_NULL(DST_UNSPECIFIED_PARAMETERS_abstract_origin(attr)))
00154 return concrete_instance;
00155 else
00156 return get_abstract_origin(DST_UNSPECIFIED_PARAMETERS_abstract_origin(attr));
00157 }
00158
00159 case DW_TAG_typedef:
00160 {
00161 DST_TYPEDEF *attr = DST_ATTR_IDX_TO_PTR(DST_INFO_attributes (dst), DST_TYPEDEF);
00162 if (DST_IS_NULL(DST_TYPEDEF_abstract_origin(attr)))
00163 return concrete_instance;
00164 else
00165 return get_abstract_origin(DST_TYPEDEF_abstract_origin(attr));
00166 }
00167
00168 case DW_TAG_array_type:
00169 {
00170 DST_ARRAY_TYPE *attr = DST_ATTR_IDX_TO_PTR(DST_INFO_attributes (dst), DST_ARRAY_TYPE);
00171 if (DST_IS_NULL(DST_ARRAY_TYPE_abstract_origin(attr)))
00172 return concrete_instance;
00173 else
00174 return get_abstract_origin(DST_ARRAY_TYPE_abstract_origin(attr));
00175 }
00176
00177 case DW_TAG_structure_type:
00178 {
00179 DST_STRUCTURE_TYPE *attr = DST_ATTR_IDX_TO_PTR(DST_INFO_attributes (dst), DST_STRUCTURE_TYPE);
00180 if (DST_IS_NULL(DST_STRUCTURE_TYPE_abstract_origin(attr)))
00181 return concrete_instance;
00182 else
00183 return get_abstract_origin(DST_STRUCTURE_TYPE_abstract_origin(attr));
00184 }
00185
00186 case DW_TAG_union_type:
00187 {
00188 DST_UNION_TYPE *attr = DST_ATTR_IDX_TO_PTR(DST_INFO_attributes (dst), DST_UNION_TYPE);
00189 if (DST_IS_NULL(DST_UNION_TYPE_abstract_origin(attr)))
00190 return concrete_instance;
00191 else
00192 return get_abstract_origin(DST_UNION_TYPE_abstract_origin(attr));
00193 }
00194
00195 case DW_TAG_class_type:
00196 {
00197 DST_CLASS_TYPE *attr = DST_ATTR_IDX_TO_PTR(DST_INFO_attributes (dst), DST_CLASS_TYPE);
00198 if (DST_IS_NULL(DST_CLASS_TYPE_abstract_origin(attr)))
00199 return concrete_instance;
00200 else
00201 return get_abstract_origin(DST_CLASS_TYPE_abstract_origin(attr));
00202 }
00203
00204 case DW_TAG_enumeration_type:
00205 {
00206 DST_ENUMERATION_TYPE *attr = DST_ATTR_IDX_TO_PTR(DST_INFO_attributes (dst), DST_ENUMERATION_TYPE);
00207 if (DST_IS_NULL(DST_ENUMERATION_TYPE_abstract_origin(attr)))
00208 return concrete_instance;
00209 else
00210 return get_abstract_origin(DST_ENUMERATION_TYPE_abstract_origin(attr));
00211 }
00212
00213 case DW_TAG_subroutine_type:
00214 {
00215 DST_SUBROUTINE_TYPE *attr = DST_ATTR_IDX_TO_PTR(DST_INFO_attributes (dst), DST_SUBROUTINE_TYPE);
00216 if (DST_IS_NULL(DST_SUBROUTINE_TYPE_abstract_origin(attr)))
00217 return concrete_instance;
00218 else
00219 return get_abstract_origin(DST_SUBROUTINE_TYPE_abstract_origin(attr));
00220 }
00221
00222 }
00223
00224 return concrete_instance;
00225 }
00226
00227
00228
00229 static void
00230 DST_enter_cloned_childs(DST_IDX parent,
00231 DST_IDX inl_routine,
00232 IPO_SYMTAB *symtab,
00233 DST_TYPE caller_file_dst,
00234 DST_TYPE callee_file_dst,
00235 mUINT16 parent_file_index,
00236 BOOL inlined,
00237 MEM_POOL *caller_file_m,
00238 MEM_POOL *callee_file_m)
00239 {
00240 DST_INFO_IDX child_idx;
00241 USRCPOS decl;
00242
00243 USRCPOS_clear(decl);
00244
00245
00246
00247 Scope_tab = symtab->Get_orig_scope_tab();
00248 CURRENT_SYMTAB = symtab->Get_orig_level();
00249
00250
00251
00252
00253 #if (!defined(_LEGO_CLONER))
00254 Current_DST = callee_file_dst;
00255 #endif
00256 for (child_idx = DST_first_child(inl_routine); !DST_IS_NULL(child_idx);
00257 child_idx = DST_INFO_sibling(DST_INFO_IDX_TO_PTR(child_idx))) {
00258 DST_INFO_IDX idx;
00259
00260 switch (DST_INFO_tag(DST_INFO_IDX_TO_PTR(child_idx))) {
00261 case DW_TAG_formal_parameter:
00262 {
00263
00264 ST *param_st;
00265 DST_ASSOC_INFO parm;
00266
00267 #if (!defined(_LEGO_CLONER))
00268 Current_DST = callee_file_dst;
00269 #endif
00270
00271 DST_FORMAL_PARAMETER *attr = DST_ATTR_IDX_TO_PTR(DST_INFO_attributes (DST_INFO_IDX_TO_PTR(child_idx)), DST_FORMAL_PARAMETER);
00272
00273 param_st = symtab->Get_Cloned_ST(&St_Table[
00274 DST_ASSOC_INFO_st_idx(DST_FORMAL_PARAMETER_st (attr))]);
00275
00276 if (param_st) {
00277 char *name = NULL;
00278 DST_ASSOC_INFO_st_idx(parm) = ST_st_idx(param_st);
00279 decl = DST_FORMAL_PARAMETER_decl(attr);
00280
00281 name = DST_STR_IDX_TO_PTR(DST_FORMAL_PARAMETER_name(attr));
00282 #if (!defined(_LEGO_CLONER))
00283 Current_DST = caller_file_dst;
00284 #endif
00285 if (parent_file_index)
00286 USRCPOS_filenum(decl) = parent_file_index;
00287
00288 idx = DST_mk_formal_parameter(decl,
00289 name,
00290 DST_INVALID_IDX,
00291 ST_st_idx(param_st),
00292 GET_ABSTRACT_ORIGIN(child_idx),
00293 DST_INVALID_IDX,
00294 FALSE,
00295 FALSE,
00296 FALSE,
00297 FALSE);
00298 DST_append_child(parent, idx);
00299 }
00300 break;
00301 }
00302 case DW_TAG_variable:
00303 {
00304 if (!(DST_IS_declaration(DST_INFO_flag(DST_INFO_IDX_TO_PTR(child_idx)))) &&
00305 DST_IS_automatic(DST_INFO_flag(DST_INFO_IDX_TO_PTR(child_idx)))) {
00306
00307
00308 ST *local_st;
00309 DST_ASSOC_INFO var;
00310
00311 #if (!defined(_LEGO_CLONER))
00312 Current_DST = callee_file_dst;
00313 #endif
00314
00315 DST_VARIABLE *attr = DST_ATTR_IDX_TO_PTR(DST_INFO_attributes(DST_INFO_IDX_TO_PTR(child_idx)), DST_VARIABLE);
00316
00317 local_st = symtab->Get_Cloned_ST(&St_Table[
00318 DST_ASSOC_INFO_st_idx(DST_VARIABLE_def_st (attr))]);
00319 if (local_st) {
00320 char *name = NULL;
00321
00322 DST_ASSOC_INFO_st_idx(var) = ST_st_idx(local_st);
00323
00324 decl = DST_VARIABLE_constant_decl(attr);
00325
00326 name = DST_STR_IDX_TO_PTR(DST_VARIABLE_def_name(attr));
00327 #if (!defined(_LEGO_CLONER))
00328 Current_DST = caller_file_dst;
00329 #endif
00330 if (parent_file_index)
00331 USRCPOS_filenum(decl) = parent_file_index;
00332
00333 idx = DST_mk_variable(decl,
00334 name,
00335 DST_INVALID_IDX,
00336 0,
00337 ST_st_idx(local_st),
00338 GET_ABSTRACT_ORIGIN(child_idx),
00339 FALSE,
00340 FALSE,
00341 FALSE,
00342 FALSE);
00343 DST_append_child(parent, idx);
00344 }
00345 }
00346 break;
00347 }
00348 case DW_TAG_label:
00349 {
00350 ST_IDX lbl;
00351 char *label_name = NULL;
00352
00353 #if (!defined(_LEGO_CLONER))
00354 Current_DST = callee_file_dst;
00355 #endif
00356
00357 DST_LABEL *attr = DST_ATTR_IDX_TO_PTR(DST_INFO_attributes(DST_INFO_IDX_TO_PTR(child_idx)), DST_LABEL);
00358
00359 lbl = make_ST_IDX(
00360 DST_ASSOC_INFO_st_index(DST_LABEL_low_pc (attr))
00361 + symtab->Get_cloned_label_last_idx(),
00362 symtab->Get_cloned_level() );
00363
00364 #if (!defined(_STANDALONE_INLINER) && !defined(_LEGO_CLONER))
00365
00366 if (DST_IS_NULL(DST_LABEL_name(attr))) {
00367 label_name = create_ipa_internal_name();
00368 if (label_name) {
00369
00370 MEM_POOL *old_src_pool = MEM_src_pool_ptr;
00371 if (inlined && (caller_file_m != callee_file_m)) {
00372 MEM_src_pool_ptr = callee_file_m;
00373 }
00374 DST_label_add_name(attr, label_name);
00375 MEM_src_pool_ptr = old_src_pool;
00376 }
00377 }
00378 else
00379 label_name = DST_STR_IDX_TO_PTR(DST_LABEL_name(attr));
00380 Current_DST = caller_file_dst;
00381 #endif
00382
00383 idx = DST_mk_label(label_name, lbl,
00384 GET_ABSTRACT_ORIGIN(child_idx));
00385
00386 DST_append_child(parent, idx);
00387 break;
00388 }
00389
00390 case DW_TAG_inlined_subroutine:
00391 {
00392
00393 #if (!defined(_LEGO_CLONER))
00394 Current_DST = callee_file_dst;
00395 #endif
00396
00397 DST_INLINED_SUBROUTINE *attr = DST_ATTR_IDX_TO_PTR(DST_INFO_attributes(DST_INFO_IDX_TO_PTR(child_idx)), DST_INLINED_SUBROUTINE);
00398
00399 LABEL_IDX b_lbl = DST_ASSOC_INFO_st_index(DST_INLINED_SUBROUTINE_low_pc (attr)) + symtab->Get_cloned_label_last_idx();
00400 LABEL_IDX e_lbl = DST_ASSOC_INFO_st_index(DST_INLINED_SUBROUTINE_high_pc (attr)) + symtab->Get_cloned_label_last_idx();
00401
00402 (void)DST_enter_inlined_subroutine(parent,
00403 child_idx,
00404 b_lbl,
00405 e_lbl,
00406 caller_file_dst,
00407 callee_file_dst,
00408 symtab,
00409 caller_file_m,
00410 callee_file_m,
00411 parent_file_index);
00412 break;
00413 }
00414 case DW_TAG_lexical_block:
00415 {
00416 ST_IDX low_pc;
00417 ST_IDX high_pc;
00418
00419 #if (!defined(_LEGO_CLONER))
00420 Current_DST = callee_file_dst;
00421 #endif
00422
00423 DST_LEXICAL_BLOCK *attr = DST_ATTR_IDX_TO_PTR(DST_INFO_attributes(DST_INFO_IDX_TO_PTR(child_idx)), DST_LEXICAL_BLOCK);
00424
00425 low_pc = make_ST_IDX(
00426 DST_ASSOC_INFO_st_index(DST_LEXICAL_BLOCK_low_pc (attr))
00427 + symtab->Get_cloned_label_last_idx(),
00428 symtab->Get_cloned_level() );
00429
00430 high_pc = make_ST_IDX(
00431 DST_ASSOC_INFO_st_index(DST_LEXICAL_BLOCK_high_pc (attr))
00432 + symtab->Get_cloned_label_last_idx(),
00433 symtab->Get_cloned_level() );
00434
00435 char *block_name = NULL;
00436
00437 #if ( !defined(_STANDALONE_INLINER) && !defined(_LEGO_CLONER))
00438
00439 if (DST_IS_NULL(DST_LEXICAL_BLOCK_name(attr))) {
00440 block_name = create_ipa_internal_name();
00441 if (block_name) {
00442
00443 MEM_POOL *old_src_pool = MEM_src_pool_ptr;
00444 if (inlined && (caller_file_m != callee_file_m)) {
00445 MEM_src_pool_ptr = callee_file_m;
00446 }
00447 DST_lexical_block_add_name(attr, block_name);
00448 MEM_src_pool_ptr = old_src_pool;
00449 }
00450 }
00451 else
00452 block_name = DST_STR_IDX_TO_PTR(DST_LEXICAL_BLOCK_name(attr));
00453 Current_DST = caller_file_dst;
00454 #endif
00455
00456 idx = DST_mk_lexical_block(block_name,
00457 low_pc,
00458 high_pc,
00459 GET_ABSTRACT_ORIGIN(child_idx));
00460
00461 DST_append_child(parent, idx);
00462
00463 (void)DST_enter_cloned_childs(idx, child_idx,
00464 symtab, caller_file_dst, callee_file_dst,
00465 parent_file_index, inlined, caller_file_m, callee_file_m);
00466
00467 break;
00468 }
00469
00470 case DW_TAG_unspecified_parameters:
00471 {
00472 if (inlined)
00473 break;
00474 else {
00475 #if (!defined(_LEGO_CLONER))
00476 Current_DST = callee_file_dst;
00477 #endif
00478 DST_UNSPECIFIED_PARAMETERS *attr = DST_ATTR_IDX_TO_PTR(DST_INFO_attributes (DST_INFO_IDX_TO_PTR(child_idx)), DST_UNSPECIFIED_PARAMETERS);
00479
00480 #if (!defined(_LEGO_CLONER))
00481 Current_DST = caller_file_dst;
00482 #endif
00483
00484 idx = DST_mk_unspecified_parameters(
00485 DST_UNSPECIFIED_PARAMETERS_decl(attr),
00486 GET_ABSTRACT_ORIGIN(child_idx));
00487
00488 DST_append_child(parent, idx);
00489 break;
00490 }
00491 }
00492
00493 case DW_TAG_typedef:
00494 {
00495 if (inlined)
00496 break;
00497 else {
00498 #if (!defined(_LEGO_CLONER))
00499 Current_DST = callee_file_dst;
00500 #endif
00501
00502 DST_TYPEDEF *attr = DST_ATTR_IDX_TO_PTR(DST_INFO_attributes (DST_INFO_IDX_TO_PTR(child_idx)), DST_TYPEDEF);
00503
00504 #if (!defined(_LEGO_CLONER))
00505 Current_DST = caller_file_dst;
00506 #endif
00507
00508 idx = DST_mk_typedef(
00509 DST_TYPEDEF_decl(attr),
00510 NULL,
00511 DST_TYPEDEF_type(attr),
00512 GET_ABSTRACT_ORIGIN(child_idx));
00513
00514 DST_append_child(parent, idx);
00515 break;
00516 }
00517 }
00518
00519 case DW_TAG_array_type:
00520 {
00521 if (inlined)
00522 break;
00523 else {
00524 #if (!defined(_LEGO_CLONER))
00525 Current_DST = callee_file_dst;
00526 #endif
00527
00528 DST_ARRAY_TYPE *attr = DST_ATTR_IDX_TO_PTR(DST_INFO_attributes (DST_INFO_IDX_TO_PTR(child_idx)), DST_ARRAY_TYPE);
00529
00530 #if (!defined(_LEGO_CLONER))
00531 Current_DST = caller_file_dst;
00532 #endif
00533
00534 idx = DST_mk_array_type(
00535 DST_ARRAY_TYPE_decl(attr),
00536 NULL,
00537 DST_ARRAY_TYPE_type(attr),
00538 DST_ARRAY_TYPE_byte_size(attr),
00539 GET_ABSTRACT_ORIGIN(child_idx),
00540 FALSE);
00541
00542 DST_append_child(parent, idx);
00543 break;
00544 }
00545 }
00546
00547 case DW_TAG_structure_type:
00548 {
00549 if (inlined)
00550 break;
00551 else {
00552 #if (!defined(_LEGO_CLONER))
00553 Current_DST = callee_file_dst;
00554 #endif
00555
00556 DST_STRUCTURE_TYPE *attr = DST_ATTR_IDX_TO_PTR(DST_INFO_attributes (DST_INFO_IDX_TO_PTR(child_idx)), DST_STRUCTURE_TYPE);
00557
00558 #if (!defined(_STANDALONE_INLINER) && !defined(_LEGO_CLONER))
00559 Current_DST = caller_file_dst;
00560 #endif
00561
00562 idx = DST_mk_structure_type(
00563 DST_STRUCTURE_TYPE_decl(attr),
00564 NULL,
00565 DST_STRUCTURE_TYPE_byte_size(attr),
00566 GET_ABSTRACT_ORIGIN(child_idx),
00567 FALSE);
00568
00569 DST_append_child(parent, idx);
00570 break;
00571 }
00572 }
00573
00574 case DW_TAG_union_type:
00575 {
00576 if (inlined)
00577 break;
00578 else {
00579 #if (!defined(_STANDALONE_INLINER) && !defined(_LEGO_CLONER))
00580 Current_DST = callee_file_dst;
00581 #endif
00582
00583 DST_UNION_TYPE *attr = DST_ATTR_IDX_TO_PTR(DST_INFO_attributes (DST_INFO_IDX_TO_PTR(child_idx)), DST_UNION_TYPE);
00584
00585 #if (!defined(_STANDALONE_INLINER) && !defined(_LEGO_CLONER))
00586 Current_DST = caller_file_dst;
00587 #endif
00588
00589 idx = DST_mk_union_type(
00590 DST_UNION_TYPE_decl(attr),
00591 NULL,
00592 DST_UNION_TYPE_byte_size(attr),
00593 GET_ABSTRACT_ORIGIN(child_idx),
00594 FALSE);
00595
00596 DST_append_child(parent, idx);
00597 }
00598 }
00599
00600 case DW_TAG_class_type:
00601 {
00602 if (inlined)
00603 break;
00604 else {
00605 #if (!defined(_STANDALONE_INLINER) && !defined(_LEGO_CLONER))
00606 Current_DST = callee_file_dst;
00607 #endif
00608
00609 DST_CLASS_TYPE *attr = DST_ATTR_IDX_TO_PTR(DST_INFO_attributes (DST_INFO_IDX_TO_PTR(child_idx)), DST_CLASS_TYPE);
00610
00611 #if (!defined(_STANDALONE_INLINER) && !defined(_LEGO_CLONER))
00612 Current_DST = caller_file_dst;
00613 #endif
00614
00615 idx = DST_mk_class_type(
00616 DST_CLASS_TYPE_decl(attr),
00617 NULL,
00618 DST_CLASS_TYPE_byte_size(attr),
00619 GET_ABSTRACT_ORIGIN(child_idx),
00620 FALSE);
00621
00622 DST_append_child(parent, idx);
00623 }
00624 }
00625
00626 case DW_TAG_enumeration_type:
00627 {
00628 if (inlined)
00629 break;
00630 else {
00631 #if (!defined(_STANDALONE_INLINER) && !defined(_LEGO_CLONER))
00632 Current_DST = callee_file_dst;
00633 #endif
00634
00635 DST_ENUMERATION_TYPE *attr = DST_ATTR_IDX_TO_PTR(DST_INFO_attributes (DST_INFO_IDX_TO_PTR(child_idx)), DST_ENUMERATION_TYPE);
00636
00637 #if (!defined(_STANDALONE_INLINER) && !defined(_LEGO_CLONER))
00638 Current_DST = caller_file_dst;
00639 #endif
00640
00641 idx = DST_mk_enumeration_type(
00642 DST_ENUMERATION_TYPE_decl(attr),
00643 NULL,
00644 DST_ENUMERATION_TYPE_byte_size(attr),
00645 GET_ABSTRACT_ORIGIN(child_idx),
00646 FALSE);
00647
00648 DST_append_child(parent, idx);
00649 }
00650 }
00651
00652 case DW_TAG_subroutine_type:
00653 {
00654 if (inlined)
00655 break;
00656 else {
00657 #if (!defined(_STANDALONE_INLINER) && !defined(_LEGO_CLONER))
00658 Current_DST = callee_file_dst;
00659 #endif
00660
00661 DST_SUBROUTINE_TYPE *attr = DST_ATTR_IDX_TO_PTR(DST_INFO_attributes (DST_INFO_IDX_TO_PTR(child_idx)), DST_SUBROUTINE_TYPE);
00662
00663 #if (!defined(_STANDALONE_INLINER) && !defined(_LEGO_CLONER))
00664 Current_DST = caller_file_dst;
00665 #endif
00666
00667 idx = DST_mk_subroutine_type(
00668 DST_SUBROUTINE_TYPE_decl(attr),
00669 NULL,
00670 DST_SUBROUTINE_TYPE_type(attr),
00671 GET_ABSTRACT_ORIGIN(child_idx),
00672 FALSE);
00673
00674 DST_append_child(parent, idx);
00675 break;
00676 }
00677 }
00678 }
00679 #if (!defined(_STANDALONE_INLINER) && !defined(_LEGO_CLONER))
00680 Current_DST = callee_file_dst;
00681 #endif
00682 }
00683 }
00684
00685
00686
00687 #if (!defined(_LEGO_CLONER))
00688 mUINT16
00689 DST_get_cross_file_id(DST_IDX parent,
00690 DST_IDX inl_routine,
00691 DST_TYPE caller_file_dst,
00692 DST_TYPE callee_file_dst)
00693 {
00694 DST_TYPE old_Current_DST = Current_DST;
00695 char *filename = 0;
00696 char *dirname = 0;
00697 UINT64 file_size;
00698 UINT64 fmod_time;
00699 mUINT16 ret_val = 0;
00700
00701 Current_DST = caller_file_dst;
00702
00703 DST_SUBPROGRAM *attr =
00704 DST_ATTR_IDX_TO_PTR (DST_INFO_attributes (DST_INFO_IDX_TO_PTR(parent)),
00705 DST_SUBPROGRAM);
00706
00707 Current_DST = callee_file_dst;
00708 DST_INFO_IDX abstract_origin = get_abstract_origin(inl_routine);
00709
00710 DST_SUBPROGRAM *inl_attr = DST_ATTR_IDX_TO_PTR (DST_INFO_attributes (DST_INFO_IDX_TO_PTR (abstract_origin)),
00711 DST_SUBPROGRAM);
00712
00713 filename = DST_get_file (USRCPOS_filenum (DST_SUBPROGRAM_decl_decl (inl_attr)),
00714 &file_size, &fmod_time, &dirname);
00715
00716 if (filename) {
00717
00718 Current_DST = caller_file_dst;
00719
00720
00721 ret_val = DST_get_cross_inlined_file_id (filename, dirname,
00722 file_size, fmod_time);
00723 }
00724 Current_DST = old_Current_DST;
00725
00726 return (ret_val);
00727 }
00728 #endif // !defined(_LEGO_CLONER)
00729
00730
00731
00732 void
00733 DST_enter_inlined_subroutine(DST_IDX parent,
00734 DST_IDX inl_routine,
00735 LABEL_IDX begin_label,
00736 LABEL_IDX end_label,
00737 DST_TYPE caller_file_dst,
00738 DST_TYPE callee_file_dst,
00739 IPO_SYMTAB *symtab,
00740 MEM_POOL *caller_file_m,
00741 MEM_POOL *callee_file_m,
00742 mUINT16 cross_file_id)
00743 {
00744 DST_INFO_IDX idx;
00745 SCOPE *old_scope = symtab->Get_orig_scope_tab();
00746 SYMTAB_IDX old_callee_level = symtab->Get_orig_level();
00747 ST_IDX low_pc, high_pc;
00748
00749 Scope_tab = symtab->Get_orig_scope_tab();
00750 CURRENT_SYMTAB = symtab->Get_orig_level();
00751
00752 #if !defined(_LEGO_CLONER)
00753 DST_TYPE old_Current_DST = Current_DST;
00754 Current_DST = callee_file_dst;
00755 #endif
00756 DST_INFO_IDX abstract_origin = get_abstract_origin(inl_routine);
00757 mUINT16 file_index = cross_file_id;
00758
00759 #if !defined(_LEGO_CLONER)
00760 Current_DST = caller_file_dst;
00761 #endif
00762
00763
00764 low_pc = make_ST_IDX(
00765 begin_label,
00766 symtab->Get_cloned_level() );
00767
00768 high_pc = make_ST_IDX(
00769 end_label,
00770 symtab->Get_cloned_level() );
00771
00772 if (caller_file_dst == callee_file_dst) {
00773 idx = DST_mk_inlined_subroutine (low_pc, high_pc,
00774 abstract_origin);
00775
00776 DST_append_child(parent, idx);
00777
00778 DST_enter_cloned_childs (idx, inl_routine, symtab,
00779 caller_file_dst, callee_file_dst,
00780 file_index, TRUE, caller_file_m,
00781 callee_file_m);
00782 }
00783 #if (!defined(_LEGO_CLONER))
00784 else {
00785 DST_SUBPROGRAM *attr;
00786
00787 attr = DST_ATTR_IDX_TO_PTR (DST_INFO_attributes (DST_INFO_IDX_TO_PTR(parent)),
00788 DST_SUBPROGRAM);
00789 char *filename;
00790 char *routine_name;
00791 char *dirname;
00792 UINT64 file_size;
00793 UINT64 fmod_time;
00794
00795 Current_DST = callee_file_dst;
00796
00797 DST_SUBPROGRAM *inl_attr = DST_ATTR_IDX_TO_PTR(DST_INFO_attributes(DST_INFO_IDX_TO_PTR(abstract_origin)),
00798 DST_SUBPROGRAM);
00799
00800 filename = DST_get_file (USRCPOS_filenum (DST_SUBPROGRAM_decl_decl(inl_attr)),
00801 &file_size, &fmod_time, &dirname);
00802
00803 routine_name = DST_STR_IDX_TO_PTR(DST_SUBPROGRAM_decl_name(inl_attr));
00804 Current_DST = caller_file_dst;
00805
00806 if (filename != NULL) {
00807
00808 idx = DST_mk_cross_inlined_subroutine(low_pc,
00809 high_pc,
00810 routine_name,
00811 &file_index,
00812 file_size,
00813 fmod_time,
00814 DST_SUBPROGRAM_decl_decl(attr),
00815 filename,
00816 dirname);
00817
00818 DST_append_child(parent, idx);
00819
00820 DST_enter_cloned_childs(idx, inl_routine, symtab,
00821 caller_file_dst, callee_file_dst,
00822 file_index, TRUE, caller_file_m,
00823 callee_file_m);
00824 }
00825 }
00826 #endif // !defined(_LEGO_CLONER)
00827
00828
00829 CURRENT_SYMTAB = old_callee_level;
00830 Scope_tab = old_scope;
00831
00832 #if (!defined(_LEGO_CLONER))
00833 Current_DST = old_Current_DST;
00834 #endif
00835 }
00836
00837
00838
00839 DST_IDX
00840 DST_enter_cloned_subroutine(DST_IDX parent,
00841 DST_IDX orig_node,
00842 ST *cloned_st,
00843 DST_TYPE cur_file_dst,
00844 IPO_SYMTAB *sym)
00845 {
00846
00847 DST_ASSOC_INFO subst;
00848 DST_INFO_IDX idx = DST_INVALID_INIT;
00849 DST_SUBPROGRAM *attr =
00850 DST_ATTR_IDX_TO_PTR(DST_INFO_attributes(DST_INFO_IDX_TO_PTR(orig_node)), DST_SUBPROGRAM);
00851
00852 Scope_tab = sym->Get_orig_scope_tab();
00853 CURRENT_SYMTAB = sym->Get_orig_level();
00854
00855 if (cloned_st) {
00856
00857 DST_ASSOC_INFO_st_idx(subst) = ST_st_idx(cloned_st);
00858
00859 idx = DST_mk_cloned_subprogram(DST_SUBPROGRAM_def_decl(attr),
00860 ST_name(cloned_st),
00861 DST_SUBPROGRAM_def_type(attr),
00862 orig_node,
00863 DST_ASSOC_INFO_st_idx(subst),
00864 DST_SUBPROGRAM_def_inline(attr),
00865 DST_SUBPROGRAM_def_virtuality(attr));
00866
00867 DST_append_child(parent, idx);
00868
00869 DST_enter_cloned_childs(idx, orig_node, sym, cur_file_dst,
00870 cur_file_dst, 0, FALSE, NULL, NULL);
00871 }
00872
00873 return idx;
00874 }
00875
00876