mirror of
https://github.com/RPCSX/llvm.git
synced 2025-01-18 02:16:43 +00:00
[CodeView] Truncate display names
Fundamentally, the length of a variable or function name is bound by the maximum size of a record: 0xffff. However, the name doesn't live in a vacuum; other data is associated with the name, lowering the bound further. We would naively attempt to emit the name, causing us to assert because the record would no-longer fit in 16-bits. Instead, truncate the name but preserve as much as we can. While I have tested this locally, I've decided to not commit it due to the test's size. N.B. While this behavior is undesirable, it is better than MSVC's behavior. They seem to truncate to ~4000 characters. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@263378 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
3aae575a24
commit
a80c0ed373
@ -397,10 +397,11 @@ void CodeViewDebug::emitInlinedCallSite(const FunctionInfo &FI,
|
||||
OS.EmitIntValue(SymbolRecordKind::S_INLINESITE_END, 2); // RecordKind
|
||||
}
|
||||
|
||||
static void emitNullTerminatedString(MCStreamer &OS, StringRef S) {
|
||||
static void emitNullTerminatedString(MCStreamer &OS, StringRef S,
|
||||
size_t MaxSize) {
|
||||
S = S.substr(0, MaxSize);
|
||||
SmallString<32> NullTerminatedString(S);
|
||||
if (NullTerminatedString.empty() || NullTerminatedString.back() != '\0')
|
||||
NullTerminatedString.push_back('\0');
|
||||
NullTerminatedString.push_back('\0');
|
||||
OS.EmitBytes(NullTerminatedString);
|
||||
}
|
||||
|
||||
@ -462,7 +463,8 @@ void CodeViewDebug::emitDebugInfoForFunction(const Function *GV,
|
||||
OS.EmitIntValue(0, 1);
|
||||
// Emit the function display name as a null-terminated string.
|
||||
OS.AddComment("Function name");
|
||||
emitNullTerminatedString(OS, FuncName);
|
||||
// Truncate the name so we won't overflow the record length field.
|
||||
emitNullTerminatedString(OS, FuncName, 0xffd9);
|
||||
OS.EmitLabel(ProcRecordEnd);
|
||||
|
||||
for (const LocalVariable &Var : FI.Locals)
|
||||
@ -706,7 +708,8 @@ void CodeViewDebug::emitLocalVariable(const LocalVariable &Var) {
|
||||
OS.EmitIntValue(TypeIndex::Int32().getIndex(), 4);
|
||||
OS.AddComment("Flags");
|
||||
OS.EmitIntValue(Flags, 2);
|
||||
emitNullTerminatedString(OS, Var.DIVar->getName());
|
||||
// Truncate the name so we won't overflow the record length field.
|
||||
emitNullTerminatedString(OS, Var.DIVar->getName(), 0xfff6);
|
||||
OS.EmitLabel(LocalEnd);
|
||||
|
||||
// Calculate the on disk prefix of the appropriate def range record. The
|
||||
|
Loading…
x
Reference in New Issue
Block a user