Skip to content

Commit f85cdcb

Browse files
committed
Delete non-supported handling of Windows-specific PDBs in ilasm
I do not expect we will ever add the classic PDB support back in ilasm. Fixes dotnet#45492
1 parent f513349 commit f85cdcb

File tree

8 files changed

+59
-332
lines changed

8 files changed

+59
-332
lines changed

src/coreclr/ilasm/assem.cpp

Lines changed: 5 additions & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,6 @@ Assembler::Assembler()
106106
m_ulLastDebugColumn = 0xFFFFFFFF;
107107
m_ulLastDebugLineEnd = 0xFFFFFFFF;
108108
m_ulLastDebugColumnEnd = 0xFFFFFFFF;
109-
m_pSymWriter = NULL;
110-
m_pSymDocument = NULL;
111109
m_dwIncludeDebugInfo = 0;
112110
m_fGeneratePDB = FALSE;
113111
m_fIsMscorlib = FALSE;
@@ -158,7 +156,6 @@ Assembler::Assembler()
158156
dummyClass = new Class(NULL);
159157
indexKeywords(&indxKeywords);
160158

161-
m_pdbFormat = CLASSIC;
162159
m_pPortablePdbWriter = NULL;
163160
}
164161

@@ -199,18 +196,10 @@ Assembler::~Assembler()
199196
while((m_szNamespace = m_NSstack.POP())) ;
200197
delete [] m_szFullNS;
201198

202-
m_DocWriterList.RESET(true);
203-
204199
m_MethodBodyList.RESET(true);
205200

206201
m_TypeDefDList.RESET(true);
207202

208-
if (m_pSymWriter != NULL)
209-
{
210-
m_pSymWriter->Close();
211-
m_pSymWriter->Release();
212-
m_pSymWriter = NULL;
213-
}
214203
if (m_pImporter != NULL)
215204
{
216205
m_pImporter->Release();
@@ -234,7 +223,7 @@ Assembler::~Assembler()
234223
}
235224

236225

237-
BOOL Assembler::Init(BOOL generatePdb, PdbFormat pdbFormat)
226+
BOOL Assembler::Init(BOOL generatePdb)
238227
{
239228
if (m_pCeeFileGen != NULL) {
240229
if (m_pCeeFile)
@@ -254,7 +243,6 @@ BOOL Assembler::Init(BOOL generatePdb, PdbFormat pdbFormat)
254243
if (FAILED(m_pCeeFileGen->GetSectionCreate (m_pCeeFile, ".tls", sdReadWrite, &m_pTLSSection))) return FALSE;
255244

256245
m_fGeneratePDB = generatePdb;
257-
m_pdbFormat = pdbFormat;
258246

259247
return TRUE;
260248
}
@@ -527,65 +515,10 @@ BOOL Assembler::EmitMethodBody(Method* pMethod, BinStr* pbsOut)
527515
//--------------------------------------------------------------------------------
528516
if(m_fGeneratePDB)
529517
{
530-
if (m_pSymWriter != NULL)
531-
{
532-
m_pSymWriter->OpenMethod(pMethod->m_Tok);
533-
ULONG N = pMethod->m_LinePCList.COUNT();
534-
if(pMethod->m_fEntryPoint) m_pSymWriter->SetUserEntryPoint(pMethod->m_Tok);
535-
if(N)
536-
{
537-
LinePC *pLPC;
538-
ULONG32 *offsets=new ULONG32[N], *lines = new ULONG32[N], *columns = new ULONG32[N];
539-
ULONG32 *endlines=new ULONG32[N], *endcolumns=new ULONG32[N];
540-
if(offsets && lines && columns && endlines && endcolumns)
541-
{
542-
DocWriter* pDW;
543-
unsigned j=0;
544-
while((pDW = m_DocWriterList.PEEK(j++)))
545-
{
546-
if((m_pSymDocument = pDW->pWriter))
547-
{
548-
int i, n;
549-
for(i=0, n=0; (pLPC = pMethod->m_LinePCList.PEEK(i)); i++)
550-
{
551-
if(pLPC->pWriter == m_pSymDocument)
552-
{
553-
offsets[n] = pLPC->PC;
554-
lines[n] = pLPC->Line;
555-
columns[n] = pLPC->Column;
556-
endlines[n] = pLPC->LineEnd;
557-
endcolumns[n] = pLPC->ColumnEnd;
558-
n++;
559-
}
560-
}
561-
if(n) m_pSymWriter->DefineSequencePoints(m_pSymDocument,n,
562-
offsets,lines,columns,endlines,endcolumns);
563-
} // end if(pSymDocument)
564-
} // end while(pDW = next doc.writer)
565-
pMethod->m_LinePCList.RESET(true);
566-
}
567-
else report->error("\nOutOfMemory!\n");
568-
delete [] offsets;
569-
delete [] lines;
570-
delete [] columns;
571-
delete [] endlines;
572-
delete [] endcolumns;
573-
}//enf if(N)
574-
HRESULT hrr;
575-
if(pMethod->m_ulLines[1])
576-
hrr = m_pSymWriter->SetMethodSourceRange(m_pSymDocument,pMethod->m_ulLines[0], pMethod->m_ulColumns[0],
577-
m_pSymDocument,pMethod->m_ulLines[1], pMethod->m_ulColumns[1]);
578-
EmitScope(&(pMethod->m_MainScope)); // recursively emits all nested scopes
579-
580-
m_pSymWriter->CloseMethod();
581-
}
582-
else if (IsPortablePdb())
583-
{
584-
if (FAILED(m_pPortablePdbWriter->DefineSequencePoints(pMethod)))
585-
return FALSE;
586-
if (FAILED(m_pPortablePdbWriter->DefineLocalScope(pMethod)))
587-
return FALSE;
588-
}
518+
if (FAILED(m_pPortablePdbWriter->DefineSequencePoints(pMethod)))
519+
return FALSE;
520+
if (FAILED(m_pPortablePdbWriter->DefineLocalScope(pMethod)))
521+
return FALSE;
589522
} // end if(fIncludeDebugInfo)
590523
//-----------------------------------------------------
591524

@@ -732,44 +665,6 @@ HRESULT Assembler::EmitPinvokeMap(mdToken tk, PInvokeDescriptor* pDescr)
732665
pDescr->mrDll); // [IN] ModuleRef token for the target DLL.
733666
}
734667

735-
void Assembler::EmitScope(Scope* pSCroot)
736-
{
737-
static ULONG32 scopeID;
738-
static ARG_NAME_LIST *pVarList;
739-
int i;
740-
WCHAR* wzVarName=&wzUniBuf[0];
741-
char* szPhonyName=(char*)&wzUniBuf[dwUniBuf >> 1];
742-
Scope* pSC = pSCroot;
743-
if(pSC && m_pSymWriter)
744-
{
745-
if(SUCCEEDED(m_pSymWriter->OpenScope(pSC->dwStart,&scopeID)))
746-
{
747-
if(pSC->pLocals)
748-
{
749-
for(pVarList = pSC->pLocals; pVarList; pVarList = pVarList->pNext)
750-
{
751-
if(pVarList->pSig)
752-
{
753-
if((pVarList->szName)&&(*(pVarList->szName))) strcpy_s(szPhonyName,dwUniBuf >> 1,pVarList->szName);
754-
else sprintf_s(szPhonyName,(dwUniBuf >> 1),"V_%d",pVarList->dwAttr);
755-
756-
WszMultiByteToWideChar(g_uCodePage,0,szPhonyName,-1,wzVarName,dwUniBuf >> 1);
757-
758-
m_pSymWriter->DefineLocalVariable(wzVarName,0,pVarList->pSig->length(),
759-
(BYTE*)pVarList->pSig->ptr(),ADDR_IL_OFFSET,pVarList->dwAttr,0,0,0,0);
760-
}
761-
else
762-
{
763-
report->error("Local Var '%s' has no signature\n",pVarList->szName);
764-
}
765-
}
766-
}
767-
for(i = 0; (pSC = pSCroot->SubScope.PEEK(i)); i++) EmitScope(pSC);
768-
m_pSymWriter->CloseScope(pSCroot->dwEnd);
769-
}
770-
}
771-
}
772-
773668
BOOL Assembler::EmitMethod(Method *pMethod)
774669
{
775670
// Emit the metadata for a method definition

src/coreclr/ilasm/assembler.cpp

Lines changed: 9 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1417,7 +1417,6 @@ void Assembler::EmitOpcode(Instr* instr)
14171417
pLPC->LineEnd = instr->linenum_end;
14181418
pLPC->ColumnEnd = instr->column_end;
14191419
pLPC->PC = m_CurPC;
1420-
pLPC->pWriter = instr->pWriter;
14211420

14221421
pLPC->pOwnerDocument = instr->pOwnerDocument;
14231422
if (0xfeefee == instr->linenum &&
@@ -2390,51 +2389,11 @@ void Assembler::SetSourceFileName(__in __nullterminated char* szName)
23902389
}
23912390
if(m_fGeneratePDB)
23922391
{
2393-
if (IsPortablePdb())
2392+
if (FAILED(m_pPortablePdbWriter->DefineDocument(szName, &m_guidLang)))
23942393
{
2395-
if (FAILED(m_pPortablePdbWriter->DefineDocument(szName, &m_guidLang)))
2396-
{
2397-
report->error("Failed to define a document: '%s'", szName);
2398-
}
2399-
delete[] szName;
2400-
}
2401-
else
2402-
{
2403-
DocWriter* pDW;
2404-
unsigned i = 0;
2405-
while ((pDW = m_DocWriterList.PEEK(i++)) != NULL)
2406-
{
2407-
if (!strcmp(szName, pDW->Name)) break;
2408-
}
2409-
if (pDW)
2410-
{
2411-
m_pSymDocument = pDW->pWriter;
2412-
delete[] szName;
2413-
}
2414-
else if (m_pSymWriter)
2415-
{
2416-
HRESULT hr;
2417-
WszMultiByteToWideChar(g_uCodePage, 0, szName, -1, wzUniBuf, dwUniBuf);
2418-
if (FAILED(hr = m_pSymWriter->DefineDocument(wzUniBuf, &m_guidLang,
2419-
&m_guidLangVendor, &m_guidDoc, &m_pSymDocument)))
2420-
{
2421-
m_pSymDocument = NULL;
2422-
report->error("Failed to define a document writer");
2423-
}
2424-
if ((pDW = new DocWriter()) != NULL)
2425-
{
2426-
pDW->Name = szName;
2427-
pDW->pWriter = m_pSymDocument;
2428-
m_DocWriterList.PUSH(pDW);
2429-
}
2430-
else
2431-
{
2432-
report->error("Out of memory");
2433-
delete[] szName;
2434-
}
2435-
}
2436-
else delete[] szName;
2394+
report->error("Failed to define a document: '%s'", szName);
24372395
}
2396+
delete[] szName;
24382397
}
24392398
else delete [] szName;
24402399
}
@@ -2471,21 +2430,15 @@ HRESULT Assembler::SavePdbFile()
24712430
HRESULT hr = S_OK;
24722431
mdMethodDef entryPoint;
24732432

2474-
if (m_pdbFormat == PORTABLE)
2475-
{
2476-
if (FAILED(hr = (m_pPortablePdbWriter == NULL ? E_FAIL : S_OK))) goto exit;
2477-
if (FAILED(hr = (m_pPortablePdbWriter->GetEmitter() == NULL ? E_FAIL : S_OK))) goto exit;
2478-
if (FAILED(hr = m_pCeeFileGen->GetEntryPoint(m_pCeeFile, &entryPoint))) goto exit;
2479-
if (FAILED(hr = m_pPortablePdbWriter->BuildPdbStream(m_pEmitter, entryPoint))) goto exit;
2480-
if (FAILED(hr = m_pPortablePdbWriter->GetEmitter()->Save(m_wzPdbFileName, NULL))) goto exit;
2481-
}
2433+
if (FAILED(hr = (m_pPortablePdbWriter == NULL ? E_FAIL : S_OK))) goto exit;
2434+
if (FAILED(hr = (m_pPortablePdbWriter->GetEmitter() == NULL ? E_FAIL : S_OK))) goto exit;
2435+
if (FAILED(hr = m_pCeeFileGen->GetEntryPoint(m_pCeeFile, &entryPoint))) goto exit;
2436+
if (FAILED(hr = m_pPortablePdbWriter->BuildPdbStream(m_pEmitter, entryPoint))) goto exit;
2437+
if (FAILED(hr = m_pPortablePdbWriter->GetEmitter()->Save(m_wzPdbFileName, NULL))) goto exit;
2438+
24822439
exit:
24832440
return hr;
24842441
}
2485-
BOOL Assembler::IsPortablePdb()
2486-
{
2487-
return (m_pdbFormat == PORTABLE) && (m_pPortablePdbWriter != NULL);
2488-
}
24892442

24902443
// This method is called after we have parsed the generic type parameters for either
24912444
// a generic class or a generic method. It calls CheckAddGenericParamConstraint on

src/coreclr/ilasm/assembler.h

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -620,14 +620,6 @@ struct EATEntry
620620
};
621621
typedef FIFO<EATEntry> EATList;
622622

623-
struct DocWriter
624-
{
625-
char* Name;
626-
ISymUnmanagedDocumentWriter* pWriter;
627-
DocWriter() { Name=NULL; pWriter=NULL; };
628-
~DocWriter() { delete [] Name; if(pWriter) pWriter->Release();};
629-
};
630-
typedef FIFO<DocWriter> DocWriterList;
631623
/**************************************************************************/
632624
/* The assembler object does all the code generation (dealing with meta-data)
633625
writing a PE file etc etc. But does NOT deal with syntax (that is what
@@ -642,7 +634,6 @@ struct Instr
642634
unsigned linenum_end;
643635
unsigned column_end;
644636
unsigned pc;
645-
ISymUnmanagedDocumentWriter* pWriter;
646637
Document* pOwnerDocument;
647638
};
648639
#define INSTR_POOL_SIZE 16
@@ -736,12 +727,6 @@ struct Indx
736727
}
737728
};
738729

739-
typedef enum {
740-
CLASSIC, // default - classic PDB format, currently not supported for CoreCLR
741-
PORTABLE,
742-
// EMBEDDED // for future use
743-
} PdbFormat;
744-
745730
class Assembler {
746731
public:
747732
Assembler();
@@ -852,7 +837,7 @@ class Assembler {
852837
void AddToImplList(mdToken);
853838
void ClearBoundList(void);
854839
//--------------------------------------------------------------------------------
855-
BOOL Init(BOOL generatePdb, PdbFormat pdbFormat);
840+
BOOL Init(BOOL generatePdb);
856841
void ProcessLabel(__in_z __in char *pszName);
857842
GlobalLabel *FindGlobalLabel(LPCUTF8 pszName);
858843
GlobalFixup *AddDeferredGlobalFixup(__in __nullterminated char *pszLabel, BYTE* reference);
@@ -1041,9 +1026,6 @@ class Assembler {
10411026

10421027
// Debug metadata paraphernalia
10431028
public:
1044-
ISymUnmanagedWriter* m_pSymWriter;
1045-
ISymUnmanagedDocumentWriter* m_pSymDocument;
1046-
DocWriterList m_DocWriterList;
10471029
ULONG m_ulCurLine; // set by Parser
10481030
ULONG m_ulCurColumn; // set by Parser
10491031
ULONG m_ulLastDebugLine;
@@ -1061,7 +1043,6 @@ class Assembler {
10611043

10621044
// Portable PDB paraphernalia
10631045
public:
1064-
PdbFormat m_pdbFormat;
10651046
PortablePdbWriter* m_pPortablePdbWriter;
10661047
char m_szPdbFileName[MAX_FILENAME_LENGTH * 3 + 1];
10671048
WCHAR m_wzPdbFileName[MAX_FILENAME_LENGTH];
@@ -1070,8 +1051,6 @@ class Assembler {
10701051
void SetPdbFileName(__in __nullterminated char* szName);
10711052
// Saves the pdb file.
10721053
HRESULT SavePdbFile();
1073-
// Checks whether pdb generation is portable
1074-
BOOL IsPortablePdb();
10751054

10761055
// Security paraphernalia
10771056
public:
@@ -1219,8 +1198,6 @@ class Assembler {
12191198
void AddMethodImpl(mdToken tkImplementedTypeSpec, __in __nullterminated char* szImplementedName, BinStr* pImplementedSig,
12201199
mdToken tkImplementingTypeSpec, __in_opt __nullterminated char* szImplementingName, BinStr* pImplementingSig);
12211200
BOOL EmitMethodImpls();
1222-
// lexical scope handling paraphernalia:
1223-
void EmitScope(Scope* pSCroot); // struct Scope - see Method.hpp
12241201
// source file name paraphernalia
12251202
BOOL m_fSourceFileSet;
12261203
void SetSourceFileName(__in __nullterminated char* szName);
@@ -1247,7 +1224,7 @@ class Assembler {
12471224
Clockwork* bClock;
12481225
void SetClock(Clockwork* val) { bClock = val; };
12491226
// ENC paraphernalia
1250-
HRESULT InitMetaDataForENC(__in __nullterminated WCHAR* wzOrigFileName, BOOL generatePdb, PdbFormat pdbFormat);
1227+
HRESULT InitMetaDataForENC(__in __nullterminated WCHAR* wzOrigFileName, BOOL generatePdb);
12511228
BOOL EmitFieldsMethodsENC(Class* pClass);
12521229
BOOL EmitEventsPropsENC(Class* pClass);
12531230
HRESULT CreateDeltaFiles(__in __nullterminated WCHAR *pwzOutputFilename);

src/coreclr/ilasm/grammar_after.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ Instr* SetupInstr(unsigned short opcode)
279279
if((pVal = PASM->GetInstr()))
280280
{
281281
pVal->opcode = opcode;
282-
if((pVal->pWriter = PASM->m_pSymDocument)!=NULL || PASM->IsPortablePdb())
282+
if(PASM->m_fGeneratePDB)
283283
{
284284
if(PENV->bExternSource)
285285
{
@@ -297,10 +297,10 @@ Instr* SetupInstr(unsigned short opcode)
297297
// Portable PDB rule:
298298
// - If Start Line is equal to End Line then End Column is greater than Start Column.
299299
// To fulfill this condition the column_end is set to 2 instead of 0
300-
pVal->column_end = PASM->IsPortablePdb() ? 2 : 0;
300+
pVal->column_end = 2;
301301
pVal->pc = PASM->m_CurPC;
302302
}
303-
pVal->pOwnerDocument = PASM->IsPortablePdb() ? PASM->m_pPortablePdbWriter->GetCurrentDocument() : NULL;
303+
pVal->pOwnerDocument = PASM->m_pPortablePdbWriter->GetCurrentDocument();
304304
}
305305
}
306306
return pVal;

0 commit comments

Comments
 (0)