diff options
author | CamVan Nguyen <ctnguyen@us.ibm.com> | 2011-08-29 10:18:55 -0500 |
---|---|---|
committer | CAMVAN T. NGUYEN <ctnguyen@us.ibm.com> | 2011-08-30 12:37:02 -0500 |
commit | e4b2a0f558f49f24bf31f763c13027ebcabc5efa (patch) | |
tree | 936250ee2006a9b8f91f2d25c5d97c479b04f6ff /src | |
parent | 868fd75d64f91d2afbb31d442451857d02a830ce (diff) | |
download | talos-hostboot-e4b2a0f558f49f24bf31f763c13027ebcabc5efa.tar.gz talos-hostboot-e4b2a0f558f49f24bf31f763c13027ebcabc5efa.zip |
Added %c and precision formatting support to trace.
Added TRACSCOMP macros.
Change-Id: If697b4d988a238b5cd06229853dded20bd0af3c1
Reviewed-on: http://gfw160.austin.ibm.com:8080/gerrit/286
Tested-by: Jenkins Server
Reviewed-by: Andrew J. Geissler <andrewg@us.ibm.com>
Diffstat (limited to 'src')
-rwxr-xr-x | src/build/trace/tracehash_hb.pl | 32 | ||||
-rw-r--r-- | src/include/usr/trace/interface.H | 39 | ||||
-rw-r--r-- | src/usr/trace/test/tracetest.H | 26 | ||||
-rw-r--r-- | src/usr/trace/trace.C | 23 |
4 files changed, 112 insertions, 8 deletions
diff --git a/src/build/trace/tracehash_hb.pl b/src/build/trace/tracehash_hb.pl index a3c35f08a..42edcdff0 100755 --- a/src/build/trace/tracehash_hb.pl +++ b/src/build/trace/tracehash_hb.pl @@ -1,4 +1,26 @@ #!/usr/bin/perl -w +# IBM_PROLOG_BEGIN_TAG +# This is an automatically generated prolog. +# +# $Source: src/build/trace/tracehash_hb.pl $ +# +# IBM CONFIDENTIAL +# +# COPYRIGHT International Business Machines Corp. 2011 +# +# p1 +# +# Object Code Only (OCO) source materials +# Licensed Internal Code Source Materials +# IBM HostBoot Licensed Internal Code +# +# The source code for this program is not published or other- +# wise divested of its trade secrets, irrespective of what has +# been deposited with the U.S. Copyright Office. +# +# Origin: 30 +# +# IBM_PROLOG_END # File tracehash.pl created by B J Zander. # 05/08/2011 - Update by andrewg to work in host boot environment @@ -627,12 +649,12 @@ sub assimilate_file($) { chop $line; # remove EOL # 64 bit support - $line =~ s/\%d/\%lld/g; - $line =~ s/\%u/\%llu/g; - $line =~ s/\%x/\%llx/g; - $line =~ s/\%X/\%llX/g; + $line =~ s/\%(\d*)(\.?)(\d*)(?:h?|l{0,2}|L?)d\b/\%$1$2$3lld/g; + $line =~ s/\%(\d*)(\.?)(\d*)(?:h?|l{0,2}|L?)i\b/\%$1$2$3lld/g; + $line =~ s/\%(\d*)(\.?)(\d*)(?:h?|l{0,2}|L?)u\b/\%$1$2$3llu/g; + $line =~ s/\%(\d*)(\.?)(\d*)(?:h?|l{0,2}|L?)x\b/\%$1$2$3llx/g; + $line =~ s/\%(\d*)(\.?)(\d*)(?:h?|l{0,2}|L?)X\b/\%$1$2$3llX/g; $line =~ s/\%p/0x\%llX/g; # Replace pointer format with hex value - $line =~ s/\%c/0x\%02llX/g; # Replace character format with 1 byte hex display #print "line: $line\n"; if($version eq "1") diff --git a/src/include/usr/trace/interface.H b/src/include/usr/trace/interface.H index 2b684ccd6..a082aaa1d 100644 --- a/src/include/usr/trace/interface.H +++ b/src/include/usr/trace/interface.H @@ -187,6 +187,31 @@ const uint32_t TRACE_FIELD = 0; //Indicates trace is field len, \ TRACE_FIELD) + +/** +@fn void TRACSCOMP(des, printf_string, args...) +@brief Defines all Strace Component Traces + +The user can pass 0 to 9 parameters to the macro. These traces will be treated +as debug traces but will never be compiled out of the code so that they can always be +dynamically turned on/off. + +@note If you are passing parameters then make sure 'printf_string' has the +@note necessary parameter formatting i.e. 'p1' = "hello" make sure +@note 'printf_string' has '%s' somewhere in it to corretcly format p1. +@return void The user will not be impacted by the failure of this function +@param des This is assigned by TRAC_INIT_BUFFER +@param printf_string string describing the trace entry and providing the formatting flags for any parameters passed. +@param p1,p2... Optional parameters + +tracepp replaces trace_adal_hash() with hash value and reduced format string +*/ + +/* a macro w/o the param number suffix. number is calculated from printf string */ +#define TRACSCOMP(des,printf_string,args...) \ + TRACE::Trace::trace_adal_write_all((des),__ALL_HASH(printf_string,-1),__LINE__,TRACE_DEBUG, ##args) + + /** * Field and Debug trace macros * Users must define COMP_TD for their components prior to using macros. @@ -227,6 +252,20 @@ const uint32_t TRACE_FIELD = 0; //Indicates trace is field #define DTRAC_EXIT_(args...) \ TRACDCOMP(__COMP_TD__, EXIT_MRK __COMP_NAMESPACE__ "::" __COMP_CLASS__ "::" __COMP_FN__ " " args) +#define STRAC_ENTER(args...) \ + TRACSCOMP(__COMP_TD__, ENTER_MRK args) +#define STRAC_EXIT(args...) \ + TRACSCOMP(__COMP_TD__, EXIT_MRK args) +#define STRAC_INF(args...) \ + TRACSCOMP(__COMP_TD__, INFO_MRK args) +#define STRAC_ERR(args...) \ + TRACSCOMP(__COMP_TD__, ERR_MRK args) + +#define STRAC_ENTER_(args...) \ + TRACSCOMP(__COMP_TD__, ENTER_MRK __COMP_NAMESPACE__ "::" __COMP_CLASS__ "::" __COMP_FN__ " " args) +#define STRAC_EXIT_(args...) \ + TRACSCOMP(__COMP_TD__, EXIT_MRK __COMP_NAMESPACE__ "::" __COMP_CLASS__ "::" __COMP_FN__ " " args) + /** * @fn void TRAC_INIT_BUFFER(des,comp_name, bufferSize) * @brief Initializes trace buffer for component diff --git a/src/usr/trace/test/tracetest.H b/src/usr/trace/test/tracetest.H index a68b6ccae..e574f55c5 100644 --- a/src/usr/trace/test/tracetest.H +++ b/src/usr/trace/test/tracetest.H @@ -71,7 +71,19 @@ public: // Do a debug trace TRACDCOMP(g_trac_test,"This is a debug trace"); - // Need to run a formatting test, but I know it will fail. + // Do an strace + TRACSCOMP(g_trac_test, "STRACE: Testing all number types (c,u,X,d,s): %c %u 0x%X %d %s", + 'b',i,i+1,i+2,"Hostboot"); + + // Test formatting + TRACFCOMP(g_trac_test, "Test width.precision formatting (u,x,X,d): %8u 0x%.06x 0x%16X %01.01d", + 0xABCD,0x1234,0x123456789ABCDEF0,0x12345678); + + TRACFCOMP(g_trac_test, "Test width.precision.length formatting (u,x,X,d): %8hu 0x%.06lx 0x%16LX %01.01lld", + 0xABCD,0x1234,0x123456789ABCDEF0,0x12345678); + + TRACFCOMP(g_trac_test, "Test width.precision.length formatting (u,x,X,i): %8hu 0x%.06lx 0x%16LX %01.01lli", + 0xABCD,0x1234,0x123456789ABCDEF0,0x12345678AB); } // Be sure a NULL trace descriptor does not cause a failure @@ -86,7 +98,7 @@ public: void testTracBinary(void) { trace_desc_t *g_trac_test = NULL; - TRAC_INIT_BUFFER(&g_trac_test, "EXAMPLE", 4096); + TRAC_INIT_BUFFER(&g_trac_test, "EXAMPLEBIN", 4096); if(g_trac_test == NULL) { @@ -119,7 +131,7 @@ public: void testTracMix(void) { trace_desc_t *g_trac_test = NULL; - TRAC_INIT_BUFFER(&g_trac_test, "EXAMPLE", 4096); + TRAC_INIT_BUFFER(&g_trac_test, "EXAMPLEMIX", 4096); if(g_trac_test == NULL) { @@ -201,6 +213,14 @@ public: DTRAC_ERR("Testing Debug Error Mark"); DTRAC_EXIT("testTracMacros - Debug Trace"); DTRAC_EXIT_(" - Debug Trace"); + + STRAC_ENTER("testTracMacros - Strace"); + STRAC_ENTER_(" - Strace"); + STRAC_INF("Testing Strace Info Mark"); + STRAC_ERR("Testing Strace Error Mark"); + STRAC_EXIT("testTracMacros - Strace"); + STRAC_EXIT_(" - Strace"); + } #undef __COMP_FN__ diff --git a/src/usr/trace/trace.C b/src/usr/trace/trace.C index 0f79c93cf..b37940300 100644 --- a/src/usr/trace/trace.C +++ b/src/usr/trace/trace.C @@ -328,6 +328,7 @@ void Trace::_trace_adal_write_all(trace_desc_t *io_td, //trace_entire_entry_t l_entry; trace_bin_entry_t l_entry; uint64_t l_str_map = 0; + uint64_t l_char_map = 0; /*------------------------------------------------------------------------*/ @@ -374,6 +375,21 @@ void Trace::_trace_adal_write_all(trace_desc_t *io_td, // num_args, l_data_size); //printk("Trace: l_str_map 0x%16llX\n", static_cast<long long>(l_str_map)); } + else if ('c' == _fmt[i]) + { + // Set flag to indicate argument is a char + l_char_map = l_char_map | (1 << num_args); + + // Increment arg counts + num_args++; + num_4byte_args++; + + // Retrieve the argument to increment to next one + uint32_t l_tmpData = va_arg(i_args, uint32_t); + + // Add to total size; data is word aligned + l_data_size += sizeof(l_tmpData); + } else { // Numbers count as two 4-byte arg @@ -447,6 +463,13 @@ void Trace::_trace_adal_write_all(trace_desc_t *io_td, //printk("Trace::trace_adal_write_all - num_args %d l_data_size %d l_entry_size %d\n", // num_args, l_data_size, l_entry_size); } + else if (l_char_map & (1 << i)) + { + // Save char to buffer & increment pointer (no need to align) + *(reinterpret_cast<uint32_t *>(l_ptr)) = va_arg(l_args, uint32_t); + l_ptr += sizeof(uint32_t); + + } else { // Save number to buffer & increment pointer (no need to align) |