Index: source/Plugins/ExpressionParser/Clang/ClangExpressionParser.h =================================================================== --- source/Plugins/ExpressionParser/Clang/ClangExpressionParser.h +++ source/Plugins/ExpressionParser/Clang/ClangExpressionParser.h @@ -137,7 +137,19 @@ Error RunStaticInitializers (lldb::IRExecutionUnitSP &execution_unit_sp, ExecutionContext &exe_ctx); - + + //------------------------------------------------------------------ + /// Returns a string representing current ABI. + /// + /// @param[in] target_arch + /// The target architecture. + /// + /// @return + /// A string representing target ABI for the current architecture. + //------------------------------------------------------------------- + std::string + GetClangTargetABI (const ArchSpec &target_arch); + private: std::unique_ptr m_llvm_context; ///< The LLVM context to generate IR into std::unique_ptr m_file_manager; ///< The Clang file manager object used by the compiler Index: source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp =================================================================== --- source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp +++ source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp @@ -268,6 +268,7 @@ bool overridden_target_opts = false; lldb_private::LanguageRuntime *lang_rt = nullptr; lldb::TargetSP target_sp; + std::string abi; if (exe_scope) target_sp = exe_scope->CalculateTarget(); @@ -333,6 +334,11 @@ // This will be empty for any CPU that doesn't really need to make a special CPU string. m_compiler->getTargetOpts().CPU = target_arch.GetClangTargetCPU(); + // Set the target ABI + abi = GetClangTargetABI(target_arch); + if (!abi.empty()) + m_compiler->getTargetOpts().ABI = abi; + // 3. Now allow the runtime to provide custom configuration options for the target. // In this case, a specialized language runtime is available and we can query it for extra options. // For 99% of use cases, this will not be needed and should be provided when basic platform detection is not enough. @@ -645,6 +651,32 @@ return num_errors; } +std::string +ClangExpressionParser::GetClangTargetABI (const ArchSpec &target_arch) +{ + std::string abi; + const llvm::Triple::ArchType machine = target_arch.GetMachine(); + + if(machine == llvm::Triple::mips || + machine == llvm::Triple::mipsel || + machine == llvm::Triple::mips64 || + machine == llvm::Triple::mips64el) + { + switch (target_arch.GetFlags () & ArchSpec::eMIPSABI_mask) + { + case ArchSpec::eMIPSABI_N64: + abi = "n64"; break; + case ArchSpec::eMIPSABI_N32: + abi = "n32"; break; + case ArchSpec::eMIPSABI_O32: + abi = "o32"; break; + default: + break; + } + } + return abi; +} + bool ClangExpressionParser::RewriteExpression(DiagnosticManager &diagnostic_manager) {