Skip to content

Commit 6b1b953

Browse files
committed
Added extra logging, and made sure that the argument
struct for expressions is deallocated when the ClangExpressionDeclMap is taken down. llvm-svn: 116028
1 parent 15bc243 commit 6b1b953

File tree

3 files changed

+52
-0
lines changed

3 files changed

+52
-0
lines changed

lldb/source/Expression/ClangExpressionDeclMap.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,12 @@ ClangExpressionDeclMap::~ClangExpressionDeclMap()
7474
pvar.DisableParserVars();
7575
}
7676

77+
if (m_materialized_location)
78+
{
79+
m_exe_ctx->process->DeallocateMemory(m_materialized_location);
80+
m_materialized_location = 0;
81+
}
82+
7783
if (m_sym_ctx)
7884
delete m_sym_ctx;
7985
}
@@ -495,6 +501,9 @@ ClangExpressionDeclMap::DoMaterialize (bool dematerialize,
495501
m_materialized_location = 0;
496502
}
497503

504+
if (log)
505+
log->PutCString("Allocating memory for materialized argument struct");
506+
498507
lldb::addr_t mem = exe_ctx->process->AllocateMemory(m_struct_alignment + m_struct_size,
499508
lldb::ePermissionsReadable | lldb::ePermissionsWritable,
500509
err);

lldb/source/Expression/ClangExpressionParser.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,8 @@ ClangExpressionParser::MakeJIT (lldb::addr_t &func_addr,
449449

450450
if (m_expr.NeedsValidation())
451451
{
452+
/*
453+
Disabled temporarily - TODO Centralize and re-enable this inside Process to avoid race conditions
452454
IRDynamicChecks ir_dynamic_checks(*exe_ctx.process->GetDynamicCheckers(), function_name.c_str());
453455
454456
if (!ir_dynamic_checks.runOnModule(*module))
@@ -457,6 +459,7 @@ ClangExpressionParser::MakeJIT (lldb::addr_t &func_addr,
457459
err.SetErrorString("Couldn't add dynamic checks to the expression");
458460
return err;
459461
}
462+
*/
460463
}
461464
}
462465

lldb/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "lldb/Core/ConstString.h"
1313
#include "lldb/Core/DataExtractor.h"
1414
#include "lldb/Core/Error.h"
15+
#include "lldb/Core/Log.h"
1516
#include "lldb/Core/Module.h"
1617
#include "lldb/Core/PluginManager.h"
1718
#include "lldb/Core/Value.h"
@@ -60,6 +61,17 @@ ABISysV_x86_64::PrepareTrivialCall (Thread &thread,
6061
lldb::addr_t arg,
6162
lldb::addr_t *this_arg) const
6263
{
64+
Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS);
65+
66+
if (log)
67+
log->Printf("ABISysV_x86_64::PrepareTrivialCall\n(\n thread = %p\n sp = 0x%llx\n functionAddress = 0x%llx\n returnAddress = 0x%llx\n arg = 0x%llx\n this_arg = %p(0x%llx)\n)",
68+
(void*)&thread,
69+
(uint64_t)sp,
70+
(uint64_t)functionAddress,
71+
(uint64_t)returnAddress,
72+
(void*)arg,
73+
this_arg ? (uint64_t)*this_arg : (uint64_t)0);
74+
6375
RegisterContext *reg_ctx = thread.GetRegisterContext();
6476
if (!reg_ctx)
6577
return false;
@@ -78,21 +90,39 @@ ABISysV_x86_64::PrepareTrivialCall (Thread &thread,
7890

7991
if (this_arg)
8092
{
93+
if (log)
94+
log->PutCString("The trivial call has a this pointer");
95+
8196
uint32_t rsiID = reg_ctx->GetRegisterInfoByName("rsi", 0)->kinds[eRegisterKindLLDB];
8297

98+
if (log)
99+
log->Printf("About to write 'this' (0x%llx) into RDI", (uint64_t)*this_arg);
100+
83101
if (!reg_ctx->WriteRegisterFromUnsigned(rdiID, *this_arg))
84102
return false;
85103

104+
if (log)
105+
log->Printf("About to write the argument (0x%llx) into RSI", (uint64_t)arg);
106+
86107
if (!reg_ctx->WriteRegisterFromUnsigned(rsiID, arg))
87108
return false;
88109
}
89110
else
90111
{
112+
if (log)
113+
log->PutCString("The trivial call does not have a this pointer");
114+
115+
if (log)
116+
log->Printf("About to write the argument (0x%llx) into RDI", (uint64_t)arg);
117+
91118
if (!reg_ctx->WriteRegisterFromUnsigned(rdiID, arg))
92119
return false;
93120
}
94121

95122
// First, align the SP
123+
124+
if (log)
125+
log->Printf("16-byte aligning SP: 0x%llx to 0x%llx", (uint64_t)sp, (uint64_t)(sp & ~0xfull));
96126

97127
sp &= ~(0xfull); // 16-byte alignment
98128

@@ -101,11 +131,18 @@ ABISysV_x86_64::PrepareTrivialCall (Thread &thread,
101131
sp -= 8;
102132
uint64_t returnAddressU64 = returnAddress;
103133
Error error;
134+
135+
if (log)
136+
log->Printf("Pushing the return address onto the stack: new SP 0x%llx, return address 0x%llx", (uint64_t)sp, (uint64_t)returnAddressU64);
137+
104138
if (thread.GetProcess().WriteMemory (sp, &returnAddressU64, sizeof(returnAddressU64), error) != sizeof(returnAddressU64))
105139
return false;
106140

107141
// %rsp is set to the actual stack value.
108142

143+
if (log)
144+
log->Printf("Writing SP (0x%llx) down", (uint64_t)sp);
145+
109146
if (!reg_ctx->WriteRegisterFromUnsigned(rspID, sp))
110147
return false;
111148

@@ -117,6 +154,9 @@ ABISysV_x86_64::PrepareTrivialCall (Thread &thread,
117154
#endif
118155

119156
// %rip is set to the address of the called function.
157+
158+
if (log)
159+
log->Printf("Writing new IP (0x%llx) down", (uint64_t)functionAddress);
120160

121161
if (!reg_ctx->WriteRegisterFromUnsigned(ripID, functionAddress))
122162
return false;

0 commit comments

Comments
 (0)