* [PATCH] kbuild: include core debug info when DEBUG_INFO_REDUCED
@ 2015-03-21 1:50 Rasmus Villemoes
2015-06-11 12:32 ` Rasmus Villemoes
0 siblings, 1 reply; 3+ messages in thread
From: Rasmus Villemoes @ 2015-03-21 1:50 UTC (permalink / raw)
To: Michal Marek, Andrew Morton; +Cc: linux-kbuild, Rasmus Villemoes, linux-kernel
With CONFIG_DEBUG_INFO_REDUCED, we do get quite a lot of debug info
(around 22.7 MB for a defconfig+DEBUG_INFO_REDUCED). However, the
"basenames must match" rule used by -femit-struct-debug-baseonly
option means that we miss some core data structures, such as struct
{device, file, inode, mm_struct, page} etc.
We can easily get these included as well, while still getting the
benefits of CONFIG_DEBUG_INFO_REDUCED (faster build times and smaller
individual object files): All it takes is a dummy translation unit
including a few strategic headers and compiled with a flag overriding
-femit-struct-debug-baseonly.
This increases the size of .debug_info by ~0.3%, but these 90 KB
contain some rather useful info.
Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
---
lib/Makefile | 3 +++
lib/debug_info.c | 27 +++++++++++++++++++++++++++
2 files changed, 30 insertions(+)
create mode 100644 lib/debug_info.c
diff --git a/lib/Makefile b/lib/Makefile
index 58f74d2dd396..3d788091d60c 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -45,6 +45,9 @@ CFLAGS_kobject.o += -DDEBUG
CFLAGS_kobject_uevent.o += -DDEBUG
endif
+obj-$(CONFIG_DEBUG_INFO_REDUCED) += debug_info.o
+CFLAGS_debug_info.o += $(call cc-option, -femit-struct-debug-detailed=any)
+
obj-$(CONFIG_GENERIC_IOMAP) += iomap.o
obj-$(CONFIG_GENERIC_PCI_IOMAP) += pci_iomap.o
obj-$(CONFIG_HAS_IOMEM) += iomap_copy.o devres.o
diff --git a/lib/debug_info.c b/lib/debug_info.c
new file mode 100644
index 000000000000..2edbe27517ed
--- /dev/null
+++ b/lib/debug_info.c
@@ -0,0 +1,27 @@
+/*
+ * This file exists solely to ensure debug information for some core
+ * data structures is included in the final image even for
+ * CONFIG_DEBUG_INFO_REDUCED. Please do not add actual code. However,
+ * adding appropriate #includes is fine.
+ */
+#include <stdarg.h>
+
+#include <linux/cred.h>
+#include <linux/crypto.h>
+#include <linux/dcache.h>
+#include <linux/device.h>
+#include <linux/fs.h>
+#include <linux/fscache-cache.h>
+#include <linux/io.h>
+#include <linux/kallsyms.h>
+#include <linux/kernel.h>
+#include <linux/kobject.h>
+#include <linux/mm.h>
+#include <linux/module.h>
+#include <linux/net.h>
+#include <linux/sched.h>
+#include <linux/slab.h>
+#include <linux/types.h>
+#include <net/addrconf.h>
+#include <net/sock.h>
+#include <net/tcp.h>
--
2.1.3
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] kbuild: include core debug info when DEBUG_INFO_REDUCED
2015-03-21 1:50 [PATCH] kbuild: include core debug info when DEBUG_INFO_REDUCED Rasmus Villemoes
@ 2015-06-11 12:32 ` Rasmus Villemoes
2015-06-11 13:35 ` Michal Marek
0 siblings, 1 reply; 3+ messages in thread
From: Rasmus Villemoes @ 2015-06-11 12:32 UTC (permalink / raw)
To: Michal Marek; +Cc: Andrew Morton, linux-kbuild, linux-kernel
On Sat, Mar 21 2015, Rasmus Villemoes <linux@rasmusvillemoes.dk> wrote:
> With CONFIG_DEBUG_INFO_REDUCED, we do get quite a lot of debug info
> (around 22.7 MB for a defconfig+DEBUG_INFO_REDUCED). However, the
> "basenames must match" rule used by -femit-struct-debug-baseonly
> option means that we miss some core data structures, such as struct
> {device, file, inode, mm_struct, page} etc.
>
> We can easily get these included as well, while still getting the
> benefits of CONFIG_DEBUG_INFO_REDUCED (faster build times and smaller
> individual object files): All it takes is a dummy translation unit
> including a few strategic headers and compiled with a flag overriding
> -femit-struct-debug-baseonly.
>
> This increases the size of .debug_info by ~0.3%, but these 90 KB
> contain some rather useful info.
>
Any comments on this patch? I know it's a little hacky, but I do find it
rather useful. For example, I just noticed that pahole shows this
struct audit_names {
struct list_head list; /* 0 0 */
/* XXX 16 bytes hole, try to pack */
when applied to a vmlinux built with DEBUG_INFO_REDUCED, since debug
info for struct list_head is not included. The same is true for a lot of
other types which are often embedded in structs (e.g. spinlock_t and
atomic_t). I could of course just compile without DEBUG_INFO_REDUCED,
but the time and space savings of that are real and sad to lose (my tree
is 1.8 GB larger when I compile without it).
Rasmus
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] kbuild: include core debug info when DEBUG_INFO_REDUCED
2015-06-11 12:32 ` Rasmus Villemoes
@ 2015-06-11 13:35 ` Michal Marek
0 siblings, 0 replies; 3+ messages in thread
From: Michal Marek @ 2015-06-11 13:35 UTC (permalink / raw)
To: Rasmus Villemoes; +Cc: Andrew Morton, linux-kbuild, linux-kernel
On Thu, Jun 11, 2015 at 02:32:48PM +0200, Rasmus Villemoes wrote:
> On Sat, Mar 21 2015, Rasmus Villemoes <linux@rasmusvillemoes.dk> wrote:
>
> > With CONFIG_DEBUG_INFO_REDUCED, we do get quite a lot of debug info
> > (around 22.7 MB for a defconfig+DEBUG_INFO_REDUCED). However, the
> > "basenames must match" rule used by -femit-struct-debug-baseonly
> > option means that we miss some core data structures, such as struct
> > {device, file, inode, mm_struct, page} etc.
> >
> > We can easily get these included as well, while still getting the
> > benefits of CONFIG_DEBUG_INFO_REDUCED (faster build times and smaller
> > individual object files): All it takes is a dummy translation unit
> > including a few strategic headers and compiled with a flag overriding
> > -femit-struct-debug-baseonly.
> >
> > This increases the size of .debug_info by ~0.3%, but these 90 KB
> > contain some rather useful info.
> >
>
> Any comments on this patch? I know it's a little hacky, but I do find it
> rather useful. For example, I just noticed that pahole shows this
I applied it to kbuild.git#kbuild now. It indeed can be quite useful.
Michal
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-06-11 13:35 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-03-21 1:50 [PATCH] kbuild: include core debug info when DEBUG_INFO_REDUCED Rasmus Villemoes
2015-06-11 12:32 ` Rasmus Villemoes
2015-06-11 13:35 ` Michal Marek
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox