| #!/bin/bash |
| set -e |
| |
| while getopts n:f name ; do |
| case $name in |
| f) |
| FORCE=y |
| ;; |
| n) |
| OPSYS=$OPTARG |
| ;; |
| esac |
| done |
| |
| cd `dirname $0`/../../.. |
| |
| echo "This script creates a git repository for a customized TCF agent." |
| echo "The repository will contain minimal amount of code" |
| echo "to start porting the agent to a new OS." |
| echo |
| |
| if [ -z "$OPSYS" ] ; then |
| read -p 'Target OS name: ' OPSYS |
| fi |
| |
| if [ -z "$OPSYS" ] ; then |
| exit 0 |
| fi |
| |
| REPO=tcf.agent.$OPSYS |
| |
| if [ -z "$FORCE" ] ; then |
| if [ -d $REPO ] ; then |
| echo "Directory $REPO already exists" |
| exit 1 |
| fi |
| else |
| rm -rf $REPO |
| fi |
| |
| mkdir $REPO |
| cd $REPO |
| |
| mkdir -p system/$OPSYS/tcf |
| |
| cat >system/$OPSYS/tcf/context-`echo "$OPSYS" | tr '[:upper:]' '[:lower:]'`.c <<EOF |
| #include <tcf/config.h> |
| |
| #include <tcf/framework/myalloc.h> |
| #include <tcf/framework/events.h> |
| #include <tcf/framework/context.h> |
| |
| Context * context_find_from_pid(pid_t pid, int thread) { |
| return NULL; |
| } |
| |
| int context_attach_self(void) { |
| errno = ERR_UNSUPPORTED; |
| return -1; |
| } |
| |
| int context_attach(pid_t pid, ContextAttachCallBack * done, void * client_data, int mode) { |
| errno = ERR_UNSUPPORTED; |
| return -1; |
| } |
| |
| int context_has_state(Context * ctx) { |
| return 0; |
| } |
| |
| #if ENABLE_ContextMemoryProperties |
| int context_get_memory_properties(Context * ctx, const char *** names, const char *** values, int * cnt) { |
| return 0; |
| } |
| #endif |
| |
| #if ENABLE_ContextExtraProperties |
| int context_get_extra_properties(Context * ctx, const char *** names, const char *** values, int * cnt) { |
| return 0; |
| } |
| #endif |
| |
| #if ENABLE_ContextStateProperties |
| int context_get_state_properties(Context * ctx, const char *** names, const char *** values, int * cnt) { |
| return 0; |
| } |
| #endif |
| |
| int context_stop(Context * ctx) { |
| errno = ERR_UNSUPPORTED; |
| return -1; |
| } |
| |
| int context_resume(Context * ctx, int mode, ContextAddress range_start, ContextAddress range_end) { |
| errno = ERR_UNSUPPORTED; |
| return -1; |
| } |
| |
| int context_can_resume(Context * ctx, int mode) { |
| return 0; |
| } |
| |
| int context_continue(Context * ctx) { |
| errno = ERR_UNSUPPORTED; |
| return -1; |
| } |
| |
| int context_single_step(Context * ctx) { |
| errno = ERR_UNSUPPORTED; |
| return -1; |
| } |
| |
| const char * context_suspend_reason(Context * ctx) { |
| return NULL; |
| } |
| |
| int context_get_memory_map(Context * ctx, MemoryMap * map) { |
| errno = ERR_UNSUPPORTED; |
| return -1; |
| } |
| |
| int context_write_mem(Context * ctx, ContextAddress address, void * buf, size_t size) { |
| errno = ERR_UNSUPPORTED; |
| return -1; |
| } |
| |
| int context_read_mem(Context * ctx, ContextAddress address, void * buf, size_t size) { |
| errno = ERR_UNSUPPORTED; |
| return -1; |
| } |
| |
| #if ENABLE_ExtendedMemoryErrorReports |
| int context_get_mem_error_info(MemoryErrorInfo * info) { |
| errno = ERR_UNSUPPORTED; |
| return -1; |
| } |
| #endif |
| |
| #if ENABLE_MemoryAccessModes |
| int context_write_mem_ext(Context * ctx, MemoryAccessMode * mode, ContextAddress address, void * buf, size_t size) { |
| errno = ERR_UNSUPPORTED; |
| return -1; |
| } |
| |
| int context_read_mem_ext(Context * ctx, MemoryAccessMode * mode, ContextAddress address, void * buf, size_t size) { |
| errno = ERR_UNSUPPORTED; |
| return -1; |
| } |
| #endif |
| |
| int context_write_reg(Context * ctx, RegisterDefinition * def, unsigned offs, unsigned size, void * buf) { |
| errno = ERR_UNSUPPORTED; |
| return -1; |
| } |
| |
| int context_read_reg(Context * ctx, RegisterDefinition * def, unsigned offs, unsigned size, void * buf) { |
| errno = ERR_UNSUPPORTED; |
| return -1; |
| } |
| |
| unsigned context_word_size(Context * ctx) { |
| return 8; |
| } |
| |
| int context_get_canonical_addr(Context * ctx, ContextAddress addr, |
| Context ** canonical_ctx, ContextAddress * canonical_addr, |
| ContextAddress * block_addr, ContextAddress * block_size) { |
| errno = ERR_UNSUPPORTED; |
| return -1; |
| } |
| |
| Context * context_get_group(Context * ctx, int group) { |
| return ctx; |
| } |
| |
| int context_get_supported_bp_access_types(Context * ctx) { |
| return 0; |
| } |
| |
| int context_plant_breakpoint(ContextBreakpoint * bp) { |
| errno = ERR_UNSUPPORTED; |
| return -1; |
| } |
| |
| int context_unplant_breakpoint(ContextBreakpoint * bp) { |
| errno = ERR_UNSUPPORTED; |
| return -1; |
| } |
| |
| #if ENABLE_ContextBreakpointCapabilities |
| int context_get_breakpoint_capabilities(Context * ctx, const char *** names, const char *** values, int * cnt) { |
| *cnt = 0; |
| return 0; |
| } |
| #endif |
| |
| #if ENABLE_ExtendedBreakpointStatus |
| int context_get_breakpoint_status(ContextBreakpoint * bp, const char *** names, const char *** values, int * cnt) { |
| *cnt = 0; |
| return 0; |
| } |
| #endif |
| |
| #if ENABLE_ContextISA |
| int context_get_isa(Context * ctx, ContextAddress addr, ContextISA * isa) { |
| errno = ERR_UNSUPPORTED; |
| return -1; |
| } |
| #endif |
| |
| RegisterDefinition * get_reg_definitions(Context * ctx) { |
| return NULL; |
| } |
| |
| RegisterDefinition * get_PC_definition(Context * ctx) { |
| return NULL; |
| } |
| |
| RegisterDefinition * get_reg_by_id(Context * ctx, unsigned id, RegisterIdScope * scope) { |
| return NULL; |
| } |
| |
| int read_reg_bytes(StackFrame * frame, RegisterDefinition * reg_def, unsigned offs, unsigned size, uint8_t * buf) { |
| errno = ERR_UNSUPPORTED; |
| return -1; |
| } |
| |
| int write_reg_bytes(StackFrame * frame, RegisterDefinition * reg_def, unsigned offs, unsigned size, uint8_t * buf) { |
| errno = ERR_UNSUPPORTED; |
| return -1; |
| } |
| |
| uint8_t * get_break_instruction(Context * ctx, size_t * size) { |
| return NULL; |
| } |
| |
| int crawl_stack_frame(StackFrame * frame, StackFrame * down) { |
| errno = ERR_UNSUPPORTED; |
| return -1; |
| } |
| |
| void init_contexts_sys_dep(void) { |
| } |
| EOF |
| |
| cat >system/$OPSYS/tcf/regset.h <<EOF |
| #include <tcf/config.h> |
| EOF |
| |
| cat >Makefile <<EOF |
| OPSYS = $OPSYS |
| MACHINE = x86_64 |
| LIBS = -lpthread -lrt |
| TCF_AGENT_DIR=../org.eclipse.tcf.agent/agent |
| |
| include \$(TCF_AGENT_DIR)/Makefile.inc |
| |
| override CFLAGS += \$(foreach dir,\$(INCDIRS),-I\$(dir)) \$(OPTS) |
| |
| HFILES := \$(foreach dir,\$(SRCDIRS),\$(wildcard \$(dir)/*.h)) \$(HFILES) |
| CFILES := \$(sort \$(foreach dir,\$(SRCDIRS),\$(wildcard \$(dir)/*.c)) \$(CFILES)) |
| |
| all: \$(addprefix \$(BINDIR)/,agent\$(EXTEXE)) |
| |
| \$(BINDIR)/libtcf\$(EXTLIB) : \$(OFILES) |
| \$(AR) \$(AR_FLAGS) \$(AR_OUT_F)\$@ \$^ |
| \$(RANLIB) |
| |
| \$(BINDIR)/agent\$(EXTEXE): \$(BINDIR)/tcf/main/main\$(EXTOBJ) \$(BINDIR)/libtcf\$(EXTLIB) |
| \$(LINK) \$(LINK_FLAGS) \$(LINK_OUT_F)\$@ \$(BINDIR)/tcf/main/main\$(EXTOBJ) \$(BINDIR)/libtcf\$(EXTLIB) \$(LIBS) |
| |
| \$(BINDIR)/%\$(EXTOBJ): %.c \$(HFILES) Makefile |
| @\$(call MKDIR,\$(dir \$@)) |
| \$(CC) \$(CFLAGS) -c -o \$@ \$< |
| |
| \$(BINDIR)/%\$(EXTOBJ): \$(TCF_AGENT_DIR)/%.c \$(HFILES) Makefile |
| @\$(call MKDIR,\$(dir \$@)) |
| \$(CC) \$(CFLAGS) -c -o \$@ \$< |
| |
| clean: |
| \$(call RMDIR,\$(BINDIR)) |
| EOF |
| |
| mkdir -p tcf |
| |
| cat >tcf/config.h <<EOF |
| #ifndef D_config |
| #define D_config |
| |
| #define ENABLE_SSL 0 |
| #define ENABLE_ELF 0 |
| #define ENABLE_LineNumbersProxy 1 |
| #define ENABLE_SymbolsProxy 1 |
| #define ENABLE_ContextProxy 1 |
| |
| #define ENABLE_ContextIdHashTable 1 |
| #define ENABLE_ContextMemoryProperties 0 |
| #define ENABLE_ContextExtraProperties 0 |
| #define ENABLE_ContextStateProperties 0 |
| #define ENABLE_ContextBreakpointCapabilities 0 |
| #define ENABLE_ExtendedBreakpointStatus 0 |
| #define ENABLE_ExtendedMemoryErrorReports 0 |
| #define ENABLE_MemoryAccessModes 0 |
| #define ENABLE_ContextISA 1 |
| |
| #define USE_uuid_generate 0 |
| |
| #define SERVICE_Symbols 0 |
| #define SERVICE_LineNumbers 0 |
| #define SERVICE_SysMonitor 0 |
| #define SERVICE_Terminals 0 |
| |
| #include <tcf/framework/config.h> |
| |
| #endif /* D_config */ |
| EOF |
| |
| cat >.gitignore <<EOF |
| /obj |
| EOF |
| |
| git init |
| git add .gitignore Makefile |
| git add tcf/* system/$OPSYS/tcf/* |
| git commit -am "Initial version" |
| |
| echo "Successfully created repository:" |
| echo " $(pwd)" |