This is the mail archive of the elfutils-devel@sourceware.org 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]

[patch 1/4] Fix dwfl_attach_state machine->elf


Hi Mark,

jankratochvil/ynonx86base-attach

'int machine' does not work as libebl/eblopenbackend.c contains:
        /* Prefer taking the information from the ELF file.  */
        if (elf == NULL)
          {
            result->machine = machines[cnt].em;
            result->class = machines[cnt].class;
            result->data = machines[cnt].data;
          }
        else
          {
            result->machine = elf->state.elf32.ehdr->e_machine;
            result->class = elf->state.elf32.ehdr->e_ident[EI_CLASS];
            result->data = elf->state.elf32.ehdr->e_ident[EI_DATA];
          }
+
  { "s390", "ebl_s390", "s390", 4, EM_S390, 0, 0 },
                                            ^=class

This means that without Elf * one cannot get eh->class properly set in
s390_init() (for 32-bit s390 vs. 64-bit s390x).

The second choice would be to somehow change libebl/eblopenbackend.c...

This change is visible only on the later s390 support [patch 4/4].


Thanks,
Jan


Fix dwfl_attach_state machine->elf

libdwfl/
2013-11-10  Jan Kratochvil  <jan.kratochvil@redhat.com>

	Fix dwfl_attach_state machine->elf.
	* dwfl_frame.c (dwfl_attach_state): Change parameter machine to elf.
	Call ebl_openbackend instead of ebl_openbackend_machine.
	* libdwfl.h (dwfl_attach_state): Change parameter machine to elf.
	Update the function description.
	* linux-core-attach.c (__libdwfl_attach_state_for_core): Pass CORE to
	dwfl_attach_state.
	* linux-pid-attach.c (__libdwfl_attach_state_for_pid): Pass NULL to
	dwfl_attach_state.

tests/
2013-11-10  Jan Kratochvil  <jan.kratochvil@redhat.com>

	Fix dwfl_attach_state machine->elf.
	* backtrace-data.c (main): Pass NULL to dwfl_attach_state.

Signed-off-by: Jan Kratochvil <jan.kratochvil@redhat.com>

--- a/libdwfl/dwfl_frame.c
+++ b/libdwfl/dwfl_frame.c
@@ -131,7 +131,7 @@ process_alloc (Dwfl *dwfl)
 }
 
 bool
-dwfl_attach_state (Dwfl *dwfl, int machine, pid_t pid,
+dwfl_attach_state (Dwfl *dwfl, Elf *elf, pid_t pid,
 		   const Dwfl_Thread_Callbacks *thread_callbacks, void *arg)
 {
   if (thread_callbacks == NULL || thread_callbacks->next_thread == NULL
@@ -147,9 +147,9 @@ dwfl_attach_state (Dwfl *dwfl, int machine, pid_t pid,
     }
   Ebl *ebl;
   bool ebl_close;
-  if (machine != EM_NONE)
+  if (elf != NULL)
     {
-      ebl = ebl_openbackend_machine (machine);
+      ebl = ebl_openbackend (elf);
       ebl_close = true;
     }
   else
--- a/libdwfl/libdwfl.h
+++ b/libdwfl/libdwfl.h
@@ -625,13 +625,13 @@ typedef struct
 } Dwfl_Thread_Callbacks;
 
 /* PID is the process id associated with the DWFL state.  Architecture of DWFL
-   modules is specified by MACHINE.  Use EM_NONE to detect architecture from
-   DWFL.  If EBL is NULL the function will detect it from arbitrary Dwfl_Module
-   of DWFL.  DWFL_ARG is the callback backend state.  DWFL_ARG will be provided
-   to the callbacks.  *THREAD_CALLBACKS function pointers must remain valid
-   during lifetime of DWFL.  Function returns true on success,
-   false otherwise.  */
-bool dwfl_attach_state (Dwfl *dwfl, int machine, pid_t pid,
+   modules is specified by ELF, ELF must remain valid during DWFL lifetime.
+   Use NULL ELF to detect architecture from DWFL, the function will then detect
+   it from arbitrary Dwfl_Module of DWFL.  DWFL_ARG is the callback backend
+   state.  DWFL_ARG will be provided to the callbacks.  *THREAD_CALLBACKS
+   function pointers must remain valid during lifetime of DWFL.  Function
+   returns true on success, false otherwise.  */
+bool dwfl_attach_state (Dwfl *dwfl, Elf *elf, pid_t pid,
                         const Dwfl_Thread_Callbacks *thread_callbacks,
 			void *dwfl_arg)
   __nonnull_attribute__ (1, 4);
--- a/libdwfl/linux-core-attach.c
+++ b/libdwfl/linux-core-attach.c
@@ -369,8 +369,8 @@ __libdwfl_attach_state_for_core (Dwfl *dwfl, Elf *core)
   core_arg->note_data = note_data;
   core_arg->thread_note_offset = 0;
   core_arg->ebl = ebl;
-  if (! INTUSE(dwfl_attach_state) (dwfl, ebl_get_elfmachine (ebl), pid,
-				   &core_thread_callbacks, core_arg))
+  if (! INTUSE(dwfl_attach_state) (dwfl, core, pid, &core_thread_callbacks,
+				   core_arg))
     {
       free (core_arg);
       ebl_closebackend (ebl);
--- a/libdwfl/linux-pid-attach.c
+++ b/libdwfl/linux-pid-attach.c
@@ -271,7 +271,7 @@ __libdwfl_attach_state_for_pid (Dwfl *dwfl, pid_t pid)
     }
   pid_arg->dir = dir;
   pid_arg->tid_attached = 0;
-  if (! INTUSE(dwfl_attach_state) (dwfl, EM_NONE, pid, &pid_thread_callbacks,
+  if (! INTUSE(dwfl_attach_state) (dwfl, NULL, pid, &pid_thread_callbacks,
 				   pid_arg))
     {
       closedir (dir);
--- a/tests/backtrace-data.c
+++ b/tests/backtrace-data.c
@@ -287,7 +287,7 @@ main (int argc __attribute__ ((unused)), char **argv __attribute__ ((unused)))
   assert (l == 0);
   report_module (dwfl, child, user_regs.rip);
 
-  bool ok = dwfl_attach_state (dwfl, EM_NONE, child, &callbacks, NULL);
+  bool ok = dwfl_attach_state (dwfl, NULL, child, &callbacks, NULL);
   assert (ok);
 
   /* Multiple threads are not handled here.  */

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