From 5025439f9d8df419e5d9797d930f7490bfdf86c0 Mon Sep 17 00:00:00 2001 From: Chris Johns Date: Sun, 21 Sep 2014 14:24:37 +1000 Subject: rtems-tld: Add config options, fix void args, and SCore traces. --- linkers/rtems-api.ini | 20 ++++ linkers/rtems-score-coremutex.ini | 12 +++ linkers/rtems-score-heap.ini | 26 +++++ linkers/rtems-score-object.ini | 38 ++++++++ linkers/rtems-score-thread.ini | 56 +++++++++++ linkers/rtems-score.ini | 29 ++++++ linkers/rtems-tld.cpp | 193 ++++++++++++++++++++++++++++++-------- linkers/rtems.ini | 21 +---- linkers/rtld-base.ini | 90 +----------------- linkers/rtld-print.ini | 94 +++++++++++++++++++ linkers/wscript | 10 +- 11 files changed, 443 insertions(+), 146 deletions(-) create mode 100644 linkers/rtems-api.ini create mode 100644 linkers/rtems-score-coremutex.ini create mode 100644 linkers/rtems-score-heap.ini create mode 100644 linkers/rtems-score-object.ini create mode 100644 linkers/rtems-score-thread.ini create mode 100644 linkers/rtems-score.ini create mode 100644 linkers/rtld-print.ini (limited to 'linkers') diff --git a/linkers/rtems-api.ini b/linkers/rtems-api.ini new file mode 100644 index 0000000..f2de480 --- /dev/null +++ b/linkers/rtems-api.ini @@ -0,0 +1,20 @@ +; +; RTEMS API Trace Configurations +; +[rtems-api] +headers = rtems-api-headers +defines = rtems-api-defines +signatures = rtems-api-signatures + +[rtems-api-headers] +header = "#include " + +[rtems-api-defines] +; Currently empty + +[rtems-api-task] +trace = rtems_task_create + +[rtems-api-signatures] +rtems_task_create = rtems_status_code, rtems_name, rtems_task_priority, size_t, rtems_mode, rtems_attribute, rtems_id* + diff --git a/linkers/rtems-score-coremutex.ini b/linkers/rtems-score-coremutex.ini new file mode 100644 index 0000000..2459d0c --- /dev/null +++ b/linkers/rtems-score-coremutex.ini @@ -0,0 +1,12 @@ +; +; RTEMS Supercore Core Mutex Trace Configurations +; +[rtems-score-coremutex-all] +trace = _CORE_mutex_Initialize, _CORE_mutex_Seize_interrupt_blocking +trace = _CORE_mutex_Surrender, _CORE_mutex_Flush + +[rtems-score-coremutex-signatures] +_CORE_mutex_Initialize = CORE_mutex_Status, CORE_mutex_Control*, Thread_Control*, const CORE_mutex_Attributes*, bool +_CORE_mutex_Seize_interrupt_blocking = void, CORE_mutex_Control*, Thread_Control*, Watchdog_Interval +_CORE_mutex_Surrender = CORE_mutex_Status, CORE_mutex_Control*, Objects_Id, CORE_mutex_API_mp_support_callout +_CORE_mutex_Flush = void, CORE_mutex_Control*, Thread_queue_Flush_callout, uint32_t diff --git a/linkers/rtems-score-heap.ini b/linkers/rtems-score-heap.ini new file mode 100644 index 0000000..7a3426d --- /dev/null +++ b/linkers/rtems-score-heap.ini @@ -0,0 +1,26 @@ +; +; RTEMS Supercore Heap Trace Configurations +; +[rtems-score-heap-all] +trace = _Heap_Get_first_and_last_block, _Heap_Initialize, _Heap_Allocate_aligned_with_boundary +trace = _Heap_Free, _Heap_Walk, _Heap_Iterate, _Heap_Greedy_allocate +trace = _Heap_Greedy_allocate_all_except_largest, _Heap_Greedy_free, _Heap_Get_information +trace = _Heap_Get_free_information, _Heap_Size_of_alloc_area, _Heap_Resize_block +trace = _Heap_Block_allocate + +[rtems-score-heap-signatures] +_Heap_Get_first_and_last_block = bool, uintptr_t, uintptr_t, uintptr_t, uintptr_t, Heap_Block**, Heap_Block** +_Heap_Initialize = uintptr_t, Heap_Control*, void*, uintptr_t, uintptr_t +_Heap_Allocate_aligned_with_boundary = void*, Heap_Control*, uintptr_t, uintptr_t, uintptr_t +_Heap_Free = bool, Heap_Control*, void* +_Heap_Walk = bool, Heap_Control*, int, bool +_Heap_Iterate = void, Heap_Control*, Heap_Block_visitor, void* +_Heap_Greedy_allocate = Heap_Block*, Heap_Control*, const uintptr_t*, size_t +_Heap_Greedy_allocate_all_except_largest = Heap_Block*, Heap_Control*, uintptr_t* +_Heap_Greedy_free = void, Heap_Control*, Heap_Block* +_Heap_Get_information = void, Heap_Control*, Heap_Information_block* +_Heap_Get_free_information = void, Heap_Control*, Heap_Information* +_Heap_Size_of_alloc_area = bool, Heap_Control*, void*, uintptr_t* +_Heap_Resize_block = Heap_Resize_status, Heap_Control*, void*, uintptr_t, uintptr_t*, uintptr_t* +_Heap_Block_allocate = Heap_Block*, Heap_Control*, Heap_Block*, uintptr_t, uintptr_t + diff --git a/linkers/rtems-score-object.ini b/linkers/rtems-score-object.ini new file mode 100644 index 0000000..34c2fd0 --- /dev/null +++ b/linkers/rtems-score-object.ini @@ -0,0 +1,38 @@ +; +; RTEMS Supercore Objects Trace Configurations +; +[rtems-score-object-all] +trace = _Objects_Initialize_information, _Objects_Extend_information +trace = _Objects_Shrink_information, _Objects_Allocate_unprotected +trace = _Objects_Allocate, _Objects_Free, _Objects_Get, _Objects_Get_isr_disable +trace = _Objects_Get_no_protection, _Objects_Get_next, _Objects_Get_information +trace = _Objects_Get_information_id, _Objects_Get_name_as_string, _Objects_Set_name +trace = _Objects_Namespace_remove, _Objects_Close, _Objects_Active_count + +[rtems-score-object-alloc] +trace = _Objects_Initialize_information, _Objects_Allocate_unprotected +trace = _Objects_Allocate, _Objects_Free, _Objects_Close + +[rtems-score-object-get] +trace = _Objects_Get, _Objects_Get_isr_disable, _Objects_Get_no_protection +trace = _Objects_Get_next, _Objects_Get_information, _Objects_Get_information_id +trace = _Objects_Get_name_as_string + +[rtems-score-object-signatures] +_Objects_Initialize_information = void, Objects_Information*, Objects_APIs, uint16_t, uint32_t, uint16_t, bool, uint32_t +_Objects_Extend_information = void, Objects_Information* +_Objects_Shrink_information = void, Objects_Information* +_Objects_Allocate_unprotected = Objects_Control*, Objects_Information* +_Objects_Allocate = Objects_Control*, Objects_Information* +_Objects_Free = void, Objects_Information*, Objects_Control* +_Objects_Get = Objects_Control*, Objects_Information*, Objects_Id, Objects_Locations* +_Objects_Get_isr_disable = Objects_Control*, Objects_Information*, Objects_Id, Objects_Locations*, ISR_Level* +_Objects_Get_no_protection = Objects_Control*, Objects_Information*, Objects_Id, Objects_Locations* +_Objects_Get_next = Objects_Control*, Objects_Information*, Objects_Id, Objects_Locations*, Objects_Id* +_Objects_Get_information = Objects_Information*, Objects_APIs, uint16_t +_Objects_Get_information_id = Objects_Information*, Objects_Id +_Objects_Get_name_as_string = char*, Objects_Id, size_t, char* +_Objects_Set_name = bool, Objects_Information*, Objects_Control*, const char* +_Objects_Namespace_remove = void, Objects_Information*, Objects_Control* +_Objects_Close = void, Objects_Information*, Objects_Control* +_Objects_Active_count = Objects_Maximum, const Objects_Information* diff --git a/linkers/rtems-score-thread.ini b/linkers/rtems-score-thread.ini new file mode 100644 index 0000000..f1cbfe6 --- /dev/null +++ b/linkers/rtems-score-thread.ini @@ -0,0 +1,56 @@ +; +; RTEMS Supercore Thread Trace Configurations +; +[rtems-score-thread-all] +trace = _Thread_Handler_initialization, _Thread_Create_idle, _Thread_Start_multitasking +trace = _Thread_Stack_Allocate, _Thread_Stack_Free, _Thread_Initialize, _Thread_Start +trace = _Thread_Restart, _Thread_Yield, _Thread_Set_life_protection +trace = _Thread_Life_action_handler, _Thread_Kill_zombies, _Thread_Close +trace = _Thread_Ready, _Thread_Clear_state, _Thread_Set_state, _Thread_Load_environment +trace = _Thread_Handler, _Thread_Delay_ended, _Thread_Change_priority, _Thread_Set_priority +trace = _Thread_Get, _Thread_blocking_operation_Cancel, _Thread_blocking_operation_Finalize + +[rtems-score-thread-create-destory] +traces = rtems-score-thread-create, rtems-score-thread-destroy + +[rtems-score-thread-create] +trace = _Thread_Handler_initialization, _Thread_Create_idle +trace = _Thread_Stack_Allocate, _Thread_Initialize, _Thread_Start +trace = _Thread_Restart, _Thread_Handler + +[rtems-score-thread-destroy] +trace = _Thread_Kill_zombies, _Thread_Close +trace = , _Thread_blocking_operation_Cancel, _Thread_blocking_operation_Finalize + +[rtems-score-thread-activity] +trace = _Thread_Restart, _Thread_Yield, _Thread_Set_life_protection +trace = _Thread_Life_action_handler, _Thread_Ready, _Thread_Clear_state, +trace = _Thread_Set_state, _Thread_Load_environment, _Thread_Delay_ended +trace = _Thread_Change_priority, _Thread_Set_priority, _Thread_Get + +[rtems-score-thread-signatures] +_Thread_Handler_initialization = void, void +_Thread_Create_idle = void, void +_Thread_Start_multitasking = void, void +_Thread_Stack_Allocate = size_t, Thread_Control*, size_t +_Thread_Stack_Free = void, Thread_Control* +_Thread_Initialize = bool, Objects_Information *, Thread_Control*, const struct Scheduler_Control*, void*, size_t, bool, Priority_Control, bool, Thread_CPU_budget_algorithms, Thread_CPU_budget_algorithm_callout, uint32_t, Objects_Name +_Thread_Start = bool, Thread_Control*, Thread_Start_types, void*, void*, Thread_Entry_numeric_type, Per_CPU_Control* +_Thread_Restart = bool, Thread_Control*, Thread_Control*, void*, Thread_Entry_numeric_type +_Thread_Yield = void, Thread_Control* +_Thread_Set_life_protection = bool, bool +_Thread_Life_action_handler = void, Thread_Control*, Thread_Action*, Per_CPU_Control*, ISR_Level +_Thread_Kill_zombies = void, void +_Thread_Close = void, Thread_Control*, Thread_Control* +_Thread_Ready = void, Thread_Control* +_Thread_Clear_state = void, Thread_Control*, States_Control +_Thread_Set_state = void, Thread_Control*, States_Control +_Thread_Load_environment = void, Thread_Control* +_Thread_Handler = void, void +_Thread_Delay_ended = void, Objects_Id, void* +_Thread_Change_priority = void, Thread_Control*, Priority_Control, bool +_Thread_Set_priority = void, Thread_Control*, Priority_Control +_Thread_Get = Thread_Control*, Objects_Id, Objects_Locations* +_Thread_blocking_operation_Cancel = void, Thread_blocking_operation_States, Thread_Control*, ISR_Level +_Thread_blocking_operation_Finalize = void, Thread_Control*, ISR_Level + diff --git a/linkers/rtems-score.ini b/linkers/rtems-score.ini new file mode 100644 index 0000000..edea712 --- /dev/null +++ b/linkers/rtems-score.ini @@ -0,0 +1,29 @@ +; +; RTEMS Supercore Trace Configurations +; +[rtems-score] +headers = rtems-score-headers +defines = rtems-score-defines +; Object +include = rtems-score-object.ini +signatures = rtems-score-object-signatures +; Thread +include = rtems-score-thread.ini +signatures = rtems-score-thread-signatures +; Heap +include = rtems-score-heap.ini +signatures = rtems-score-heap-signatures +; Core Mutex +include = rtems-score-coremutex.ini +signatures = rtems-score-coremutex-signatures + +[rtems-score-headers] +header = "#include " +header = "#include " +header = "#include " +header = "#include " +header = "#include " +header = "#include " + +[rtems-score-defines] +; Currently empty diff --git a/linkers/rtems-tld.cpp b/linkers/rtems-tld.cpp index 70ab330..c2cc196 100644 --- a/linkers/rtems-tld.cpp +++ b/linkers/rtems-tld.cpp @@ -58,6 +58,11 @@ namespace rld */ namespace trace { + /** + * Dump on error user option. + */ + bool dump_on_error; + /** * A container of arguments. */ @@ -87,6 +92,16 @@ namespace rld */ signature (const rld::config::record& record); + /** + * Has the signature got a return value ? + */ + bool has_ret () const; + + /** + * Has the signature got any arguments ? + */ + bool has_args () const; + /** * Return the function's declaration. */ @@ -172,6 +187,11 @@ namespace rld void load (rld::config::config& config, const std::string& section); + /** + * Process any script based options. + */ + void load_options (const rld::config::section& section); + /** * The the functions for the trace. */ @@ -206,11 +226,10 @@ namespace rld private: - std::string name; /**< The name of the trace. */ - std::string bsp; /**< The BSP we are linking to. */ - rld::strings traces; /**< The functions to trace. */ - functions functions_; /**< The functions that can be traced. */ - generator generator_; /**< The tracer's generator. */ + std::string name; /**< The name of the trace. */ + rld::strings traces; /**< The functions to trace. */ + functions functions_; /**< The functions that can be traced. */ + generator generator_; /**< The tracer's generator. */ }; /** @@ -317,28 +336,53 @@ namespace rld rld::config::parse_items (record, si); if (si.size () == 0) - throw rld::error ("no return value", "signature: " + record.name); + throw rld::error ("no return value", "signature: " + name); if (si.size () == 1) - throw rld::error ("no arguments", "signature: " + record.name); + throw rld::error ("no arguments", "signature: " + name); ret = si[0]; args.resize (si.size () - 1); std::copy (si.begin () + 1, si.end (), args.begin ()); } + bool + signature::has_ret () const + { + /* + * @todo Need to define as part of the function signature if ret + * processing is required. + */ + return ret != "void"; + } + + bool + signature::has_args () const + { + if (args.empty ()) + return false; + return ((args.size() == 1) && (args[0] == "void")) ? false : true; + } + const std::string signature::decl (const std::string& prefix) const { std::string ds = ret + ' ' + prefix + name + '('; - int arg = 0; - for (function_args::const_iterator ai = args.begin (); - ai != args.end (); - ++ai) + if (has_args ()) + { + int arg = 0; + for (function_args::const_iterator ai = args.begin (); + ai != args.end (); + ++ai) { if (ai != args.begin ()) ds += ", "; ds += (*ai) + " a" + rld::to_string (++arg); } + } + else + { + ds += "void"; + } ds += ')'; return ds; } @@ -374,13 +418,21 @@ namespace rld sli != sig_list.end (); ++sli) { - const rld::config::section& sig_sec = config.get_section (*sli); - for (rld::config::records::const_iterator si = sig_sec.recs.begin (); - si != sig_sec.recs.end (); - ++si) + rld::strings sigs; + rld::split(sigs, *sli, ','); + + for (rld::strings::const_iterator ssi = sigs.begin (); + ssi != sigs.end (); + ++ssi) { - signature sig (*si); - signatures_[sig.name] = sig; + const rld::config::section& sig_sec = config.get_section (*ssi); + for (rld::config::records::const_iterator si = sig_sec.recs.begin (); + si != sig_sec.recs.end (); + ++si) + { + signature sig (*si); + signatures_[sig.name] = sig; + } } } } @@ -503,20 +555,76 @@ namespace rld * The following records are required: * * # name - * # bsp - * # trace + * # traces * # functions */ const rld::config::section& section = config.get_section (tname); - config.includes (section); - name = section.get_record_item ("name"); - + load_options (section); + config.includes (section); load_functions (config, section); load_traces (config, section); } + void + tracer::load_options (const rld::config::section& section) + { + rld::strings ol; + rld::config::parse_items (section, "options", ol, true); + + for (rld::strings::const_iterator oli = ol.begin (); + oli != ol.end (); + ++oli) + { + rld::strings opts; + rld::split(opts, *oli, ','); + for (rld::strings::const_iterator oi = opts.begin (); + oi != opts.end (); + ++oi) + { + const std::string& opt = *oi; + if (opt == "dump-on-error") + dump_on_error = true; + else if (opt == "verbose") + rld::verbose_inc (); + else if (opt == "prefix") + { + rld::strings prefix; + rld::split (prefix, opt, '='); + if (prefix.size () != 2) + throw rld::error ("invalid option", "option: " + opt); + rld::cc::set_exec_prefix (prefix[1]); + } + else if (opt == "cc") + { + rld::strings cc; + rld::split (cc, opt, '='); + if (cc.size () != 2) + throw rld::error ("invalid option", "option: " + opt); + rld::cc::set_cc (cc[1]); + } + else if (opt == "ld") + { + rld::strings ld; + rld::split (ld, opt, '='); + if (ld.size () != 2) + throw rld::error ("invalid option", "option: " + opt); + rld::cc::set_ld (ld[1]); + } + else if (opt == "cflags") + { + rld::strings cflags; + rld::split (cflags, opt, '='); + if (cflags.size () < 2) + throw rld::error ("invalid option", "option: " + opt); + cflags.erase (cflags.begin ()); + rld::cc::append_flags (rld::join (cflags, "="), rld::cc::ft_cflags); + } + } + } + } + void tracer::load_functions (rld::config::config& config, const rld::config::section& section) @@ -543,12 +651,17 @@ namespace rld parse (config, section, "traces", "generator", gens); if (gens.size () > 1) + { + if (dump_on_error) + dump (std::cout); throw rld::error ("duplicate generators", "tracer: " + section.name); + } if (gens.size () == 0) { - gen = - config.get_section ("default-generator").get_record_item ("generator"); + const rld::config::section& dg_section = config.get_section ("default-generator"); + gen = dg_section.get_record_item ("generator"); + config.includes (dg_section); } else { @@ -587,6 +700,8 @@ namespace rld catch (...) { c.close (); + if (dump_on_error) + dump (std::cout); throw; } @@ -659,13 +774,7 @@ namespace rld c.write_line(sig.decl ("__wrap_")); c.write_line("{"); - /* - * @todo Need to define as part of the function signature if ret - * processing is required. - */ - bool has_ret = sig.ret != "void"; - - if (has_ret) + if (sig.has_ret ()) c.write_line(" " + sig.ret + " ret;"); std::string l; @@ -678,7 +787,7 @@ namespace rld c.write_line(l); } - if (!generator_.arg_trace.empty ()) + if (sig.has_args ()) { for (size_t a = 0; a < sig.args.size (); ++a) { @@ -694,15 +803,18 @@ namespace rld l.clear (); - if (has_ret) + if (sig.has_ret ()) l = " ret ="; l += " __real_" + sig.name + '('; - for (size_t a = 0; a < sig.args.size (); ++a) + if (sig.has_args ()) { - if (a) - l += ", "; - l += "a" + rld::to_string ((int) (a + 1)); + for (size_t a = 0; a < sig.args.size (); ++a) + { + if (a) + l += ", "; + l += "a" + rld::to_string ((int) (a + 1)); + } } l += ");"; c.write_line(l); @@ -715,7 +827,7 @@ namespace rld c.write_line(l); } - if (has_ret && !generator_.ret_trace.empty ()) + if (sig.has_ret () && !generator_.ret_trace.empty ()) { std::string l = ' ' + generator_.ret_trace; l = rld::find_replace (l, "@RET_TYPE@", '"' + sig.ret + '"'); @@ -744,7 +856,6 @@ namespace rld tracer::dump (std::ostream& out) const { out << " Tracer: " << name << std::endl - << " BSP: " << bsp << std::endl << " Traces: " << traces.size () << std::endl; for (rld::strings::const_iterator ti = traces.begin (); ti != traces.end (); @@ -824,6 +935,8 @@ namespace rld (status.code != 0)) { err.output (rld::cc::get_cc (), std::cout); + if (dump_on_error) + dump (std::cout); throw rld::error ("Compiler error", "compiling wrapper"); } } @@ -920,7 +1033,7 @@ usage (int exit_code) << " -f cflags : C compiler flags (also --cflags)" << std::endl << " -r path : RTEMS path (also --rtems)" << std::endl << " -B bsp : RTEMS arch/bsp (also --rtems-bsp)" << std::endl - << " -W wrappe r : wrapper file name without ext (also --wrapper)" << std::endl + << " -W wrapper : wrapper file name without ext (also --wrapper)" << std::endl << " -C ini : user configuration INI file (also --config)" << std::endl; ::exit (exit_code); } diff --git a/linkers/rtems.ini b/linkers/rtems.ini index f2de480..f19bcfc 100644 --- a/linkers/rtems.ini +++ b/linkers/rtems.ini @@ -1,20 +1,7 @@ ; -; RTEMS API Trace Configurations +; RTEMS Trace Configurations ; -[rtems-api] -headers = rtems-api-headers -defines = rtems-api-defines -signatures = rtems-api-signatures - -[rtems-api-headers] -header = "#include " - -[rtems-api-defines] -; Currently empty - -[rtems-api-task] -trace = rtems_task_create - -[rtems-api-signatures] -rtems_task_create = rtems_status_code, rtems_name, rtems_task_priority, size_t, rtems_mode, rtems_attribute, rtems_id* +[includes] +include = rtems-api.ini +include = rtems-score.ini diff --git a/linkers/rtld-base.ini b/linkers/rtld-base.ini index 1927dcc..39d5fb1 100644 --- a/linkers/rtld-base.ini +++ b/linkers/rtld-base.ini @@ -10,91 +10,5 @@ [default-generator] generator = printf-generator -; -; A printf generator prints to stdout the trace functions. -; -[printf-generator] -headers = printf-generator-headers -entry-trace = "rtld_pg_printf_entry(@FUNC_NAME@, (void*) &@FUNC_LABEL@);" -arg-trace = "rtld_pg_printf_arg(@ARG_NUM@, @ARG_TYPE@, @ARG_SIZE@, (void*) &@ARG_LABEL@);" -exit-trace = "rtld_pg_printf_exit(@FUNC_NAME@, (void*) &@FUNC_LABEL@);" -ret-trace = "rtld_pg_printf_ret(@RET_TYPE@, @RET_SIZE@, (void*) &@RET_LABEL@);" -code = <<> %s (0x%08x)\n", func_name, func_addr); -} -static inline void rtld_pg_printf_arg(int arg_num, - const char* arg_type, - int arg_size, - void* arg) -{ - const unsigned char* p = arg; - int i; - printf (" %2d] %s(%d) = ", arg_num, arg_type, arg_size); - for (i = 0; i < arg_size; ++i, ++p) printf ("%02x", (unsigned int) *p); - printf ("\n"); -} -static inline void rtld_pg_printf_exit(const char* func_name, - void* func_addr) -{ - printf (" << %s (0x%08x)\n", func_name, func_addr); -} -static inline void rtld_pg_printf_ret(const char* ret_type, - int ret_size, - void* ret) -{ - const unsigned char* p = ret; - int i; - printf (" rt] %s(%d) = ", ret_type, ret_size); - for (i = 0; i < ret_size; ++i, ++p) printf ("%02x", (unsigned int) *p); - printf ("\n"); -} -CODE - -[printf-generator-headers] -header = "#include " - -[printk-generator] -headers = printk-generator-headers -entry-trace = "rtld_pg_printk_entry(@FUNC_NAME@, (void*) &@FUNC_LABEL@);" -arg-trace = "rtld_pg_printk_arg(@ARG_NUM@, @ARG_TYPE@, @ARG_SIZE@, (void*) &@ARG_LABEL@);" -exit-trace = "rtld_pg_printk_exit(@FUNC_NAME@, (void*) &@FUNC_LABEL@);" -ret-trace = "rtld_pg_printk_ret(@RET_TYPE@, @RET_SIZE@, (void*) &@RET_LABEL@);" -code = <<> %s (0x%08x)\n", func_name, func_addr); -} -static inline void rtld_pg_printk_arg(int arg_num, - const char* arg_type, - int arg_size, - void* arg) -{ - const unsigned char* p = arg; - int i; - printk (" %2d] %s(%d) = ", arg_num, arg_type, arg_size); - for (i = 0; i < arg_size; ++i, ++p) printk ("%02x", (unsigned int) *p); - printk ("\n"); -} -static inline void rtld_pg_printk_exit(const char* func_name, - void* func_addr) -{ - printk (" << %s (0x%08x)\n", func_name, func_addr); -} -static inline void rtld_pg_printk_ret(const char* ret_type, - int ret_size, - void* ret) -{ - const unsigned char* p = ret; - int i; - printk (" rt] %s(%d) = ", ret_type, ret_size); - for (i = 0; i < ret_size; ++i, ++p) printk ("%02x", (unsigned int) *p); - printk ("\n"); -} -CODE - -[printk-generator-headers] -header = "#include " +[includes] +include = rtld-print.ini diff --git a/linkers/rtld-print.ini b/linkers/rtld-print.ini new file mode 100644 index 0000000..b9b524f --- /dev/null +++ b/linkers/rtld-print.ini @@ -0,0 +1,94 @@ +; +; RTEMS Trace Linker Printf and Prink configuration. +; +; Copyright 2014 Chris Johns +; + +; +; A printf generator prints to stdout the trace functions. +; +[printf-generator] +headers = printf-generator-headers +entry-trace = "rtld_pg_printf_entry(@FUNC_NAME@, (void*) &@FUNC_LABEL@);" +arg-trace = "rtld_pg_printf_arg(@ARG_NUM@, @ARG_TYPE@, @ARG_SIZE@, (void*) &@ARG_LABEL@);" +exit-trace = "rtld_pg_printf_exit(@FUNC_NAME@, (void*) &@FUNC_LABEL@);" +ret-trace = "rtld_pg_printf_ret(@RET_TYPE@, @RET_SIZE@, (void*) &@RET_LABEL@);" +code = <<>> %s (0x%08x)\n", func_name, func_addr); +} +static inline void rtld_pg_printf_arg(int arg_num, + const char* arg_type, + int arg_size, + void* arg) +{ + const unsigned char* p = arg; + int i; + printf (" %2d] %s(%d) = ", arg_num, arg_type, arg_size); + for (i = 0; i < arg_size; ++i, ++p) printf ("%02x", (unsigned int) *p); + printf ("\n"); +} +static inline void rtld_pg_printf_exit(const char* func_name, + void* func_addr) +{ + printf ("<<< %s (0x%08x)\n", func_name, func_addr); +} +static inline void rtld_pg_printf_ret(const char* ret_type, + int ret_size, + void* ret) +{ + const unsigned char* p = ret; + int i; + printf (" rt] %s(%d) = ", ret_type, ret_size); + for (i = 0; i < ret_size; ++i, ++p) printf ("%02x", (unsigned int) *p); + printf ("\n"); +} +CODE + +[printf-generator-headers] +header = "#include " + +[printk-generator] +headers = printk-generator-headers +entry-trace = "rtld_pg_printk_entry(@FUNC_NAME@, (void*) &@FUNC_LABEL@);" +arg-trace = "rtld_pg_printk_arg(@ARG_NUM@, @ARG_TYPE@, @ARG_SIZE@, (void*) &@ARG_LABEL@);" +exit-trace = "rtld_pg_printk_exit(@FUNC_NAME@, (void*) &@FUNC_LABEL@);" +ret-trace = "rtld_pg_printk_ret(@RET_TYPE@, @RET_SIZE@, (void*) &@RET_LABEL@);" +code = <<>> %s (0x%08x)\n", func_name, func_addr); +} +static inline void rtld_pg_printk_arg(int arg_num, + const char* arg_type, + int arg_size, + void* arg) +{ + const unsigned char* p = arg; + int i; + printk (" %2d] %s(%d) = ", arg_num, arg_type, arg_size); + for (i = 0; i < arg_size; ++i, ++p) printk ("%02x", (unsigned int) *p); + printk ("\n"); +} +static inline void rtld_pg_printk_exit(const char* func_name, + void* func_addr) +{ + printk ("<<< %s (0x%08x)\n", func_name, func_addr); +} +static inline void rtld_pg_printk_ret(const char* ret_type, + int ret_size, + void* ret) +{ + const unsigned char* p = ret; + int i; + printk (" rt] %s(%d) = ", ret_type, ret_size); + for (i = 0; i < ret_size; ++i, ++p) printk ("%02x", (unsigned int) *p); + printk ("\n"); +} +CODE + +[printk-generator-headers] +header = "#include " diff --git a/linkers/wscript b/linkers/wscript index 99aa86a..3d11747 100644 --- a/linkers/wscript +++ b/linkers/wscript @@ -88,7 +88,15 @@ def build(bld): linkflags = conf['linkflags'], use = modules) bld.install_files('${PREFIX}/share/rtems/trace-linker', - ['rtems.ini', 'rtld-base.ini']) + ['rtems.ini', + 'rtems-api.ini', + 'rtems-score.ini', + 'rtems-score-object.ini', + 'rtems-score-thread.ini', + 'rtems-score-heap.ini', + 'rtems-score-coremutex.ini', + 'rtld-base.ini', + 'rtld-print.ini']) # # Build the symbols. -- cgit v1.2.3