From: Igor Kulaychuk Date: Mon, 3 Oct 2016 18:04:05 +0000 (+0300) Subject: Fix DWARF linetable info provided by GDBJIT (dotnet/coreclr#7444) X-Git-Tag: submit/tizen/20210909.063632~11030^2~9290 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a9a25991ca27c46b3cd4139cf0cb591a3ab325ea;p=platform%2Fupstream%2Fdotnet%2Fruntime.git Fix DWARF linetable info provided by GDBJIT (dotnet/coreclr#7444) Extend PC to the end of function in DWARF linetable commands. This allows the debugger to show source lines for all addresses inside a function. Commit migrated from https://github.com/dotnet/coreclr/commit/449feba048bc80faf999ad0e014497fde1d12e60 --- diff --git a/src/coreclr/src/vm/gdbjit.cpp b/src/coreclr/src/vm/gdbjit.cpp index d2373f0..1a7f6b1 100644 --- a/src/coreclr/src/vm/gdbjit.cpp +++ b/src/coreclr/src/vm/gdbjit.cpp @@ -752,7 +752,7 @@ void NotifyGdb::MethodCompiled(MethodDesc* MethodDescPtr) debugInfoSub.m_sub_low_pc = pCode; debugInfoSub.m_sub_high_pc = codeSize; /* Build .debug_line section */ - if (!BuildLineTable(dbgLine, pCode, symInfo, symInfoLen)) + if (!BuildLineTable(dbgLine, pCode, codeSize, symInfo, symInfoLen)) { return; } @@ -992,7 +992,7 @@ void NotifyGdb::MethodDropped(MethodDesc* MethodDescPtr) } /* Build the DWARF .debug_line section */ -bool NotifyGdb::BuildLineTable(MemBuf& buf, PCODE startAddr, SymbolsInfo* lines, unsigned nlines) +bool NotifyGdb::BuildLineTable(MemBuf& buf, PCODE startAddr, TADDR codeSize, SymbolsInfo* lines, unsigned nlines) { MemBuf fileTable, lineProg; @@ -1000,7 +1000,7 @@ bool NotifyGdb::BuildLineTable(MemBuf& buf, PCODE startAddr, SymbolsInfo* lines, if (!BuildFileTable(fileTable, lines, nlines)) return false; /* Build line info program */ - if (!BuildLineProg(lineProg, startAddr, lines, nlines)) + if (!BuildLineProg(lineProg, startAddr, codeSize, lines, nlines)) { return false; } @@ -1147,7 +1147,7 @@ bool NotifyGdb::FitIntoSpecialOpcode(int8_t line_shift, uint8_t addr_shift) } /* Build program for DWARF source line section */ -bool NotifyGdb::BuildLineProg(MemBuf& buf, PCODE startAddr, SymbolsInfo* lines, unsigned nlines) +bool NotifyGdb::BuildLineProg(MemBuf& buf, PCODE startAddr, TADDR codeSize, SymbolsInfo* lines, unsigned nlines) { static char cnv_buf[16]; @@ -1157,6 +1157,7 @@ bool NotifyGdb::BuildLineProg(MemBuf& buf, PCODE startAddr, SymbolsInfo* lines, + 6 /* set file command */ + nlines * 6 /* advance line commands */ + nlines * (4 + ADDRESS_SIZE) /* 1 extended + 1 special command */ + + 6 /* advance PC command */ + 3; /* end of sequence command */ buf.MemPtr = new (nothrow) char[buf.MemSize]; char* ptr = buf.MemPtr; @@ -1199,6 +1200,12 @@ bool NotifyGdb::BuildLineProg(MemBuf& buf, PCODE startAddr, SymbolsInfo* lines, prevAddr = lines[i].nativeOffset; } + // Advance PC to the end of function + if (prevAddr < codeSize) { + int len = Leb128Encode(static_cast(codeSize - prevAddr), cnv_buf, sizeof(cnv_buf)); + IssueParamCommand(ptr, DW_LNS_advance_pc, cnv_buf, len); + } + IssueEndOfSequence(ptr); buf.MemSize = ptr - buf.MemPtr; diff --git a/src/coreclr/src/vm/gdbjit.h b/src/coreclr/src/vm/gdbjit.h index 7f87d9e..21a60fe 100644 --- a/src/coreclr/src/vm/gdbjit.h +++ b/src/coreclr/src/vm/gdbjit.h @@ -141,9 +141,9 @@ private: NewArrayHolder& localsDebug, unsigned int localsDebugSize); static bool BuildDebugPub(MemBuf& buf, const char* name, uint32_t size, uint32_t dieOffset); - static bool BuildLineTable(MemBuf& buf, PCODE startAddr, SymbolsInfo* lines, unsigned nlines); + static bool BuildLineTable(MemBuf& buf, PCODE startAddr, TADDR codeSize, SymbolsInfo* lines, unsigned nlines); static bool BuildFileTable(MemBuf& buf, SymbolsInfo* lines, unsigned nlines); - static bool BuildLineProg(MemBuf& buf, PCODE startAddr, SymbolsInfo* lines, unsigned nlines); + static bool BuildLineProg(MemBuf& buf, PCODE startAddr, TADDR codeSize, SymbolsInfo* lines, unsigned nlines); static bool FitIntoSpecialOpcode(int8_t line_shift, uint8_t addr_shift); static void IssueSetAddress(char*& ptr, PCODE addr); static void IssueEndOfSequence(char*& ptr);