Hi,
dependent on: [patch 1/4] unwinder: New base address based dwfl_report_elf_baseaddr
present in: jankratochvil/forunwind-baseaddr-hookvars but this branch is not suitable for merge as it is unclear in which form get checked in the patches above. The branch is usable only for "git checkout", neither diff nor merge should be done on it.
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.
I can sure easily rework the remaining patches if I really should use a function doing nothing else than returning a number.
Thanks, Jan
backends/ 2012-11-13 Jan Kratochvil jan.kratochvil@redhat.com
* libebl_CPU.h (EBLHOOKVAR): New definition. * libeblP.h (EBLHOOKVAR): New definition and its new undef.
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 EBLHOOKVAR EBLHOOK #define EBLHOOK_1(a, b) EBLHOOK_2(a, b) #define EBLHOOK_2(a, b) a##b
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. */
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 jan.kratochvil@redhat.com
- 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 EBLHOOKVAR EBLHOOK #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?
Cheers,
Mark
On Tue, 28 May 2013 12:46:34 +0200, Mark Wielaard wrote:
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?
Yes, I see the EBLHOOKVAR macro not only is not useful but it even has wrong side-effect: $ nm ./backends/libebl_x86_64.so|grep frame_state_nregs 00000000002110e0 b i386_frame_state_nregs 00000000002110d8 b x86_64_frame_state_nregs
These global variables are not used anywhere and I never intended to create them.
EBLHOOK macro purpose is to create prototypes for functions but that is not useful for variables.
OK, this patch is dropped and I will remove its use from the rest of the series.
Thanks, Jan
elfutils-devel@lists.fedorahosted.org