[llvm-commits] [llvm-gcc-4.2] r63145 - in /llvm-gcc-4.2/branches/Apple/Dib/gcc: llvm-debug.cpp llvm-debug.h
Bill Wendling
isanbard at gmail.com
Tue Jan 27 14:37:27 PST 2009
Author: void
Date: Tue Jan 27 16:37:27 2009
New Revision: 63145
URL: http://llvm.org/viewvc/llvm-project?rev=63145&view=rev
Log:
Pull these patches into Dib:
r63133:
Keep track of context info. findRegion() is not comprehensive enough to find
appropriate scope in all cases, but it is significantly better then what
llvm-gcc ever did for debug info.
r63096:
Remove dead code.
r62856:
Set function linkage name appropriately. This allows debugger to find
fn/methods.
Modified:
llvm-gcc-4.2/branches/Apple/Dib/gcc/llvm-debug.cpp
llvm-gcc-4.2/branches/Apple/Dib/gcc/llvm-debug.h
Modified: llvm-gcc-4.2/branches/Apple/Dib/gcc/llvm-debug.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/branches/Apple/Dib/gcc/llvm-debug.cpp?rev=63145&r1=63144&r2=63145&view=diff
==============================================================================
--- llvm-gcc-4.2/branches/Apple/Dib/gcc/llvm-debug.cpp (original)
+++ llvm-gcc-4.2/branches/Apple/Dib/gcc/llvm-debug.cpp Tue Jan 27 16:37:27 2009
@@ -198,11 +198,6 @@
, PrevFullPath("")
, PrevLineNo(0)
, PrevBB(NULL)
-, StopPointFn(NULL)
-, FuncStartFn(NULL)
-, RegionStartFn(NULL)
-, RegionEndFn(NULL)
-, DeclareFn(NULL)
, RegionStack()
{
MainCompileUnit = createCompileUnit(main_input_filename);
@@ -216,42 +211,54 @@
expanded_location Loc = GetNodeLocation(FnDecl, false);
std::string Filename, Directory;
DirectoryAndFile(Loc.file, Directory, Filename);
+ const char *FnName = GetNodeName(FnDecl);
const char *LinkageName = getLinkageName(FnDecl);
- tree func_type = TREE_TYPE(FnDecl);
- llvm::SmallVector<llvm::DIDescriptor, 16> ArgTys;
- // Add the result type at least.
- ArgTys.push_back(getOrCreateType(TREE_TYPE(func_type)));
-
- // Set up remainder of arguments.
- for (tree arg = TYPE_ARG_TYPES(func_type); arg; arg = TREE_CHAIN(arg)) {
- tree formal_type = TREE_VALUE(arg);
- if (formal_type == void_type_node) break;
- ArgTys.push_back(getOrCreateType(formal_type));
- }
-
- llvm::DIArray FnTypeArray =
- DebugFactory.GetOrCreateArray(&ArgTys[0], ArgTys.size());
-
- llvm::DICompositeType FnTy =
- DebugFactory.CreateCompositeType(llvm::dwarf::DW_TAG_subroutine_type,
- MainCompileUnit, "",
- MainCompileUnit, 0, 0, 0, 0, 0,
- llvm::DIType(), FnTypeArray);
-
- DISubprogram SP = DebugFactory.CreateSubprogram(MainCompileUnit,
- Fn->getNameStr(),
- Fn->getNameStr(), LinkageName,
- MainCompileUnit, CurLineNo,
- FnTy,
- Fn->hasInternalLinkage(),
- true /*definition*/,
- &Filename, &Directory);
+ DISubprogram SP =
+ DebugFactory.CreateSubprogram(findRegion(FnDecl),
+ FnName, FnName, LinkageName,
+ MainCompileUnit, CurLineNo,
+ getOrCreateType(TREE_TYPE(FnDecl)),
+ Fn->hasInternalLinkage(),
+ true /*definition*/,
+ &Filename, &Directory);
DebugFactory.InsertSubprogramStart(SP, CurBB);
// Push function on region stack.
RegionStack.push_back(SP);
+ RegionMap[FnDecl] = SP;
+}
+
+ /// findRegion - Find tree_node N's region.
+DIDescriptor DebugInfo::findRegion(tree Node) {
+ if (Node == NULL_TREE)
+ return MainCompileUnit;
+
+ std::map<tree_node *, DIDescriptor>::iterator I = RegionMap.find(Node);
+ if (I != RegionMap.end())
+ return I->second;
+
+ if (TYPE_P (Node)) {
+ if (TYPE_CONTEXT (Node))
+ return findRegion (TYPE_CONTEXT(Node));
+ } else if (DECL_P (Node)) {
+ tree decl = Node;
+ tree context = NULL_TREE;
+ if (TREE_CODE (decl) != FUNCTION_DECL || ! DECL_VINDEX (decl))
+ context = DECL_CONTEXT (decl);
+ else
+ context = TYPE_MAIN_VARIANT
+ (TREE_TYPE (TREE_VALUE (TYPE_ARG_TYPES (TREE_TYPE (decl)))));
+
+ if (context && !TYPE_P (context))
+ context = NULL_TREE;
+ if (context != NULL_TREE)
+ return findRegion(context);
+ }
+
+ // Otherwise main compile unit covers everything.
+ return MainCompileUnit;
}
/// EmitRegionStart- Constructs the debug code for entering a declarative
@@ -402,7 +409,7 @@
DebugFactory.GetOrCreateArray(&EltTys[0], EltTys.size());
return DebugFactory.CreateCompositeType(llvm::dwarf::DW_TAG_subroutine_type,
- MainCompileUnit, "",
+ findRegion(type), "",
MainCompileUnit, 0, 0, 0, 0, 0,
llvm::DIType(), EltTypeArray);
}
@@ -417,7 +424,7 @@
TREE_CODE(type) == BLOCK_POINTER_TYPE) ?
DW_TAG_pointer_type :
DW_TAG_reference_type;
- return DebugFactory.CreateDerivedType(Tag, MainCompileUnit, "",
+ return DebugFactory.CreateDerivedType(Tag, findRegion(type), "",
MainCompileUnit, 0 /*line no*/,
NodeSizeInBits(type),
NodeAlignInBits(type),
@@ -471,7 +478,7 @@
DebugFactory.GetOrCreateArray(&Subscripts[0], Subscripts.size());
return DebugFactory.CreateCompositeType(llvm::dwarf::DW_TAG_array_type,
- MainCompileUnit, "",
+ findRegion(type), "",
MainCompileUnit,
0, NodeSizeInBits(type),
NodeAlignInBits(type), 0, 0,
@@ -500,7 +507,7 @@
std::string Filename, Directory;
DirectoryAndFile(Loc.file, Directory, Filename);
return DebugFactory.CreateCompositeType(llvm::dwarf::DW_TAG_enumeration_type,
- MainCompileUnit, GetNodeName(type),
+ findRegion(type), GetNodeName(type),
MainCompileUnit, Loc.line,
NodeSizeInBits(type),
NodeAlignInBits(type), 0, 0,
@@ -526,7 +533,9 @@
std::string Filename, Directory;
DirectoryAndFile(Loc.file, Directory, Filename);
llvm::DIType FwdDecl =
- DebugFactory.CreateCompositeType(Tag, MainCompileUnit, GetNodeName(type),
+ DebugFactory.CreateCompositeType(Tag,
+ findRegion(type),
+ GetNodeName(type),
MainCompileUnit, Loc.line,
0, 0, 0, llvm::DIType::FlagFwdDecl,
llvm::DIType(), llvm::DIArray(),
@@ -554,7 +563,7 @@
// FIXME : name, size, align etc...
DIType DTy =
DebugFactory.CreateDerivedType(DW_TAG_inheritance,
- MainCompileUnit,"",
+ findRegion(type),"",
MainCompileUnit, 0,0,0,
getInt64(BINFO_OFFSET(BInfo), 0),
0, BaseClass);
@@ -595,7 +604,7 @@
Flags = llvm::DIType::FlagPrivate;
DIType DTy =
- DebugFactory.CreateDerivedType(DW_TAG_member, MainCompileUnit,
+ DebugFactory.CreateDerivedType(DW_TAG_member, findRegion(Member),
MemberName, MainCompileUnit,
MemLoc.line, NodeSizeInBits(Member),
NodeAlignInBits(FieldNodeType),
@@ -619,10 +628,11 @@
DirectoryAndFile(MemLoc.file, MemDirectory, MemFilename);
const char *MemberName = GetNodeName(Member);
+ const char *LinkageName = getLinkageName(Member);
DIType SPTy = getOrCreateType(TREE_TYPE(Member));
DISubprogram SP =
- DebugFactory.CreateSubprogram(MainCompileUnit, MemberName, MemberName,
- MemberName, MainCompileUnit,
+ DebugFactory.CreateSubprogram(findRegion(Member), MemberName, MemberName,
+ LinkageName, MainCompileUnit,
MemLoc.line, SPTy, false, false,
&MemFilename, &MemDirectory);
@@ -633,7 +643,7 @@
DebugFactory.GetOrCreateArray(&EltTys[0], EltTys.size());
llvm::DIType RealDecl =
- DebugFactory.CreateCompositeType(Tag, MainCompileUnit,
+ DebugFactory.CreateCompositeType(Tag, findRegion(type),
GetNodeName(type),
MainCompileUnit, Loc.line,
NodeSizeInBits(type), NodeAlignInBits(type),
@@ -656,7 +666,7 @@
expanded_location TypeDefLoc = GetNodeLocation(Name);
std::string Filename, Directory;
DirectoryAndFile(TypeDefLoc.file, Directory, Filename);
- Ty = DebugFactory.CreateDerivedType(DW_TAG_typedef, MainCompileUnit,
+ Ty = DebugFactory.CreateDerivedType(DW_TAG_typedef, findRegion(type),
GetNodeName(Name),
MainCompileUnit, TypeDefLoc.line,
0 /*size*/,
@@ -672,7 +682,7 @@
if (TYPE_VOLATILE(type)) {
Ty = DebugFactory.CreateDerivedType(DW_TAG_volatile_type,
- MainCompileUnit, "",
+ findRegion(type), "",
MainCompileUnit, 0 /*line no*/,
NodeSizeInBits(type),
NodeAlignInBits(type),
@@ -684,7 +694,7 @@
if (TYPE_READONLY(type))
Ty = DebugFactory.CreateDerivedType(DW_TAG_const_type,
- MainCompileUnit, "",
+ findRegion(type), "",
MainCompileUnit, 0 /*line no*/,
NodeSizeInBits(type),
NodeAlignInBits(type),
Modified: llvm-gcc-4.2/branches/Apple/Dib/gcc/llvm-debug.h
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/branches/Apple/Dib/gcc/llvm-debug.h?rev=63145&r1=63144&r2=63145&view=diff
==============================================================================
--- llvm-gcc-4.2/branches/Apple/Dib/gcc/llvm-debug.h (original)
+++ llvm-gcc-4.2/branches/Apple/Dib/gcc/llvm-debug.h Tue Jan 27 16:37:27 2009
@@ -63,14 +63,10 @@
std::map<tree_node *, DIType> TypeCache;
// Cache of previously constructed
// Types.
- Function *StopPointFn; // llvm.dbg.stoppoint
- Function *FuncStartFn; // llvm.dbg.func.start
- Function *RegionStartFn; // llvm.dbg.region.start
- Function *RegionEndFn; // llvm.dbg.region.end
- Function *DeclareFn; // llvm.dbg.declare
std::vector<DIDescriptor> RegionStack;
// Stack to track declarative scopes.
+ std::map<tree_node *, DIDescriptor> RegionMap;
public:
DebugInfo(Module *m);
@@ -131,7 +127,9 @@
/// createCompileUnit - Create a new compile unit.
DICompileUnit createCompileUnit(const std::string &FullPath);
-
+
+ /// findRegion - Find tree_node N's region.
+ DIDescriptor findRegion(tree_node *n);
};
} // end namespace llvm
More information about the llvm-commits
mailing list