ClangExpressionDeclMap.h revision bdcb6abaa287df2c5f312c51d993c1d0b0cb120c
1//===-- ClangExpressionDeclMap.h --------------------------------*- C++ -*-===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9 10#ifndef liblldb_ClangExpressionDeclMap_h_ 11#define liblldb_ClangExpressionDeclMap_h_ 12 13// C Includes 14#include <signal.h> 15#include <stdint.h> 16 17// C++ Includes 18#include <vector> 19 20// Other libraries and framework includes 21// Project includes 22#include "llvm/ADT/DenseMap.h" 23#include "lldb/lldb-include.h" 24#include "lldb/Core/ClangForward.h" 25#include "lldb/Core/Value.h" 26#include "lldb/Expression/ClangExpressionVariable.h" 27#include "lldb/Symbol/TaggedASTType.h" 28#include "lldb/Symbol/SymbolContext.h" 29#include "lldb/Target/ExecutionContext.h" 30 31namespace lldb_private { 32 33//---------------------------------------------------------------------- 34/// @class ClangExpressionDeclMap ClangExpressionDeclMap.h "lldb/Expression/ClangExpressionDeclMap.h" 35/// @brief Manages named entities that are defined in LLDB's debug information. 36/// 37/// The Clang parser uses the ClangASTSource as an interface to request named 38/// entities from outside an expression. The ClangASTSource reports back, listing 39/// all possible objects corresponding to a particular name. But it in turn 40/// relies on ClangExpressionDeclMap, which performs several important functions. 41/// 42/// First, it records what variables and functions were looked up and what Decls 43/// were returned for them. 44/// 45/// Second, it constructs a struct on behalf of IRForTarget, recording which 46/// variables should be placed where and relaying this information back so that 47/// IRForTarget can generate context-independent code. 48/// 49/// Third, it "materializes" this struct on behalf of the expression command, 50/// finding the current values of each variable and placing them into the 51/// struct so that it can be passed to the JITted version of the IR. 52/// 53/// Fourth and finally, it "dematerializes" the struct after the JITted code has 54/// has executed, placing the new values back where it found the old ones. 55//---------------------------------------------------------------------- 56class ClangExpressionDeclMap 57{ 58public: 59 //------------------------------------------------------------------ 60 /// Constructor 61 /// 62 /// Initializes class variables. 63 /// 64 /// @param[in] keep_result_in_memory 65 /// If true, inhibits the normal deallocation of the memory for 66 /// the result persistent variable, and instead marks the variable 67 /// as persisting. 68 //------------------------------------------------------------------ 69 ClangExpressionDeclMap (bool keep_result_in_memory); 70 71 //------------------------------------------------------------------ 72 /// Destructor 73 //------------------------------------------------------------------ 74 ~ClangExpressionDeclMap (); 75 76 //------------------------------------------------------------------ 77 /// Enable the state needed for parsing and IR transformation. 78 /// 79 /// @param[in] exe_ctx 80 /// The execution context to use when finding types for variables. 81 /// Also used to find a "scratch" AST context to store result types. 82 //------------------------------------------------------------------ 83 void 84 WillParse (ExecutionContext &exe_ctx); 85 86 //------------------------------------------------------------------ 87 /// Disable the state needed for parsing and IR transformation. 88 //------------------------------------------------------------------ 89 void 90 DidParse (); 91 92 //------------------------------------------------------------------ 93 /// [Used by IRForTarget] Get a new result variable name of the form 94 /// $n, where n is a natural number starting with 0. 95 /// 96 /// @param[in] name 97 /// The std::string to place the name into. 98 //------------------------------------------------------------------ 99 const ConstString & 100 GetPersistentResultName (); 101 102 clang::NamespaceDecl * 103 AddNamespace (NameSearchContext &context, 104 const ClangNamespaceDecl &namespace_decl); 105 106 //------------------------------------------------------------------ 107 /// [Used by IRForTarget] Get a constant variable given a name, 108 /// a type, and an llvm::APInt. 109 /// 110 /// @param[in] name 111 /// The name of the variable 112 /// 113 /// @param[in] type 114 /// The type of the variable, which will be imported into the 115 /// target's AST context 116 /// 117 /// @param[in] value 118 /// The value of the variable 119 /// 120 /// @return 121 /// The created variable 122 //------------------------------------------------------------------ 123 lldb::ClangExpressionVariableSP 124 BuildIntegerVariable (const ConstString &name, 125 lldb_private::TypeFromParser type, 126 const llvm::APInt& value); 127 128 //------------------------------------------------------------------ 129 /// [Used by IRForTarget] Add a variable to the list of persistent 130 /// variables for the process. 131 /// 132 /// @param[in] decl 133 /// The Clang declaration for the persistent variable, used for 134 /// lookup during parsing. 135 /// 136 /// @param[in] name 137 /// The name of the persistent variable, usually $something. 138 /// 139 /// @param[in] type 140 /// The type of the variable, in the Clang parser's context. 141 /// 142 /// @return 143 /// True on success; false otherwise. 144 //------------------------------------------------------------------ 145 bool 146 AddPersistentVariable (const clang::NamedDecl *decl, 147 const ConstString &name, 148 TypeFromParser type, 149 bool is_result, 150 bool is_lvalue); 151 152 //------------------------------------------------------------------ 153 /// [Used by IRForTarget] Add a variable to the struct that needs to 154 /// be materialized each time the expression runs. 155 /// 156 /// @param[in] decl 157 /// The Clang declaration for the variable. 158 /// 159 /// @param[in] name 160 /// The name of the variable. 161 /// 162 /// @param[in] value 163 /// The LLVM IR value for this variable. 164 /// 165 /// @param[in] size 166 /// The size of the variable in bytes. 167 /// 168 /// @param[in] alignment 169 /// The required alignment of the variable in bytes. 170 /// 171 /// @return 172 /// True on success; false otherwise. 173 //------------------------------------------------------------------ 174 bool 175 AddValueToStruct (const clang::NamedDecl *decl, 176 const ConstString &name, 177 llvm::Value *value, 178 size_t size, 179 off_t alignment); 180 181 //------------------------------------------------------------------ 182 /// [Used by IRForTarget] Finalize the struct, laying out the position 183 /// of each object in it. 184 /// 185 /// @return 186 /// True on success; false otherwise. 187 //------------------------------------------------------------------ 188 bool 189 DoStructLayout (); 190 191 //------------------------------------------------------------------ 192 /// [Used by IRForTarget] Get general information about the laid-out 193 /// struct after DoStructLayout() has been called. 194 /// 195 /// @param[out] num_elements 196 /// The number of elements in the struct. 197 /// 198 /// @param[out] size 199 /// The size of the struct, in bytes. 200 /// 201 /// @param[out] alignment 202 /// The alignment of the struct, in bytes. 203 /// 204 /// @return 205 /// True if the information could be retrieved; false otherwise. 206 //------------------------------------------------------------------ 207 bool 208 GetStructInfo (uint32_t &num_elements, 209 size_t &size, 210 off_t &alignment); 211 212 //------------------------------------------------------------------ 213 /// [Used by IRForTarget] Get specific information about one field 214 /// of the laid-out struct after DoStructLayout() has been called. 215 /// 216 /// @param[out] decl 217 /// The parsed Decl for the field, as generated by ClangASTSource 218 /// on ClangExpressionDeclMap's behalf. In the case of the result 219 /// value, this will have the name $__lldb_result even if the 220 /// result value ends up having the name $1. This is an 221 /// implementation detail of IRForTarget. 222 /// 223 /// @param[out] value 224 /// The IR value for the field (usually a GlobalVariable). In 225 /// the case of the result value, this will have the correct 226 /// name ($1, for instance). This is an implementation detail 227 /// of IRForTarget. 228 /// 229 /// @param[out] offset 230 /// The offset of the field from the beginning of the struct. 231 /// As long as the struct is aligned according to its required 232 /// alignment, this offset will align the field correctly. 233 /// 234 /// @param[out] name 235 /// The name of the field as used in materialization. 236 /// 237 /// @param[in] index 238 /// The index of the field about which information is requested. 239 /// 240 /// @return 241 /// True if the information could be retrieved; false otherwise. 242 //------------------------------------------------------------------ 243 bool 244 GetStructElement (const clang::NamedDecl *&decl, 245 llvm::Value *&value, 246 off_t &offset, 247 ConstString &name, 248 uint32_t index); 249 250 //------------------------------------------------------------------ 251 /// [Used by IRForTarget] Get information about a function given its 252 /// Decl. 253 /// 254 /// @param[in] decl 255 /// The parsed Decl for the Function, as generated by ClangASTSource 256 /// on ClangExpressionDeclMap's behalf. 257 /// 258 /// @param[out] value 259 /// A pointer to the address where a Value for the function's address 260 /// can be stored. IRForTarget typically places a ConstantExpr here. 261 /// 262 /// @param[out] ptr 263 /// The absolute address of the function in the target. 264 /// 265 /// @return 266 /// True if the information could be retrieved; false otherwise. 267 //------------------------------------------------------------------ 268 bool 269 GetFunctionInfo (const clang::NamedDecl *decl, 270 llvm::Value**& value, 271 uint64_t &ptr); 272 273 //------------------------------------------------------------------ 274 /// [Used by IRForTarget] Get the address of a function given nothing 275 /// but its name. Some functions are needed but didn't get Decls made 276 /// during parsing -- specifically, sel_registerName is never called 277 /// in the generated IR but we need to call it nonetheless. 278 /// 279 /// @param[in] name 280 /// The name of the function. 281 /// 282 /// @param[out] ptr 283 /// The absolute address of the function in the target. 284 /// 285 /// @return 286 /// True if the address could be retrieved; false otherwise. 287 //------------------------------------------------------------------ 288 bool 289 GetFunctionAddress (const ConstString &name, 290 uint64_t &ptr); 291 292 //------------------------------------------------------------------ 293 /// [Used by IRForTarget] Get the address of a symbol given nothing 294 /// but its name. 295 /// 296 /// @param[in] name 297 /// The name of the symbol. 298 /// 299 /// @param[out] ptr 300 /// The absolute address of the function in the target. 301 /// 302 /// @return 303 /// True if the address could be retrieved; false otherwise. 304 //------------------------------------------------------------------ 305 bool 306 GetSymbolAddress (const ConstString &name, 307 uint64_t &ptr); 308 309 //------------------------------------------------------------------ 310 /// [Used by CommandObjectExpression] Materialize the entire struct 311 /// at a given address, which should be aligned as specified by 312 /// GetStructInfo(). 313 /// 314 /// @param[in] exe_ctx 315 /// The execution context at which to dump the struct. 316 /// 317 /// @param[in] struct_address 318 /// The address at which the struct should be written. 319 /// 320 /// @param[in] error 321 /// An Error to populate with any messages related to 322 /// materializing the struct. 323 /// 324 /// @return 325 /// True on success; false otherwise. 326 //------------------------------------------------------------------ 327 bool 328 Materialize (ExecutionContext &exe_ctx, 329 lldb::addr_t &struct_address, 330 Error &error); 331 332 //------------------------------------------------------------------ 333 /// [Used by CommandObjectExpression] Get the "this" pointer 334 /// from a given execution context. 335 /// 336 /// @param[out] object_ptr 337 /// The this pointer. 338 /// 339 /// @param[in] object_name 340 /// The name of the object pointer -- "this," "self," or similar 341 /// depending on language 342 /// 343 /// @param[in] exe_ctx 344 /// The execution context at which to dump the struct. 345 /// 346 /// @param[in] error 347 /// An Error to populate with any messages related to 348 /// finding the "this" pointer. 349 /// 350 /// @param[in] suppress_type_check 351 /// True if the type is not needed. 352 /// 353 /// @return 354 /// True on success; false otherwise. 355 //------------------------------------------------------------------ 356 bool 357 GetObjectPointer (lldb::addr_t &object_ptr, 358 ConstString &object_name, 359 ExecutionContext &exe_ctx, 360 Error &error, 361 bool suppress_type_check = false); 362 363 //------------------------------------------------------------------ 364 /// [Used by CommandObjectExpression] Pretty-print a materialized 365 /// struct, which must have been materialized by Materialize(), 366 /// byte for byte on a given stream. 367 /// 368 /// @param[in] exe_ctx 369 /// The execution context from which to read the struct. 370 /// 371 /// @param[in] s 372 /// The stream on which to write the pretty-printed output. 373 /// 374 /// @param[in] error 375 /// An Error to populate with any messages related to 376 /// pretty-printing the struct. 377 /// 378 /// @return 379 /// True on success; false otherwise. 380 //------------------------------------------------------------------ 381 bool 382 DumpMaterializedStruct (ExecutionContext &exe_ctx, 383 Stream &s, 384 Error &error); 385 386 //------------------------------------------------------------------ 387 /// [Used by CommandObjectExpression] Deaterialize the entire struct. 388 /// 389 /// @param[in] exe_ctx 390 /// The execution context from which to read the struct. 391 /// 392 /// @param[out] result 393 /// A ClangExpressionVariable containing the result of the 394 /// expression, for potential re-use. 395 /// 396 /// @param[in] error 397 /// An Error to populate with any messages related to 398 /// dematerializing the struct. 399 /// 400 /// @return 401 /// True on success; false otherwise. 402 //------------------------------------------------------------------ 403 bool 404 Dematerialize (ExecutionContext &exe_ctx, 405 lldb::ClangExpressionVariableSP &result_sp, 406 Error &error); 407 408 //------------------------------------------------------------------ 409 /// [Used by ClangASTSource] Find all entities matching a given name, 410 /// using a NameSearchContext to make Decls for them. 411 /// 412 /// @param[in] context 413 /// The NameSearchContext that can construct Decls for this name. 414 /// 415 /// @param[in] name 416 /// The name as a plain C string. The NameSearchContext contains 417 /// a DeclarationName for the name so at first the name may seem 418 /// redundant, but ClangExpressionDeclMap operates in RTTI land so 419 /// it can't access DeclarationName. 420 /// 421 /// @return 422 /// True on success; false otherwise. 423 //------------------------------------------------------------------ 424 void 425 GetDecls (NameSearchContext &context, 426 const ConstString &name); 427 428 //------------------------------------------------------------------ 429 /// [Used by ClangASTSource] Report whether a $__lldb variable has 430 /// been searched for yet. This is the trigger for beginning to 431 /// actually look for externally-defined names. (Names that come 432 /// before this are typically the names of built-ins that don't need 433 /// to be looked up.) 434 /// 435 /// @return 436 /// True if a $__lldb variable has been found. 437 //------------------------------------------------------------------ 438 bool 439 GetLookupsEnabled () const 440 { 441 assert(m_parser_vars.get()); 442 return m_parser_vars->m_enable_lookups; 443 } 444 445 bool 446 GetImportInProgress () const 447 { 448 if (m_parser_vars.get()) 449 return m_parser_vars->m_ignore_lookups; 450 return false; 451 } 452 453 //------------------------------------------------------------------ 454 /// [Used by ClangASTSource] Indicate that a $__lldb variable has 455 /// been found. 456 //------------------------------------------------------------------ 457 void 458 SetLookupsEnabled () 459 { 460 assert(m_parser_vars.get()); 461 m_parser_vars->m_enable_lookups = true; 462 } 463 464private: 465 ClangExpressionVariableList m_found_entities; ///< All entities that were looked up for the parser. 466 ClangExpressionVariableList m_struct_members; ///< All entities that need to be placed in the struct. 467 bool m_keep_result_in_memory; ///< True if result persistent variables generated by this expression should stay in memory. 468 469 //---------------------------------------------------------------------- 470 /// The following values should not live beyond parsing 471 //---------------------------------------------------------------------- 472 class ParserVars 473 { 474 public: 475 ParserVars() : 476 m_exe_ctx(NULL), 477 m_sym_ctx(), 478 m_persistent_vars(NULL), 479 m_enable_lookups(false), 480 m_ignore_lookups(false) 481 { 482 } 483 484 Target * 485 GetTarget() 486 { 487 if (m_exe_ctx && m_exe_ctx->target) 488 return m_exe_ctx->target; 489 else if (m_sym_ctx.target_sp) 490 m_sym_ctx.target_sp.get(); 491 return NULL; 492 } 493 ExecutionContext *m_exe_ctx; ///< The execution context to use when parsing. 494 SymbolContext m_sym_ctx; ///< The symbol context to use in finding variables and types. 495 ClangPersistentVariables *m_persistent_vars; ///< The persistent variables for the process. 496 bool m_enable_lookups; ///< Set to true during parsing if we have found the first "$__lldb" name. 497 bool m_ignore_lookups; ///< True during an import when we should be ignoring type lookups. 498 private: 499 DISALLOW_COPY_AND_ASSIGN (ParserVars); 500 }; 501 502 std::auto_ptr<ParserVars> m_parser_vars; 503 504 //---------------------------------------------------------------------- 505 /// Activate parser-specific variables 506 //---------------------------------------------------------------------- 507 void 508 EnableParserVars() 509 { 510 if (!m_parser_vars.get()) 511 m_parser_vars.reset(new struct ParserVars); 512 } 513 514 //---------------------------------------------------------------------- 515 /// Deallocate parser-specific variables 516 //---------------------------------------------------------------------- 517 void 518 DisableParserVars() 519 { 520 m_parser_vars.reset(); 521 } 522 523 //---------------------------------------------------------------------- 524 /// The following values contain layout information for the materialized 525 /// struct, but are not specific to a single materialization 526 //---------------------------------------------------------------------- 527 struct StructVars { 528 StructVars() : 529 m_struct_alignment(0), 530 m_struct_size(0), 531 m_struct_laid_out(false), 532 m_result_name(), 533 m_object_pointer_type(NULL, NULL) 534 { 535 } 536 537 off_t m_struct_alignment; ///< The alignment of the struct in bytes. 538 size_t m_struct_size; ///< The size of the struct in bytes. 539 bool m_struct_laid_out; ///< True if the struct has been laid out and the layout is valid (that is, no new fields have been added since). 540 ConstString m_result_name; ///< The name of the result variable ($1, for example) 541 TypeFromUser m_object_pointer_type; ///< The type of the "this" variable, if one exists 542 }; 543 544 std::auto_ptr<StructVars> m_struct_vars; 545 546 //---------------------------------------------------------------------- 547 /// Activate struct variables 548 //---------------------------------------------------------------------- 549 void 550 EnableStructVars() 551 { 552 if (!m_struct_vars.get()) 553 m_struct_vars.reset(new struct StructVars); 554 } 555 556 //---------------------------------------------------------------------- 557 /// Deallocate struct variables 558 //---------------------------------------------------------------------- 559 void 560 DisableStructVars() 561 { 562 m_struct_vars.reset(); 563 } 564 565 //---------------------------------------------------------------------- 566 /// The following values refer to a specific materialization of the 567 /// structure in a process 568 //---------------------------------------------------------------------- 569 struct MaterialVars { 570 MaterialVars() : 571 m_allocated_area(NULL), 572 m_materialized_location(NULL) 573 { 574 } 575 576 Process *m_process; ///< The process that the struct is materialized into. 577 lldb::addr_t m_allocated_area; ///< The base of the memory allocated for the struct. Starts on a potentially unaligned address and may therefore be larger than the struct. 578 lldb::addr_t m_materialized_location; ///< The address at which the struct is placed. Falls inside the allocated area. 579 }; 580 581 std::auto_ptr<MaterialVars> m_material_vars; 582 583 //---------------------------------------------------------------------- 584 /// Activate materialization-specific variables 585 //---------------------------------------------------------------------- 586 void 587 EnableMaterialVars() 588 { 589 if (!m_material_vars.get()) 590 m_material_vars.reset(new struct MaterialVars); 591 } 592 593 //---------------------------------------------------------------------- 594 /// Deallocate materialization-specific variables 595 //---------------------------------------------------------------------- 596 void 597 DisableMaterialVars() 598 { 599 m_material_vars.reset(); 600 } 601 602 //------------------------------------------------------------------ 603 /// Given a stack frame, find a variable that matches the given name and 604 /// type. We need this for expression re-use; we may not always get the 605 /// same lldb::Variable back, and we want the expression to work wherever 606 /// it can. Returns the variable defined in the tightest scope. 607 /// 608 /// @param[in] frame 609 /// The stack frame to use as a basis for finding the variable. 610 /// 611 /// @param[in] name 612 /// The name as a plain C string. 613 /// 614 /// @param[in] type 615 /// The required type for the variable. This function may be called 616 /// during parsing, in which case we don't know its type; hence the 617 /// default. 618 /// 619 /// @return 620 /// The LLDB Variable found, or NULL if none was found. 621 //------------------------------------------------------------------ 622 Variable * 623 FindVariableInScope (StackFrame &frame, 624 const ConstString &name, 625 TypeFromUser *type = NULL); 626 627 //------------------------------------------------------------------ 628 /// Get the value of a variable in a given execution context and return 629 /// the associated Types if needed. 630 /// 631 /// @param[in] exe_ctx 632 /// The execution context to look for the variable in. 633 /// 634 /// @param[in] var 635 /// The variable to evaluate. 636 /// 637 /// @param[in] parser_ast_context 638 /// The AST context of the parser, to store the found type in. 639 /// 640 /// @param[out] found_type 641 /// The type of the found value, as it was found in the user process. 642 /// This is only useful when the variable is being inspected on behalf 643 /// of the parser, hence the default. 644 /// 645 /// @param[out] parser_type 646 /// The type of the found value, as it was copied into the parser's 647 /// AST context. This is only useful when the variable is being 648 /// inspected on behalf of the parser, hence the default. 649 /// 650 /// @param[in] decl 651 /// The Decl to be looked up. 652 /// 653 /// @return 654 /// The LLDB Value for the variable. 655 //------------------------------------------------------------------ 656 Value * 657 GetVariableValue (ExecutionContext &exe_ctx, 658 Variable *var, 659 clang::ASTContext *parser_ast_context, 660 TypeFromUser *found_type = NULL, 661 TypeFromParser *parser_type = NULL); 662 663 //------------------------------------------------------------------ 664 /// Use the NameSearchContext to generate a Decl for the given LLDB 665 /// Variable, and put it in the Tuple list. 666 /// 667 /// @param[in] context 668 /// The NameSearchContext to use when constructing the Decl. 669 /// 670 /// @param[in] var 671 /// The LLDB Variable that needs a Decl. 672 //------------------------------------------------------------------ 673 void 674 AddOneVariable (NameSearchContext &context, 675 Variable *var); 676 677 //------------------------------------------------------------------ 678 /// Use the NameSearchContext to generate a Decl for the given 679 /// persistent variable, and put it in the Tuple list. 680 /// 681 /// @param[in] context 682 /// The NameSearchContext to use when constructing the Decl. 683 /// 684 /// @param[in] pvar 685 /// The persistent variable that needs a Decl. 686 //------------------------------------------------------------------ 687 void 688 AddOneVariable (NameSearchContext &context, 689 lldb::ClangExpressionVariableSP &pvar_sp); 690 691 //------------------------------------------------------------------ 692 /// Use the NameSearchContext to generate a Decl for the given 693 /// function. (Functions are not placed in the Tuple list.) Can 694 /// handle both fully typed functions and generic functions. 695 /// 696 /// @param[in] context 697 /// The NameSearchContext to use when constructing the Decl. 698 /// 699 /// @param[in] fun 700 /// The Function that needs to be created. If non-NULL, this is 701 /// a fully-typed function. 702 /// 703 /// @param[in] sym 704 /// The Symbol that corresponds to a function that needs to be 705 /// created with generic type (unitptr_t foo(...)). 706 //------------------------------------------------------------------ 707 void 708 AddOneFunction (NameSearchContext &context, 709 Function *fun, 710 Symbol *sym); 711 712 //------------------------------------------------------------------ 713 /// Use the NameSearchContext to generate a Decl for the given 714 /// register. 715 /// 716 /// @param[in] context 717 /// The NameSearchContext to use when constructing the Decl. 718 /// 719 /// @param[in] reg_info 720 /// The information corresponding to that register. 721 //------------------------------------------------------------------ 722 void 723 AddOneRegister (NameSearchContext &context, 724 const lldb::RegisterInfo *reg_info); 725 726 //------------------------------------------------------------------ 727 /// Use the NameSearchContext to generate a Decl for the given 728 /// type. (Types are not placed in the Tuple list.) 729 /// 730 /// @param[in] context 731 /// The NameSearchContext to use when constructing the Decl. 732 /// 733 /// @param[in] type 734 /// The type that needs to be created. 735 /// 736 /// @param[in] add_method 737 /// True if a method with signature void $__lldb_expr(void*) 738 /// should be added to the C++ class type passed in 739 //------------------------------------------------------------------ 740 void 741 AddOneType (NameSearchContext &context, 742 TypeFromUser &type, 743 bool add_method = false); 744 745 //------------------------------------------------------------------ 746 /// Actually do the task of materializing or dematerializing the struct. 747 /// Since both tasks are very similar, although ClangExpressionDeclMap 748 /// exposes two functions to the outside, both call DoMaterialize. 749 /// 750 /// @param[in] dematerialize 751 /// True if the struct is to be dematerialized; false if it is to 752 /// be materialized. 753 /// 754 /// @param[in] exe_ctx 755 /// The execution context to use. 756 /// 757 /// @param[out] result 758 /// If the struct is being dematerialized, a pointer into which the 759 /// location of the result persistent variable is placed. If not, 760 /// NULL. 761 /// 762 /// @param[in] err 763 /// An Error to populate with any messages related to 764 /// (de)materializing the struct. 765 /// 766 /// @return 767 /// True on success; false otherwise. 768 //------------------------------------------------------------------ 769 bool 770 DoMaterialize (bool dematerialize, 771 ExecutionContext &exe_ctx, 772 lldb::ClangExpressionVariableSP *result_sp_ptr, 773 Error &err); 774 775 //------------------------------------------------------------------ 776 /// Clean up the state required to dematerialize the variable. 777 //------------------------------------------------------------------ 778 void 779 DidDematerialize (); 780 781 //------------------------------------------------------------------ 782 /// Actually do the task of materializing or dematerializing a persistent 783 /// variable. 784 /// 785 /// @param[in] dematerialize 786 /// True if the variable is to be dematerialized; false if it is to 787 /// be materialized. 788 /// 789 /// @param[in] exe_ctx 790 /// The execution context to use. 791 /// 792 /// @param[in] var_sp 793 /// The persistent variable to materialize 794 /// 795 /// @param[in] addr 796 /// The address at which to materialize the variable. 797 /// 798 /// @param[in] err 799 /// An Error to populate with any messages related to 800 /// (de)materializing the persistent variable. 801 /// 802 /// @return 803 /// True on success; false otherwise. 804 //------------------------------------------------------------------ 805 bool 806 DoMaterializeOnePersistentVariable (bool dematerialize, 807 ExecutionContext &exe_ctx, 808 lldb::ClangExpressionVariableSP &var_sp, 809 lldb::addr_t addr, 810 Error &err); 811 812 //------------------------------------------------------------------ 813 /// Actually do the task of materializing or dematerializing a 814 /// variable. 815 /// 816 /// @param[in] dematerialize 817 /// True if the variable is to be dematerialized; false if it is to 818 /// be materialized. 819 /// 820 /// @param[in] exe_ctx 821 /// The execution context to use. 822 /// 823 /// @param[in] sym_ctx 824 /// The symbol context to use (for looking the variable up). 825 /// 826 /// @param[in] expr_var 827 /// The entity that the expression parser uses for the variable. 828 /// In case the variable needs to be copied into the target's 829 /// memory, this location is stored in the variable during 830 /// materialization and cleared when it is demateralized. 831 /// 832 /// @param[in] addr 833 /// The address at which to materialize the variable. 834 /// 835 /// @param[in] err 836 /// An Error to populate with any messages related to 837 /// (de)materializing the persistent variable. 838 /// 839 /// @return 840 /// True on success; false otherwise. 841 //------------------------------------------------------------------ 842 bool 843 DoMaterializeOneVariable (bool dematerialize, 844 ExecutionContext &exe_ctx, 845 const SymbolContext &sym_ctx, 846 lldb::ClangExpressionVariableSP &expr_var, 847 lldb::addr_t addr, 848 Error &err); 849 850 //------------------------------------------------------------------ 851 /// Actually do the task of materializing or dematerializing a 852 /// register variable. 853 /// 854 /// @param[in] dematerialize 855 /// True if the variable is to be dematerialized; false if it is to 856 /// be materialized. 857 /// 858 /// @param[in] exe_ctx 859 /// The execution context to use. 860 /// 861 /// @param[in] reg_ctx 862 /// The register context to use. 863 /// 864 /// @param[in] reg_info 865 /// The information for the register to read/write. 866 /// 867 /// @param[in] addr 868 /// The address at which to materialize the variable. 869 /// 870 /// @param[in] err 871 /// An Error to populate with any messages related to 872 /// (de)materializing the persistent variable. 873 /// 874 /// @return 875 /// True on success; false otherwise. 876 //------------------------------------------------------------------ 877 bool 878 DoMaterializeOneRegister (bool dematerialize, 879 ExecutionContext &exe_ctx, 880 RegisterContext ®_ctx, 881 const lldb::RegisterInfo ®_info, 882 lldb::addr_t addr, 883 Error &err); 884 885 //------------------------------------------------------------------ 886 /// A wrapper for ClangASTContext::CopyType that sets a flag that 887 /// indicates that we should not respond to queries during import. 888 /// 889 /// @param[in] dest_context 890 /// The target AST context, typically the parser's AST context. 891 /// 892 /// @param[in] source_context 893 /// The source AST context, typically the AST context of whatever 894 /// symbol file the type was found in. 895 /// 896 /// @param[in] clang_type 897 /// The source type. 898 /// 899 /// @return 900 /// The imported type. 901 //------------------------------------------------------------------ 902 void * 903 GuardedCopyType (clang::ASTContext *dest_context, 904 clang::ASTContext *source_context, 905 void *clang_type); 906}; 907 908} // namespace lldb_private 909 910#endif // liblldb_ClangExpressionDeclMap_h_ 911