Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Xin Tong committed Oct 8, 2014
1 parent 5a3607d commit e847842
Show file tree
Hide file tree
Showing 15 changed files with 67 additions and 102 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ libqemuutil.a: $(util-obj-y) qapi-types.o qapi-visit.o
######################################################################

qemu-img.o: qemu-img-cmds.h
qemu-adebug.o: qemu-adebug.h
qemu-adebug.o: qemu-adebug.h

qemu-img$(EXESUF): qemu-img.o $(block-obj-y) libqemuutil.a libqemustub.a
qemu-nbd$(EXESUF): qemu-nbd.o $(block-obj-y) libqemuutil.a libqemustub.a
Expand Down
1 change: 1 addition & 0 deletions Makefile.target
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ ifndef CONFIG_HAIKU
LIBS+=-lm
endif

# Loading user plugin modules.
LIBS+=-ldl

ifdef QEMU_PROGW
Expand Down
11 changes: 0 additions & 11 deletions cpu-exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@
#include "sysemu/qtest.h"
#include "qtrace.h"

extern void * client_reset_stats;
extern void * client_print_stats;


bool qemu_cpu_has_work(CPUState *cpu)
{
Expand Down Expand Up @@ -104,7 +101,6 @@ static inline tcg_target_ulong cpu_tb_exec(CPUState *cpu, uint8_t *tb_ptr)
*/
cpu->tcg_exit_req = 0;
}

return next_tb;
}

Expand Down Expand Up @@ -230,7 +226,6 @@ static void cpu_handle_debug_exception(CPUArchState *env)

volatile sig_atomic_t exit_request;


int cpu_exec(CPUArchState *env)
{
CPUState *cpu = ENV_GET_CPU(env);
Expand Down Expand Up @@ -627,13 +622,11 @@ int cpu_exec(CPUArchState *env)
#endif
}
#endif /* DEBUG_DISAS */

/* handle QTRACE commands */
qtrace_cpu_handle_cmds(env);

spin_lock(&tcg_ctx.tb_ctx.tb_lock);
tb = tb_find_fast(env);

/* Note: we do it here to avoid a gcc bug on Mac OS X when
doing it in tb_find_slow */
if (tcg_ctx.tb_ctx.tb_invalidated_flag) {
Expand Down Expand Up @@ -666,10 +659,6 @@ int cpu_exec(CPUArchState *env)
barrier();
if (likely(!cpu->exit_request)) {
tc_ptr = tb->tc_ptr;

// if (tc_ptr == 0x7fe71ba91580)
// printf("tc_ptr is 0x%lx\n", tc_ptr);

/* execute the generated code */
next_tb = cpu_tb_exec(cpu, tc_ptr);
switch (next_tb & TB_EXIT_MASK) {
Expand Down
1 change: 0 additions & 1 deletion include/exec/cpu-all.h
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,6 @@ extern unsigned long reserved_va;
#define TARGET_PAGE_MASK ~(TARGET_PAGE_SIZE - 1)
#define TARGET_PAGE_ALIGN(addr) (((addr) + TARGET_PAGE_SIZE - 1) & TARGET_PAGE_MASK)


/* ??? These should be the larger of uintptr_t and target_ulong. */
extern uintptr_t qemu_real_host_page_size;
extern uintptr_t qemu_host_page_size;
Expand Down
4 changes: 2 additions & 2 deletions include/exec/exec-all.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,14 @@ typedef struct TranslationBlock TranslationBlock;
* and up to 4 + N parameters on 64-bit archs
* (N = number of input arguments + output arguments). */
#define MAX_OPC_PARAM (4 + (MAX_OPC_PARAM_PER_ARG * MAX_OPC_PARAM_ARGS))
#define OPC_BUF_SIZE 640
#define OPC_BUF_SIZE 640
#define OPC_MAX_SIZE (OPC_BUF_SIZE - MAX_OP_PER_INSTR)

/* Maximum size a TCG op can expand to. This is complicated because a
single op may require several host instructions and register reloads.
For now take a wild guess at 192 bytes, which should allow at least
a couple of fixup instructions per argument. */
#define TCG_MAX_OP_SIZE 192
#define TCG_MAX_OP_SIZE 192

#define OPPARAM_BUF_SIZE (OPC_BUF_SIZE * MAX_OPC_PARAM)

Expand Down
1 change: 0 additions & 1 deletion include/qtrace-common.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ typedef struct InstrumentContext {
struct InstrumentContext *next;
} InstrumentContext;


/// ------------------------------------------------ ///
/// qtrace asynchronous debug channel.
/// ------------------------------------------------ ///
Expand Down
77 changes: 37 additions & 40 deletions qemu-adebug.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
#include <stdlib.h>
#include <sys/shm.h>
#include <sys/stat.h>
#include "qemu-adebug.h"
#include <stdbool.h>
#include "qemu-adebug.h"

/// --------------------------------------------
/* connect/disconnect the shared memory */
Expand Down Expand Up @@ -56,10 +56,8 @@ static inline void handle_connection_##cmd(DebugChannel *channel, \
const char *mname, \
bool *valid) \
{ \
if (fname) \
memcpy(channel->fname, fname, strlen(fname)); \
if (mname) \
memcpy(channel->mname, mname, strlen(mname)); \
if (fname) memcpy(channel->fname, fname, strlen(fname)); \
if (mname) memcpy(channel->mname, mname, strlen(mname)); \
channel->var = 1; \
QTRACE_WAIT_COMMAND_HANDLED(channel->var); \
*valid = true; \
Expand All @@ -74,43 +72,42 @@ QTRACE_HANDLE_CONNECTION(client_print_all, client_print_all);

static inline void handle_connection_success(int argc, char** argv, DebugChannel *channel)
{
int i;
for (i=1;i<argc;++i)
{
bool valid_command = false;
if (!strcmp(argv[i], flushcc)) handle_connection_flushcc(channel, 0, 0, &valid_command);
if (!strcmp(argv[i], client_userd)) handle_connection_client_userd(channel,
argv[++i],
argv[++i],
&valid_command);
if (!strcmp(argv[i], client_reset)) handle_connection_client_reset(channel,
0,
argv[++i],
&valid_command);
if (!strcmp(argv[i], client_print)) handle_connection_client_print(channel,
0,
argv[++i],
&valid_command);
if (!strcmp(argv[i], client_reset_all)) handle_connection_client_reset_all(channel,
0, 0,
&valid_command);
if (!strcmp(argv[i], client_print_all)) handle_connection_client_print_all(channel,
0, 0,
&valid_command);
int i;
for (i=1;i<argc;++i)
{
bool valid_command = false;
if (!strcmp(argv[i], flushcc)) handle_connection_flushcc(channel, 0, 0, &valid_command);
if (!strcmp(argv[i], client_userd)) handle_connection_client_userd(channel,
argv[++i],
argv[++i],
&valid_command);
if (!strcmp(argv[i], client_reset)) handle_connection_client_reset(channel,
0,
argv[++i],
&valid_command);
if (!strcmp(argv[i], client_print)) handle_connection_client_print(channel,
0,
argv[++i],
&valid_command);
if (!strcmp(argv[i], client_reset_all)) handle_connection_client_reset_all(channel,
0, 0,
&valid_command);
if (!strcmp(argv[i], client_print_all)) handle_connection_client_print_all(channel,
0, 0,
&valid_command);
if (!valid_command)
{
QTRACE_ERROR("invalid command %s\n", argv[i]);
QTRACE_EXIT(-1);
QTRACE_ERROR("invalid command %s\n", argv[i]);
QTRACE_EXIT(-1);
}
}

}
return;
}

static void handle_connection_error(void)
{
QTRACE_ERROR("unable to connect to shm %d\n", SHARED_MEM_KEY);
QTRACE_EXIT(-1);
QTRACE_EXIT(-1);
}

static void print_help(void)
Expand All @@ -132,16 +129,16 @@ int main(int argc, char **argv)
exit(0);
}

/* connect to the shared memory */
DebugChannel *channel=connect();
/* connect to the shared memory */
DebugChannel *channel=connect();

if (!channel) handle_connection_error();
else handle_connection_success(argc, argv, channel);
if (!channel) handle_connection_error();
else handle_connection_success(argc, argv, channel);

/* disconnect */
disconnect(channel);
/* disconnect */
disconnect(channel);

/* done */
return 0;
return 0;
}

11 changes: 5 additions & 6 deletions qtrace-client-header.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ unsigned UserDefineCallBackNum = 0;
unsigned ResetStatsCallBackNum = 0;
unsigned PrintStatsCallBackNum = 0;

GenericRtnContainer* ResetStatsCallBackArray[QTRACE_MAX_CALLBACK_NUM] = {0};
GenericRtnContainer* PrintStatsCallBackArray[QTRACE_MAX_CALLBACK_NUM] = {0};
GenericRtnContainer* InstructionCallBackArray[QTRACE_MAX_CALLBACK_NUM] = {0};
GenericRtnContainer* BasicBlockCallBackArray[QTRACE_MAX_CALLBACK_NUM] = {0};
GenericRtnContainer* UserDefineCallBackArray[QTRACE_MAX_CALLBACK_NUM] = {0};
GenericRtnContainer* ResetStatsCallBackArray[QTRACE_MAX_CALLBACK_NUM] = {0};
GenericRtnContainer* PrintStatsCallBackArray[QTRACE_MAX_CALLBACK_NUM] = {0};
GenericRtnContainer* InstructionCallBackArray[QTRACE_MAX_CALLBACK_NUM]= {0};
GenericRtnContainer* BasicBlockCallBackArray[QTRACE_MAX_CALLBACK_NUM] = {0};
GenericRtnContainer* UserDefineCallBackArray[QTRACE_MAX_CALLBACK_NUM] = {0};

/* hook up the QTRACE function to insert instrumentation */
void InitializeInstructionInstrument(QTRACE_INSERT_INSTRUMENT rtn)
Expand Down Expand Up @@ -89,4 +89,3 @@ void AddUserDefineCallBack(void *rtn, char *fname)
}

#endif /* QTRACE_CLIENT_HEADER_H */

34 changes: 17 additions & 17 deletions qtrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,27 +84,27 @@ static void add_function_to_list(void *rtn,
const char *fname,
GenericRtnContainer **list)
{
/* it is possible that this module does not define a instruction callback */
if (!rtn) return;
/* it is possible that this module does not define a instruction callback */
if (!rtn) return;

GenericRtnContainer *head = *list;
if (!*list)
GenericRtnContainer *head = *list;
if (!*list)
{
head = *list = (GenericRtnContainer*) malloc(sizeof(GenericRtnContainer));
}
else
{
/* get to the end of the linkedlist */
while(head->next) head = head->next;
head->next = (GenericRtnContainer*) malloc(sizeof(GenericRtnContainer));
head = head->next;
}
else
{
/* get to the end of the linkedlist */
while(head->next) head = head->next;
head->next = (GenericRtnContainer*) malloc(sizeof(GenericRtnContainer));
head = head->next;
}

/* register the callback */
head->rtn = rtn;
/* register the callback */
head->rtn = rtn;
head->mname = mname;
head->fname = fname;
head->next = NULL;
head->next = NULL;
}

/// @ register_stats_reset - register a function to resetstats_list list.
Expand All @@ -113,16 +113,16 @@ static void register_function_to_list(void* function,
const char* fname,
GenericRtnContainer **list)
{
add_function_to_list(function, mname, fname, list);
add_function_to_list(function, mname, fname, list);
}

/// @ qtrace_increment_uiid - increment the uiid. one more instruction has passed.
void qtrace_increment_uiid(void) { uiid ++; }
/// @ qtrace_allocate_icontext_root - allocate a icontext root pointer.
void qtrace_allocate_icontext_root(void)
{
rootarray[rootcount++] = 0;
assert(rootcount < MAX_ICONTEXT_ROOT);
rootarray[rootcount++] = 0;
assert(rootcount < MAX_ICONTEXT_ROOT);
}
/// @ qtrace_get_current_icontext_list - return the current icontext.
InstrumentContext* qtrace_get_current_icontext_list(void)
Expand Down
1 change: 0 additions & 1 deletion qtrace.h
Original file line number Diff line number Diff line change
Expand Up @@ -250,4 +250,3 @@ void qtrace_icontext_sanity_check(InstrumentContext *);
InstrumentContext* qtrace_get_current_icontext_list(void);

#endif /* QTRACE_H */

6 changes: 1 addition & 5 deletions tcg/i386/tcg-target.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ static const char * const tcg_target_reg_names[TCG_TARGET_NB_REGS] = {
};
#endif


static const int tcg_target_reg_alloc_order[] = {
#if TCG_TARGET_REG_BITS == 64
TCG_REG_RBP,
Expand Down Expand Up @@ -113,7 +112,6 @@ static bool have_cmov;
# define have_cmov 0
#endif


static uint8_t *tb_ret_addr;

static void patch_reloc(uint8_t *code_ptr, int type,
Expand Down Expand Up @@ -1371,7 +1369,6 @@ static inline void tcg_out_tlb_load_trace_vpma(TCGContext *s, TCGReg addrlo, TCG

/* TLB Hit. */


/* add addend(r0), r1 */
tcg_out_modrm_offset(s, OPC_ADD_GvEv + hrexw, r1, r0,
offsetof(CPUTLBEntry, addend) - which);
Expand Down Expand Up @@ -1675,7 +1672,7 @@ static void tcg_out_qemu_ld(TCGContext *s, const TCGArg *args, bool is64)
int mem_index;
int mem_trace;
TCGMemOp s_bits;
uint8_t *label_ptr[2] = { 0, 0 };
uint8_t *label_ptr[2];
#endif
unsigned maddrs = 0;

Expand Down Expand Up @@ -1843,7 +1840,6 @@ static void tcg_out_qemu_st(TCGContext *s, const TCGArg *args, bool is64)
#endif

unsigned maddrs = 0;

datalo = *args++;
datahi = (TCG_TARGET_REG_BITS == 32 && is64 ? *args++ : 0);
addrlo = *args++;
Expand Down
6 changes: 0 additions & 6 deletions tcg/tcg-op.h
Original file line number Diff line number Diff line change
Expand Up @@ -2715,12 +2715,6 @@ static inline void tcg_gen_qemu_st64(TCGv_i64 arg, TCGv addr, int mem_index)
tcg_gen_qemu_st_i64(arg, addr, mem_index, MO_TEQ);
}

static inline void tcg_gen_qemu_xlate(TCGv ret, TCGv addr, int mem_index)
{
// tcg_gen_qemu_xlate_tl(ret, addr, mem_index);
}


#if TARGET_LONG_BITS == 64
#define tcg_gen_movi_tl tcg_gen_movi_i64
#define tcg_gen_mov_tl tcg_gen_mov_i64
Expand Down
2 changes: 1 addition & 1 deletion tcg/tcg-opc.h
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,6 @@ DEF(qemu_st_i64, 0, 4, 2, IMPL_NEW_LDST | TCG_OPF_64BIT)

DEF(qtrace_instrumentation, 0, 0, 1, IMPL_NEW_LDST)
DEF(qtrace_shadow_register, 0, 0, 2, IMPL_NEW_LDST)

#undef IMPL_NEW_LDST

#define IMPL_OLD_LDST \
Expand Down Expand Up @@ -265,6 +264,7 @@ DEF(qemu_st64, 0, 4, 1, IMPL_OLD_LDST | TCG_OPF_64BIT)
#endif

#else /* TCG_TARGET_REG_BITS == 32 */

DEF(qemu_ld8u, 1, 1, 1, IMPL_OLD_LDST | TCG_OPF_64BIT)
DEF(qemu_ld8s, 1, 1, 1, IMPL_OLD_LDST | TCG_OPF_64BIT)
DEF(qemu_ld16u, 1, 1, 1, IMPL_OLD_LDST | TCG_OPF_64BIT)
Expand Down
Loading

0 comments on commit e847842

Please sign in to comment.