These fall into several classes, partitioned according to the contents of
objects.builtin and modules.builtin:
- - dtrace_ctf.builtin.ctf: The shared type repository. Types shared by more
- than one of the files below go here. Despite its name it is not DTrace-
- specific: it is named after the library that reads and writes it,
+ - shared_ctf.builtin.ctf: The shared type repository. Types shared by more
+ than one of the files below go here.
libdtrace-ctf). See 'Using dwarf2ctf output' below regarding use of this
data.
- vmlinux.builtin.ctf: Types in the core kernel, that cannot be built in to
is presently built in to the kernel.
- *.mod.ctf: One of these is generated for each .ko.
-All the files in the first three classes are linked into the dtrace_ctf.ko
-module under various names, an empty module containing nothing but CTF data.
+All the files in the first three classes are linked into the ctf.ko module under
+various names, an empty module containing nothing but CTF data.
A lengthy section of Makefile.modpost, and a short section of the toplevel
complex: modules and objects (ld -r'ed *.o files) are processed by dwarf2ctf to
produce a number of files in the .ctf directory, and the final modules depend on
the relevant ctf files. .mod.ctf's go into the .ko's with the same stem name,
-but dtrace_ctf.ko receives content from all the CTF files corresponding to
-built-in modules, and until dwarf2ctf runs and creates those files we cannot
-tell what those CTF files will be, though we do have a wildcard that matches
-them all.
+but ctf.ko receives content from all the CTF files corresponding to built-in
+modules, and until dwarf2ctf runs and creates those files we cannot tell what
+those CTF files will be, though we do have a wildcard that matches them all.
GNU Make's 'secondary expansion' feature comes to the rescue here: we can
compute a list of expected CTF filenames at runtime, given the names of the
modules we are linking in. For the builtin modules, we cheat and touch a stamp
file after moving any .ctf.new files back over a .ctf file, then depend on that
-to see if dtrace_ctf.ko needs to be relinked.
+to see if ctf.ko needs to be relinked.
The actual incorporation of the CTF data into the kernel modules happens before
module signing (if signing is active), by calling objcopy --add-section on the
Using this data is fairly simple. Once you've read the CTF sections from the
kernel modules and inflated them (or ignored them if they are empty or, as just
mentioned, one byte long), you simply need to look at the ctf_parent_name() for
-each module, and if it is set to "dtrace_ctf", call ctf_import() to set the
-parent of this module to the CTF data you have read from the
-.dtrace_ctf.dtrace_ctf section in the dtrace_ctf.ko kernel module. The core
-kernel's types are stored in the .dtrace_ctf.vmlinux section in the same kernel
-module, and all built-in kernel modules have their types in
-.dtrace_ctf.$module_name. Non-built-in kernel modules just have a .dtrace_ctf
-section containing their types, which again might need their parent set to
-"dtrace_ctf". (Out-of- tree kernel modules will have no such parent.)
+each module, and if it is set to "ctf", call ctf_import() to set the parent of
+this module to the CTF data you have read from the .ctf.shared_ctf section in
+the ctf.ko kernel module. The core kernel's types are stored in the
+.ctf.vmlinux section in the same kernel module, and all built-in kernel modules
+have their types in .ctf.$module_name. Non-built-in kernel modules just have a
+.ctf section containing their types, which again might need their parent set to
+"shared_ctf". (Out-of-tree kernel modules will have no such parent.)
Once you've set up the parenthood relationships you can call ctf_close() on the
shared type repository and forget about it entirely: it will be refcounted and
which maps type IDs to the module they appear in, with the two special cases
that types that appear only in the core kernel are said to appear in the module
'vmlinux', and types that appear in more than one module (or in a module and in
-the core kernel) are said to appear in the module 'dtrace_ctf', the shared type
+the core kernel) are said to appear in the module 'shared_ctf', the shared type
repository. This is quite a tricky multi-pass process, because we must ensure
that the shared type repository is self-contained: all types in the repository
must not reference any types outside the repository.
obj-$(CONFIG_CONTEXT_TRACKING) += context_tracking.o
obj-$(CONFIG_TORTURE_TEST) += torture.o
obj-$(CONFIG_DTRACE) += dtrace/
+obj-$(CONFIG_CTF) += ctf/
$(obj)/configs.o: $(obj)/config_data.h
--- /dev/null
+config CTF
+ bool "Compact Type Format generation"
+ default n
+ help
+ Emit a compact, compressed description of the kernel's datatypes and
+ global variables into .ctf sections in kernel modules. A module
+ 'ctf.ko' is also generated containing type information for built-in
+ modules, the core kernel, and types shared across multiple kernel
+ modules.
--- /dev/null
+#
+# Makefile for Compact Type Format storage
+#
+
+ifdef CONFIG_CTF
+obj-m += ctf.o
+endif
/*
- * FILE: dtrace_ctf.c
+ * FILE: ctf.c
* DESCRIPTION: Dynamic Tracing: CTF container module
*
* Copyright (C) 2012 Oracle Corporation
MODULE_AUTHOR("Nick Alcock <nick.alcock@oracle.com>");
MODULE_DESCRIPTION("CTF container module, not for modprobing");
-MODULE_VERSION("v0.1");
+MODULE_VERSION("v0.2");
MODULE_LICENSE("GPL");
-void dtrace_ctf_forceload(void) {
+void ctf_forceload(void) {
/* nothing doing */
}
-EXPORT_SYMBOL(dtrace_ctf_forceload);
+EXPORT_SYMBOL(ctf_forceload);
#
# DTrace Configuration
-# Copyright (C) 2010, 2011 Oracle Corporation
+# Copyright (C) 2010, 2011, 2012 Oracle Corporation
#
menuconfig DTRACE
default y
depends on X86_64 && !DEBUG_LOCK_ALLOC
select KALLSYMS
+ select CTF if (!DT_DISABLE_CTF)
select STRIP_ASM_SYMS if (!DT_DISABLE_CTF)
select DEBUG_INFO if (!DT_DISABLE_CTF)
help
ifdef CONFIG_DT_CORE
obj-y += dtrace_os.o dtrace_cpu.o \
dtrace_stubs_x86_64.o dtrace_sdt.o
-obj-m += dtrace_ctf.o
endif
#
config LIBFDT
bool
+#
+# CTF support is select'ed if needed
+#
+source "kernel/ctf/Kconfig"
config OID_REGISTRY
tristate
# Step 6), generate CTF for the entire kernel, or for the module alone if this
# is a build of an external module.
-ifdef CONFIG_DTRACE
+ifdef CONFIG_CTF
ifndef CONFIG_DT_DISABLE_CTF
# This is quite tricky. If called for non-external-modules, dwarf2ctf needs to
quiet_cmd_ctf = DWARF2CTF
cmd_ctf = scripts/dwarf2ctf/dwarf2ctf $(ctf-dir) objects.builtin modules.builtin scripts/dwarf2ctf/dedup.blacklist $^
builtins := $(shell cat objects.builtin 2>/dev/null)
-ctf-stamp := .ctf/dtrace-ctf.stamp
+ctf-stamp := .ctf/ctf.stamp
-# The dtrace CTF module depends on the CTF stamp file, in lieu of the builtin
+# The CTF module depends on the CTF stamp file, in lieu of the builtin
# CTF files whose names we cannot determine until it is too late.
-kernel/dtrace/dtrace_ctf.ko: .ctf/dtrace-ctf.stamp
+kernel/ctf/ctf.ko: .ctf/ctf.stamp
else
ctf-dir := $(KBUILD_EXTMOD)/.ctf
# Expands to a series of objcopy --add-section arguments to add all
# necessary CTF files to a module, with appropriate section names.
# We also take advantage of the opportunity to strip the guaranteed-
-# useless debugging information out of dtrace_ctf.ko at the same time.
+# useless debugging information out of ctf.ko at the same time.
-module-ctf-flags = $(if $(filter dtrace_ctf.ko dtrace_ctf.ko.unsigned,$(notdir $@)), \
+module-ctf-flags = $(if $(filter ctf.ko ctf.ko.unsigned,$(notdir $@)), \
--strip-debug \
$(foreach builtin,$(wildcard $(ctf-dir)/*.builtin.ctf), \
- --add-section $(patsubst %.builtin.ctf,.dtrace_ctf.%,$(notdir $(builtin)))=$(builtin)), \
- --add-section .dtrace_ctf=$(ctf-module-name))
+ --add-section $(patsubst %.builtin.ctf,.ctf.%,$(notdir $(builtin)))=$(builtin)), \
+ --add-section .ctf=$(ctf-module-name))
# We have to put content in our dummy no-CTF files because --add-section
# in binutils 2.20 silently fails if asked to add an empty file as a section.
test -f $$name || dd if=/dev/zero of=$$name bs=1 count=1 2>/dev/null; \
done
-else
+else # CONFIG_DT_DISABLE_CTF
module-ctfs-modular-prereq =
module-ctfs-builtin =
cmd-touch-ctf = @:
endif
-else
+else # !CONFIG_CTF
module-ctfs-modular-prereq =
module-ctfs-builtin =
/*
* A mapping from module name to ctf_file_t *. The CTF named 'vmlinux' is the
* CTF corresponding to the types in always-built-in translation units; the CTF
- * named 'dtrace_ctf' (not appearing in this mapping) is the CTF corresponding
+ * named 'shared_ctf' (not appearing in this mapping) is the CTF corresponding
* to types shared between more than one module (even between two currently-
* built-in modules: we do not distinguish at this level between built-in
* modules and non-built-in modules.)
/*
* Initialize a CTF type table, and possibly fill it with those special types
* that appear in CTF but not in DWARF (such as 'void'). (This filling happens
- * only for the type table named "dtrace_ctf", unless deduplication is turned
+ * only for the type table named "shared_ctf", unless deduplication is turned
* off, signified by the builtin_modules list being NULL.)
*
* If this is a local type table, and deduplication is active, make the global
init_tu_to_modules();
if (builtin_modules != NULL)
- init_ctf_table("dtrace_ctf");
+ init_ctf_table("shared_ctf");
scan_duplicates(starting_argv, argv);
/*
* Initialize a CTF type table, and possibly fill it with those special types
* that appear in CTF but not in DWARF (such as 'void'). (This filling happens
- * only for the type table named "dtrace_ctf", unless deduplication is turned
+ * only for the type table named "shared_ctf", unless deduplication is turned
* off, signified by the builtin_modules list being NULL.)
*
* If this is a local type table, and deduplication is active, make the global
ctf_file);
dw_ctf_trace("Initializing module: %s\n", module_name);
- if ((strcmp(module_name, "dtrace_ctf") == 0) ||
+ if ((strcmp(module_name, "shared_ctf") == 0) ||
(builtin_modules == NULL)) {
ctf_encoding_t void_encoding = { CTF_INT_SIGNED, 0, 0 };
ctf_encoding_t int_encoding = { CTF_INT_SIGNED, 0,
*/
if (ctf_import(ctf_file,
g_hash_table_lookup(module_to_ctf_file,
- "dtrace_ctf")) < 0) {
+ "shared_ctf")) < 0) {
fprintf(stderr, "Cannot set parent of CTF file for "
"module %s: %s\n", module_name,
ctf_errmsg(ctf_errno(ctf_file)));
exit(1);
}
- ctf_parent_name_set(ctf_file, "dtrace_ctf");
+ ctf_parent_name_set(ctf_file, "shared_ctf");
}
dw_ctf_trace("Created CTF file for module %s: %p\n",
!g_hash_table_lookup_extended(dedup_blacklist, module_name,
NULL, NULL))) {
mark_shared(die, NULL, data);
- mark_seen_contained(die, "dtrace_ctf");
+ mark_seen_contained(die, "shared_ctf");
}
/*
existing_module = g_hash_table_lookup(id_to_module, id);
if ((existing_module == NULL) ||
- (strcmp(existing_module, "dtrace_ctf") != 0)) {
+ (strcmp(existing_module, "shared_ctf") != 0)) {
dw_ctf_trace("Marking %s as duplicate\n", id);
g_hash_table_replace(id_to_module, xstrdup(id),
- xstrdup("dtrace_ctf"));
+ xstrdup("shared_ctf"));
/*
* Newly-marked structures or unions must trigger a new
opaque_id);
transparent_shared = ((transparent_module != NULL) &&
- (strcmp(transparent_module, "dtrace_ctf") == 0));
+ (strcmp(transparent_module, "shared_ctf") == 0));
opaque_shared = ((opaque_module != NULL) &&
- (strcmp(opaque_module, "dtrace_ctf") == 0));
+ (strcmp(opaque_module, "shared_ctf") == 0));
/*
* Transparent type needs sharing.
if (transparent_shared && !opaque_shared) {
dw_ctf_trace("Marking %s as duplicate\n", opaque_id);
g_hash_table_replace(id_to_module, xstrdup(opaque_id),
- xstrdup("dtrace_ctf"));
+ xstrdup("shared_ctf"));
}
free(opaque_id);
}
if ((strcmp(ctf_module, module_name) != 0) &&
- (strcmp(ctf_module, "dtrace_ctf") != 0)) {
+ (strcmp(ctf_module, "shared_ctf") != 0)) {
fprintf(stderr, "Internal error: within file %s, module %s, "
"type at DIE offset %lx with ID %s is in a different "
"non-shared module, %s.\n", file_name, module_name,
* die: The DWARF DIE.
* parent_die: Its parent, i.e. if a structure member, this is a structure: if
* top-level, this is a CU DIE.
- * ctf: The CTF file this object should go into (possibly dtrace_ctf).
+ * ctf: The CTF file this object should go into (possibly shared_ctf).
* parent_ctf_id: The CTF ID of the parent DIE, or -1 if none.
* parent_bias: any bias applied to structure members. Normally 0, may be
* nonzero for unnamed structure members.
if ((type_ref->ctf_file != ctf) &&
type_ref->ctf_file != g_hash_table_lookup(module_to_ctf_file,
- "dtrace_ctf")) {
+ "shared_ctf")) {
#ifdef DEBUG
fprintf(stderr, "%s: Internal error: lookup of %s found in "
"different file: %s/%s versus %s/%s.\n", locerrstr,
if ((new_type->ctf_file != ctf) &&
(new_type->ctf_file != g_hash_table_lookup(module_to_ctf_file,
- "dtrace_ctf"))) {
+ "shared_ctf"))) {
fprintf(stderr, "%s:%s: internal error: referenced type lookup "
"for member %s yields a different CTF file: %p versus "
"%p\n", locerrstr, dwarf_diename(&cu_die),
dw_ctf_trace("Writing out %s\n", module);
- if ((strcmp(module, "dtrace_ctf") == 0) ||
+ if ((strcmp(module, "shared_ctf") == 0) ||
(strcmp(module, "vmlinux") == 0))
builtin_module = 1;
else {