Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1677478

Re: [PATCH v2 4/8] objtool: add undwarf debuginfo generation

From Ingo Molnar <mingo@kernel.org>
Newsgroups linux.kernel
Subject Re: [PATCH v2 4/8] objtool: add undwarf debuginfo generation
Date 2017-06-29 09:30 +0200
Message-ID <tXC3M-4EX-13@gated-at.bofh.it> (permalink)
References <tXmV4-8uj-15@gated-at.bofh.it> <tXmV4-8uj-19@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


* Josh Poimboeuf <jpoimboe@redhat.com> wrote:

> +#ifndef _UNDWARF_TYPES_H
> +#define _UNDWARF_TYPES_H
> +
> +/*
> + * The UNDWARF_REG_* registers are base registers which are used to find other
> + * registers on the stack.
> + *
> + * The CFA (call frame address) is the value of the stack pointer on the
> + * previous frame, i.e. the caller's SP before it called the callee.
> + *
> + * The CFA is usually based on SP, unless a frame pointer has been saved, in
> + * which case it's based on BP.
> + *
> + * BP is usually either based on CFA or is undefined (meaning its value didn't
> + * change for the current frame).
> + *
> + * So the CFA base is usually either SP or BP, and the FP base is usually either
> + * CFA or undefined.  The rest of the base registers are needed for special
> + * cases like entry code and gcc aligned stacks.
> + */
> +#define UNDWARF_REG_UNDEFINED		0
> +#define UNDWARF_REG_CFA			1
> +#define UNDWARF_REG_DX			2
> +#define UNDWARF_REG_DI			3
> +#define UNDWARF_REG_BP			4
> +#define UNDWARF_REG_SP			5
> +#define UNDWARF_REG_R10			6
> +#define UNDWARF_REG_R13			7
> +#define UNDWARF_REG_BP_INDIRECT		8
> +#define UNDWARF_REG_SP_INDIRECT		9
> +#define UNDWARF_REG_MAX			15
> +
> +/*
> + * UNDWARF_TYPE_CFA: Indicates that cfa_reg+cfa_offset points to the caller's
> + * stack pointer (aka the CFA in DWARF terms).  Used for all callable
> + * functions, i.e.  all C code and all callable asm functions.
> + *
> + * UNDWARF_TYPE_REGS: Used in entry code to indicate that cfa_reg+cfa_offset
> + * points to a fully populated pt_regs from a syscall, interrupt, or exception.
> + *
> + * UNDWARF_TYPE_REGS_IRET: Used in entry code to indicate that
> + * cfa_reg+cfa_offset points to the iret return frame.
> + */
> +#define UNDWARF_TYPE_CFA		0
> +#define UNDWARF_TYPE_REGS		1
> +#define UNDWARF_TYPE_REGS_IRET		2
> +
> +/*
> + * This struct contains a simplified version of the DWARF Call Frame
> + * Information standard.  It contains only the necessary parts of the real
> + * DWARF, simplified for ease of access by the in-kernel unwinder.  It tells
> + * the unwinder how to find the previous SP and BP (and sometimes entry regs)
> + * on the stack for a given code address (IP).  Each instance of the struct
> + * corresponds to one or more code locations.
> + */
> +struct undwarf {
> +	short cfa_offset;
> +	short bp_offset;
> +	unsigned cfa_reg:4;
> +	unsigned bp_reg:4;
> +	unsigned type:2;
> +};

I never know straight away what 'CFA' stands for - could we please use natural 
names, i.e. something like:

struct undwarf {
	u16		sp_offset;
	u16		bp_offset;
	unsigned	sp_reg:4;
	unsigned	bp_reg:4;
	unsigned	type:2;
};

...

struct unwind_hint {
	u32		ip;
	u16		sp_offset;
	u8		sp_reg;
	u8		type;
};

?

Also note the slightly cleaner vertical alignment, plus the conversion to more 
stable data types: I believe various bits of tooling (perf and so) will eventually 
learn about undwarf, so having a well defined cross-arch data structure is 
probably of advantage.

Since we are not bound by DWARF anymore, we might as well use readable names and 
such?

Plus, shouldn't we use __packed for 'struct undwarf' to minimize the structure's 
size (to 6 bytes AFAICS?) - or is optimal packing of the main undwarf array 
already guaranteed on every platform with this layout?

Thanks,

	Ingo

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH v2 0/8] x86: undwarf unwinder Josh Poimboeuf <jpoimboe@redhat.com> - 2017-06-28 17:20 +0200
  [PATCH v2 4/8] objtool: add undwarf debuginfo generation Josh Poimboeuf <jpoimboe@redhat.com> - 2017-06-28 17:20 +0200
    Re: [PATCH v2 4/8] objtool: add undwarf debuginfo generation Ingo Molnar <mingo@kernel.org> - 2017-06-29 09:20 +0200
      Re: [PATCH v2 4/8] objtool: add undwarf debuginfo generation Josh Poimboeuf <jpoimboe@redhat.com> - 2017-06-29 15:50 +0200
    Re: [PATCH v2 4/8] objtool: add undwarf debuginfo generation Ingo Molnar <mingo@kernel.org> - 2017-06-29 09:30 +0200
      Re: [PATCH v2 4/8] objtool: add undwarf debuginfo generation Josh Poimboeuf <jpoimboe@redhat.com> - 2017-06-29 16:10 +0200
        Re: [PATCH v2 4/8] objtool: add undwarf debuginfo generation Ingo Molnar <mingo@kernel.org> - 2017-06-29 16:50 +0200
          Re: [PATCH v2 4/8] objtool: add undwarf debuginfo generation Josh Poimboeuf <jpoimboe@redhat.com> - 2017-06-29 17:10 +0200
  [PATCH v2 7/8] x86/asm: add unwind hint annotations to sync_core() Josh Poimboeuf <jpoimboe@redhat.com> - 2017-06-28 17:20 +0200
  [PATCH v2 2/8] objtool, x86: add several functions and files to the objtool whitelist Josh Poimboeuf <jpoimboe@redhat.com> - 2017-06-28 17:20 +0200
    [tip:core/objtool] objtool, x86: Add several functions and files to  the objtool whitelist tip-bot for Josh Poimboeuf <tipbot@zytor.com> - 2017-06-30 15:20 +0200
  [PATCH v2 6/8] x86/entry: add unwind hint annotations Josh Poimboeuf <jpoimboe@redhat.com> - 2017-06-28 17:20 +0200
    Re: [PATCH v2 6/8] x86/entry: add unwind hint annotations Josh Poimboeuf <jpoimboe@redhat.com> - 2017-06-29 20:00 +0200
      Re: [PATCH v2 6/8] x86/entry: add unwind hint annotations Andy Lutomirski <luto@kernel.org> - 2017-06-29 21:00 +0200
        Re: [PATCH v2 6/8] x86/entry: add unwind hint annotations Josh Poimboeuf <jpoimboe@redhat.com> - 2017-06-29 21:10 +0200
          Re: [PATCH v2 6/8] x86/entry: add unwind hint annotations Andy Lutomirski <luto@kernel.org> - 2017-06-29 23:20 +0200
            Re: [PATCH v2 6/8] x86/entry: add unwind hint annotations Josh Poimboeuf <jpoimboe@redhat.com> - 2017-06-29 23:50 +0200
              Re: [PATCH v2 6/8] x86/entry: add unwind hint annotations Andy Lutomirski <luto@amacapital.net> - 2017-06-30 01:00 +0200
                Re: [PATCH v2 6/8] x86/entry: add unwind hint annotations Josh Poimboeuf <jpoimboe@redhat.com> - 2017-06-30 04:20 +0200
                Re: [PATCH v2 6/8] x86/entry: add unwind hint annotations Andy Lutomirski <luto@kernel.org> - 2017-06-30 07:10 +0200
                Re: [PATCH v2 6/8] x86/entry: add unwind hint annotations Andy Lutomirski <luto@kernel.org> - 2017-06-30 07:50 +0200
                Re: [PATCH v2 6/8] x86/entry: add unwind hint annotations Josh Poimboeuf <jpoimboe@redhat.com> - 2017-06-30 15:20 +0200
                Re: [PATCH v2 6/8] x86/entry: add unwind hint annotations Andy Lutomirski <luto@kernel.org> - 2017-06-30 17:50 +0200
                Re: [PATCH v2 6/8] x86/entry: add unwind hint annotations Josh Poimboeuf <jpoimboe@redhat.com> - 2017-06-30 18:00 +0200
                Re: [PATCH v2 6/8] x86/entry: add unwind hint annotations Andy Lutomirski <luto@kernel.org> - 2017-06-30 18:00 +0200
                Re: [PATCH v2 6/8] x86/entry: add unwind hint annotations Josh Poimboeuf <jpoimboe@redhat.com> - 2017-06-30 18:20 +0200
  [PATCH v2 1/8] objtool: move checking code to check.c Josh Poimboeuf <jpoimboe@redhat.com> - 2017-06-28 17:20 +0200
  Re: [PATCH v2 0/8] x86: undwarf unwinder Ingo Molnar <mingo@kernel.org> - 2017-06-29 10:00 +0200
    Re: [PATCH v2 0/8] x86: undwarf unwinder Josh Poimboeuf <jpoimboe@redhat.com> - 2017-06-29 16:20 +0200
      Re: [PATCH v2 0/8] x86: undwarf unwinder Josh Poimboeuf <jpoimboe@redhat.com> - 2017-06-29 21:20 +0200
  Re: [PATCH v2 3/8] objtool: stack validation 2.0 Ingo Molnar <mingo@kernel.org> - 2017-06-30 10:40 +0200
    Re: [PATCH v2 3/8] objtool: stack validation 2.0 Josh Poimboeuf <jpoimboe@redhat.com> - 2017-06-30 15:30 +0200
      Re: [PATCH v2 3/8] objtool: stack validation 2.0 Josh Poimboeuf <jpoimboe@redhat.com> - 2017-06-30 15:30 +0200
    [PATCH] objtool: silence warnings for functions which use iret Josh Poimboeuf <jpoimboe@redhat.com> - 2017-06-30 16:10 +0200
      [tip:core/objtool] objtool: Silence warnings for functions which  use IRET tip-bot for Josh Poimboeuf <tipbot@zytor.com> - 2017-06-30 20:00 +0200

csiph-web