[llvm-commits] DebugInfoBuilder
Evan Cheng
evan.cheng at apple.com
Tue Aug 5 13:22:40 PDT 2008
Very nice! This is sorely needed. Some comments:
+ // Calculate the size of the specified LLVM type.
+ Constant * Sizeof(const Type * type);
+
+ // Calculate the alignment of the specified LLVM type.
+ Constant * Alignof(const Type * type);
I find these names confusing. Perhaps getSize and getAlignment? That
follows the convention which are used elsewhere in LLVM.
+ /// Set the reference to the module where we will insert
debugging information.
+ /// Also defines the debug info types for the module and creates
the initial anchors.
+ /// Also changes the current context to the global context for
that module.
+ void SetModule(Module * m);
80 column please. :-)
+//
=
=
=----------------------------------------------------------------------
===//
+// Debug version -- copied from MachineModuleInfo (for now), in order
to avoid
+// creating a dependency on CodeGen. These declarations really should
be moved
+// to a better place where modules can get at them without being
dependent on
+// CodeGen.
+enum {
+ LLVMDebugVersion = (6 << 16), // Current version of debug
information.
+ LLVMDebugVersion5 = (5 << 16), // Constant for version 5.
+ LLVMDebugVersion4 = (4 << 16), // Constant for version 4.
+ LLVMDebugVersionMask = 0xffff0000 // Mask for version number.
+};
What are the different versions?
+GlobalVariable *
DebugInfoBuilder::CreateCompileUnitDescriptor(unsigned langId,
+ const sys::Path & srcPath, const std::string & producer) {
+
+ if (compileUnit == NULL) {
+ std::vector<Constant *> values;
+ values.push_back(ConstantInt::get(Type::Int32Ty,
LLVMDebugVersion + dwarf::DW_TAG_compile_unit));
+ values.push_back(ConstantExpr::getBitCast(compileUnitAnchor,
anyPtrType));
+ values.push_back(ConstantInt::get(Type::Int32Ty, langId));
+ values.push_back(ConstantArray::get(srcPath.getLast()));
+ values.push_back(ConstantArray::get(srcPath.getDirname() +
"/"));
+ values.push_back(ConstantArray::get(producer));
+
+ Constant * structVal = ConstantStruct::get(values, false);
It would be nice if there is a ConstantStruct::get that takes
SmallVectorImpl instead (hint :-). Then we can avoid heap allocation
for a small vector.
Thanks,
Evan
On Aug 5, 2008, at 11:35 AM, Talin wrote:
> The attached patch file contains an initial implementation of
> DebugInfoBuilder, which is intended to help generate DWARF debugging
> information. Currently it only has support for creating global
> descriptors, I have not yet implemented descriptors for aggregate
> types or stop points.
>
> The API tries to simplify the task of creating descriptors by using
> the IR types. For example, instead of having to manually specify the
> size and alignment of an integer, you can just pass an IntegerType
> to CreateIntegerTypeDescriptor and it will figure that out for you.
> However, in some cases you'll need to pass extra information which
> is not represented in the IR - so for example
> CreateIntegerTypeDescriptor takes an argument indicating whether the
> type is intended to be signed or unsigned (since the IR integer type
> has no concept of signed-ness.)
>
> --
> -- Talin
> <DIB.patch>_______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
More information about the llvm-commits
mailing list