This is the mail archive of the mailing list for the elfutils project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch 2/4] unwinder: Provide EBLHOOKVAR

On Tue, 2012-11-13 at 21:31 +0100, Jan Kratochvil wrote:
> Currently EBL backends support functions via EBLHOOK.  Providing variables is
> done via a function returning value such as via current x86_64_register_info.
> I find it needlessly complicated, backends can provide also
> variables/constants.
> [...]
> 2012-11-13  Jan Kratochvil  <>
> 	* libebl_CPU.h (EBLHOOKVAR): New definition.
> 	* libeblP.h (EBLHOOKVAR): New definition and its new undef.

So the idea is that a <type> EBLHOOKVAR(name); is added to ebl-hooks.h.
That adds the name to the struct ebl (Ebl), and then the backend init
function sets it? Then you just define a generic ebl_name() accessor to
return the value given the ebl instance used?

It would probably be possible to define the generic accessor also
automagically with some defines, but that might overdesign things.
Especially if in practice it is only used once.

> diff --git a/backends/libebl_CPU.h b/backends/libebl_CPU.h
> index 36b3a4a..65a9a13 100644
> --- a/backends/libebl_CPU.h
> +++ b/backends/libebl_CPU.h
> @@ -32,6 +32,7 @@
>  #include <libeblP.h>
>  #define EBLHOOK(name)	EBLHOOK_1(BACKEND, name)
>  #define EBLHOOK_1(a, b)	EBLHOOK_2(a, b)
>  #define EBLHOOK_2(a, b)	a##b

I dont' fully understand how the EBLHOOKVAR -> EBLHOOK expands.

It would make sense to me to:
#define HOOKVAR(eh, name, val)  eh->name = val
Like we have a define for HOOK, that can be used in the _init functions.
But that might overdesign things.

> diff --git a/libebl/libeblP.h b/libebl/libeblP.h
> index c8196bd..773b6b8 100644
> --- a/libebl/libeblP.h
> +++ b/libebl/libeblP.h
> @@ -54,7 +54,9 @@ struct ebl
>    /* See ebl-hooks.h for the declarations of the hook functions.  */
>  # define EBLHOOK(name) (*name)
> +# define EBLHOOKVAR(name) (name)
>  # include "ebl-hooks.h"
> +# undef EBLHOOKVAR
>  # undef EBLHOOK
>    /* Size of entry in Sysv-style hash table.  */

Hmmm, after reading it all and now seeing the Sysv-style hash table,
lets not define some "generic defines" for adding these variables.

If it is just for one or two variables, lets just do like
sysvhash_entrysize. Add any variables used directly to the ebl struct in
libebl/libeblP.h. Initialize them to something sane in the
libebl/eblopenbackend.c and let any backends that want to override the
value in their init function.

Does that make sense for your use case?



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]