1
0
Fork 0
mirror of https://github.com/tobast/libunwind-eh_elf.git synced 2024-06-27 20:01:45 +02:00

Init eh_elf structures upon unw_init_*

This commit is contained in:
Théophile Bastian 2018-05-31 16:39:53 +02:00
parent da7446a21a
commit 4fb0baaa89
4 changed files with 64 additions and 0 deletions

16
src/eh_elf/eh_elf.c Normal file
View file

@ -0,0 +1,16 @@
/********** Libunwind -- eh_elf flavour **********
* This is the eh_elf version of libunwind, made for academic purposes.
*
* Théophile Bastian <theophile.bastian@ens.fr> <contact+github@tobast.fr>
*************************************************
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
************************************************/
#include "eh_elf_i.h"

42
src/eh_elf/eh_elf.h Normal file
View file

@ -0,0 +1,42 @@
/********** Libunwind -- eh_elf flavour **********
* This is the eh_elf version of libunwind, made for academic purposes.
*
* Théophile Bastian <theophile.bastian@ens.fr> <contact+github@tobast.fr>
*************************************************
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
************************************************/
#pragma once
#include <sys/types.h>
#include "libunwind_i.h"
/// Store the necessary data for a single eh_elf
typedef struct {
// TODO
} eh_elf_handle_t;
/** Initialize everything for local memory analysis
* @return 0 on success, or a negative value upon failure
**/
int eh_elf_init_local();
/** Initialize everything for the remote analysis of the process of given PID
* @return 0 on success, or a negative value upon failure
**/
int eh_elf_init_pid(pid_t pid);
/// Cleanup everything that was allocated by eh_elf_init_*
void eh_elf_clean();
/** Step the cursor using eh_elf mechanisms.
*
* Return 0 if everything went file, otherwise, return a negative value.
**/
int eh_elf_step_cursor(struct cursor *cursor);

View file

@ -26,6 +26,7 @@ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
#include "unwind_i.h"
#include "../eh_elf/eh_elf.h"
#include "init.h"
#ifdef UNW_REMOTE_ONLY
@ -41,6 +42,8 @@ unw_init_local (unw_cursor_t *cursor, ucontext_t *uc)
PROTECTED int
unw_init_local (unw_cursor_t *cursor, ucontext_t *uc)
{
eh_elf_init_local();
struct cursor *c = (struct cursor *) cursor;
if (unlikely (!tdep_init_done))

View file

@ -26,6 +26,7 @@ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
#include "init.h"
#include "../eh_elf/eh_elf.h"
#include "unwind_i.h"
PROTECTED int
@ -41,6 +42,8 @@ unw_init_remote (unw_cursor_t *cursor, unw_addr_space_t as, void *as_arg)
Debug (1, "(cursor=%p)\n", c);
eh_elf_init_pid(as.acc.get_pid(as_arg));
c->dwarf.as = as;
if (as == unw_local_addr_space)
{