for (I = 0; I < CollCount (&HLLDbgSyms); ++I) {
/* Get the next symbol */
- const HLLDbgSym* S = CollAtUnchecked (&HLLDbgSyms, I);
+ HLLDbgSym* S = CollAtUnchecked (&HLLDbgSyms, I);
/* Get the type of the symbol */
unsigned SC = HLL_GET_SC (S->Flags);
+ /* Remember if the symbol has debug info attached
+ * ### This should go into DbgInfoCheck
+ */
+ if (S->Sym && S->Sym->DebugSymId) {
+ S->Flags |= HLL_DATA_SYM;
+ }
+
/* Write the symbol data */
ObjWriteVar (S->Flags);
ObjWriteVar (S->Name);
- if (SC != HLL_SC_AUTO) {
- CHECK (S->Sym->DebugSymId != ~0U);
+ if (HLL_HAS_SYM (S->Flags)) {
ObjWriteVar (S->Sym->DebugSymId);
}
if (SC == HLL_SC_AUTO || SC == HLL_SC_REG) {
void FinishCompile (void)
-/* Emit literals, externals, do cleanup and optimizations */
+/* Emit literals, externals, debug info, do cleanup and optimizations */
{
SymTable* SymTab;
SymEntry* Func;
/* Output the literal pool */
OutputLiteralPool ();
+ /* Emit debug infos if enabled */
+ EmitDebugInfo ();
+
/* Write imported/exported symbols */
EmitExternals ();
-static void EmitDebugInfo (void)
+static void F_EmitDebugInfo (void)
/* Emit debug infos for the current function */
-{
- /* Fetch stuff for the current fuction */
- const SymEntry* Sym = CurrentFunc->FuncEntry;
- const FuncDesc* Desc = CurrentFunc->Desc;
- const SymTable* Tab = Desc->SymTab;
-
- /* Output info for the function itself */
- AddTextLine ("\t.dbg\tfunc, \"%s\", \"00\", %s, \"%s\"",
- Sym->Name,
- (Sym->Flags & SC_EXTERN)? "extern" : "static",
- Sym->AsmName);
-
- /* Output info for locals */
- Sym = Tab->SymHead;
- while (Sym) {
- if ((Sym->Flags & (SC_CONST|SC_TYPE)) == 0) {
- if (Sym->Flags & SC_AUTO) {
- AddTextLine ("\t.dbg\tsym, \"%s\", \"00\", auto, %d",
- Sym->Name, Sym->V.Offs);
- } else if (Sym->Flags & SC_REGISTER) {
- AddTextLine ("\t.dbg\tsym, \"%s\", \"00\", register, \"regbank\", %d",
- Sym->Name, Sym->V.R.RegOffs);
-
- } else {
- AddTextLine ("\t.dbg\tsym, \"%s\", \"00\", %s, \"%s\"",
- Sym->Name,
- (Sym->Flags & SC_EXTERN)? "extern" : "static",
- Sym->AsmName);
- }
- }
- Sym = Sym->NextSym;
+{
+ if (DebugInfo) {
+ /* Get the current fuction */
+ const SymEntry* Sym = CurrentFunc->FuncEntry;
+
+ /* Output info for the function itself */
+ AddTextLine ("\t.dbg\tfunc, \"%s\", \"00\", %s, \"%s\"",
+ Sym->Name,
+ (Sym->Flags & SC_EXTERN)? "extern" : "static",
+ Sym->AsmName);
}
}
EmitExternals ();
/* Emit function debug info */
+ F_EmitDebugInfo ();
EmitDebugInfo ();
/* Leave the lexical level */
+void EmitDebugInfo (void)
+/* Emit debug infos for the locals of the current scope */
+{
+ const char* Head;
+ const SymEntry* Sym;
+
+ /* Output info for locals if enabled */
+ if (DebugInfo) {
+ /* For cosmetic reasons in the output file, we will insert two tabs
+ * on global level and just one on local level.
+ */
+ if (LexicalLevel == LEX_LEVEL_GLOBAL) {
+ Head = "\t.dbg\t\tsym";
+ } else {
+ Head = "\t.dbg\tsym";
+ }
+ Sym = SymTab->SymHead;
+ while (Sym) {
+ if ((Sym->Flags & (SC_CONST|SC_TYPE)) == 0) {
+ if (Sym->Flags & SC_AUTO) {
+ AddTextLine ("%s, \"%s\", \"00\", auto, %d",
+ Head, Sym->Name, Sym->V.Offs);
+ } else if (Sym->Flags & SC_REGISTER) {
+ AddTextLine ("%s, \"%s\", \"00\", register, \"regbank\", %d",
+ Head, Sym->Name, Sym->V.R.RegOffs);
+
+ } else if (SymIsRef (Sym) && !SymIsDef (Sym)) {
+ AddTextLine ("%s, \"%s\", \"00\", %s, \"%s\"",
+ Head, Sym->Name,
+ (Sym->Flags & SC_EXTERN)? "extern" : "static",
+ Sym->AsmName);
+ }
+ }
+ Sym = Sym->NextSym;
+ }
+ }
+}
+
+
+
void EmitExternals (void);
/* Write import/export statements for external symbols */
+void EmitDebugInfo (void);
+/* Emit debug infos for the locals of the current scope */
+
/* End of symtab.h */
S->Flags = ReadVar (F);
SC = HLL_GET_SC (S->Flags);
S->Name = MakeGlobalStringId (O, ReadVar (F));
- if (SC != HLL_SC_AUTO) {
+ if (HLL_HAS_SYM (S->Flags)) {
S->Sym = GetObjDbgSym (O, ReadVar (F));
} else {
/* Auto variables aren't attached to asm symbols */
}
/* For non auto symbols output the debug symbol id of the asm sym */
- if (SC != HLL_SC_AUTO) {
+ if (HLL_HAS_SYM (S->Flags)) {
fprintf (F, ",sym=%u", S->Sym->Id);
}