move process specific debug definitions to its own header file, thus fixing compiler warnings
This commit is contained in:
parent
ce5b3ee705
commit
eb4b5767ee
5 changed files with 73 additions and 63 deletions
2
Makefile
2
Makefile
|
|
@ -31,7 +31,7 @@ RTDISASM_TEST_DEPS := $(addprefix $(INC_DIR)/,$(RTDISASM_TEST_DEPS)) $(SHARED_D
|
||||||
BLACKJACK_SRC = main.c process.c
|
BLACKJACK_SRC = main.c process.c
|
||||||
BLACKJACK_OBJ := $(addprefix $(OBJ_DIR)/,$(patsubst %.s,%.o,$(patsubst %.c,%.o,$(BLACKJACK_SRC)))) $(SHARED_OBJ)
|
BLACKJACK_OBJ := $(addprefix $(OBJ_DIR)/,$(patsubst %.s,%.o,$(patsubst %.c,%.o,$(BLACKJACK_SRC)))) $(SHARED_OBJ)
|
||||||
BLACKJACK_SRC := $(addprefix $(SRC_DIR)/,$(BLACKJACK_SRC))
|
BLACKJACK_SRC := $(addprefix $(SRC_DIR)/,$(BLACKJACK_SRC))
|
||||||
BLACKJACK_DEPS = process.h
|
BLACKJACK_DEPS = process.h process_debug.h
|
||||||
BLACKJACK_DEPS := $(addprefix $(INC_DIR)/,$(BLACKJACK_DEPS)) rtdisasm $(SHARED_DEPS)
|
BLACKJACK_DEPS := $(addprefix $(INC_DIR)/,$(BLACKJACK_DEPS)) rtdisasm $(SHARED_DEPS)
|
||||||
|
|
||||||
DUMMY_TARGET_SRC = dummy_target.c dummy_destination.s
|
DUMMY_TARGET_SRC = dummy_target.c dummy_destination.s
|
||||||
|
|
|
||||||
|
|
@ -3,70 +3,9 @@
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <sys/user.h>
|
|
||||||
#define TRACE(fmt, ...) fprintf(stderr, "%s:%d:%s\tTRACE\t" fmt, __FILE__, __LINE__, __func__, ##__VA_ARGS__)
|
#define TRACE(fmt, ...) fprintf(stderr, "%s:%d:%s\tTRACE\t" fmt, __FILE__, __LINE__, __func__, ##__VA_ARGS__)
|
||||||
static void print_registers(const struct user_regs_struct* regs)
|
|
||||||
{
|
|
||||||
fprintf(stderr,
|
|
||||||
"r15\t%p\n"
|
|
||||||
"r14\t%p\n"
|
|
||||||
"r13\t%p\n"
|
|
||||||
"r12\t%p\n"
|
|
||||||
"rbp\t%p\n"
|
|
||||||
"rbx\t%p\n"
|
|
||||||
"r11\t%p\n"
|
|
||||||
"r10\t%p\n"
|
|
||||||
"r9\t%p\n"
|
|
||||||
"r8\t%p\n"
|
|
||||||
"rax\t%p\n"
|
|
||||||
"rcx\t%p\n"
|
|
||||||
"rdx\t%p\n"
|
|
||||||
"rsi\t%p\n"
|
|
||||||
"rdi\t%p\n"
|
|
||||||
"orig_rax\t%p\n"
|
|
||||||
"rip\t%p\n"
|
|
||||||
"cs\t%p\n"
|
|
||||||
"eflags\t%p\n"
|
|
||||||
"rsp\t%p\n"
|
|
||||||
"ss\t%p\n"
|
|
||||||
"fs_base\t%p\n"
|
|
||||||
"gs_base\t%p\n"
|
|
||||||
"ds\t%p\n"
|
|
||||||
"es\t%p\n"
|
|
||||||
"fs\t%p\n"
|
|
||||||
"gs\t%p\n",
|
|
||||||
(void*)regs->r15,
|
|
||||||
(void*)regs->r14,
|
|
||||||
(void*)regs->r13,
|
|
||||||
(void*)regs->r12,
|
|
||||||
(void*)regs->rbp,
|
|
||||||
(void*)regs->rbx,
|
|
||||||
(void*)regs->r11,
|
|
||||||
(void*)regs->r10,
|
|
||||||
(void*)regs->r9,
|
|
||||||
(void*)regs->r8,
|
|
||||||
(void*)regs->rax,
|
|
||||||
(void*)regs->rcx,
|
|
||||||
(void*)regs->rdx,
|
|
||||||
(void*)regs->rsi,
|
|
||||||
(void*)regs->rdi,
|
|
||||||
(void*)regs->orig_rax,
|
|
||||||
(void*)regs->rip,
|
|
||||||
(void*)regs->cs,
|
|
||||||
(void*)regs->eflags,
|
|
||||||
(void*)regs->rsp,
|
|
||||||
(void*)regs->ss,
|
|
||||||
(void*)regs->fs_base,
|
|
||||||
(void*)regs->gs_base,
|
|
||||||
(void*)regs->ds,
|
|
||||||
(void*)regs->es,
|
|
||||||
(void*)regs->fs,
|
|
||||||
(void*)regs->gs
|
|
||||||
);
|
|
||||||
}
|
|
||||||
#else
|
#else
|
||||||
#define TRACE(fmt, ...)
|
#define TRACE(fmt, ...)
|
||||||
#define print_registers(regs)
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
70
include/process_debug.h
Normal file
70
include/process_debug.h
Normal file
|
|
@ -0,0 +1,70 @@
|
||||||
|
#ifndef __PROCESS_DEBUG_H
|
||||||
|
#define __PROCESS_DEBUG_H
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <sys/user.h>
|
||||||
|
static void print_registers(const struct user_regs_struct* regs)
|
||||||
|
{
|
||||||
|
fprintf(stderr,
|
||||||
|
"r15\t%p\n"
|
||||||
|
"r14\t%p\n"
|
||||||
|
"r13\t%p\n"
|
||||||
|
"r12\t%p\n"
|
||||||
|
"rbp\t%p\n"
|
||||||
|
"rbx\t%p\n"
|
||||||
|
"r11\t%p\n"
|
||||||
|
"r10\t%p\n"
|
||||||
|
"r9\t%p\n"
|
||||||
|
"r8\t%p\n"
|
||||||
|
"rax\t%p\n"
|
||||||
|
"rcx\t%p\n"
|
||||||
|
"rdx\t%p\n"
|
||||||
|
"rsi\t%p\n"
|
||||||
|
"rdi\t%p\n"
|
||||||
|
"orig_rax\t%p\n"
|
||||||
|
"rip\t%p\n"
|
||||||
|
"cs\t%p\n"
|
||||||
|
"eflags\t%p\n"
|
||||||
|
"rsp\t%p\n"
|
||||||
|
"ss\t%p\n"
|
||||||
|
"fs_base\t%p\n"
|
||||||
|
"gs_base\t%p\n"
|
||||||
|
"ds\t%p\n"
|
||||||
|
"es\t%p\n"
|
||||||
|
"fs\t%p\n"
|
||||||
|
"gs\t%p\n",
|
||||||
|
(void*)regs->r15,
|
||||||
|
(void*)regs->r14,
|
||||||
|
(void*)regs->r13,
|
||||||
|
(void*)regs->r12,
|
||||||
|
(void*)regs->rbp,
|
||||||
|
(void*)regs->rbx,
|
||||||
|
(void*)regs->r11,
|
||||||
|
(void*)regs->r10,
|
||||||
|
(void*)regs->r9,
|
||||||
|
(void*)regs->r8,
|
||||||
|
(void*)regs->rax,
|
||||||
|
(void*)regs->rcx,
|
||||||
|
(void*)regs->rdx,
|
||||||
|
(void*)regs->rsi,
|
||||||
|
(void*)regs->rdi,
|
||||||
|
(void*)regs->orig_rax,
|
||||||
|
(void*)regs->rip,
|
||||||
|
(void*)regs->cs,
|
||||||
|
(void*)regs->eflags,
|
||||||
|
(void*)regs->rsp,
|
||||||
|
(void*)regs->ss,
|
||||||
|
(void*)regs->fs_base,
|
||||||
|
(void*)regs->gs_base,
|
||||||
|
(void*)regs->ds,
|
||||||
|
(void*)regs->es,
|
||||||
|
(void*)regs->fs,
|
||||||
|
(void*)regs->gs
|
||||||
|
);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
#define print_registers(regs)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
#define _DEFAULT_SOURCE
|
#define _DEFAULT_SOURCE
|
||||||
#include "process.h"
|
#include "process.h"
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
|
#include "process_debug.h"
|
||||||
#include <sys/capability.h>
|
#include <sys/capability.h>
|
||||||
#include <sys/ptrace.h>
|
#include <sys/ptrace.h>
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
|
|
|
||||||
|
|
@ -7,4 +7,4 @@ test_1:
|
||||||
mov %gs:(%rbx), %rax
|
mov %gs:(%rbx), %rax
|
||||||
|
|
||||||
nop # target that rtdisasm must reach
|
nop # target that rtdisasm must reach
|
||||||
test_1_end:
|
test_1_end:
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue