Skip to content

Commit

Permalink
Log traces to error logs in HBRT
Browse files Browse the repository at this point in the history
This enables buffer tracing at hostboot runtime.
Will add these traces to runtime errors for better debug

Change-Id: I795bb7deafdd02adea4588ebf8dfb11cbce116a0
RTC:172770
Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/48084
Tested-by: Jenkins Server <pfd-jenkins+hostboot@us.ibm.com>
Reviewed-by: Christian R. Geddes <crgeddes@us.ibm.com>
Tested-by: Jenkins OP Build CI <op-jenkins+hostboot@us.ibm.com>
Tested-by: Jenkins OP HW <op-hw-jenkins+hostboot@us.ibm.com>
Tested-by: FSP CI Jenkins <fsp-CI-jenkins+hostboot@us.ibm.com>
Reviewed-by: Martin Gloff <mgloff@us.ibm.com>
Reviewed-by: Daniel M. Crowell <dcrowell@us.ibm.com>
  • Loading branch information
mderkse1 authored and dcrowell77 committed Oct 20, 2017
1 parent 20250c0 commit ad1909d
Show file tree
Hide file tree
Showing 12 changed files with 1,073 additions and 26 deletions.
7 changes: 7 additions & 0 deletions src/build/debug/simics-debug-framework.py
Original file line number Diff line number Diff line change
Expand Up @@ -595,6 +595,13 @@ def magic_instruction_callback(user_arg, cpu, arg):
dateCommand = "shell \" date +'%s > ISTEP %d.%d' \""%(percent_s,major_istep,minor_istep)
SIM_run_alone(run_command, dateCommand )

if arg == 7021: # MAGIC_PRINT_TWO_REGS
first_num = cpu.r4
second_num = cpu.r5
percent_s = "%s"
dateCommand = "shell \" date +'%s > TRACE REGS: %d %d' \""%(percent_s,first_num,second_num)
SIM_run_alone(run_command, dateCommand )

if arg == 7055: # MAGIC_CONTINUOUS_TRACE
hb_tracBinaryBuffer = cpu.r4
hb_tracBinaryBufferSz = cpu.r5
Expand Down
10 changes: 10 additions & 0 deletions src/include/arch/ppc.H
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,7 @@ enum
// env var HB_BREAK_ON_ERROR
MAGIC_GET_SBE_TRACES = 7019, // Collect SBE traces
MAGIC_PRINT_ISTEP = 7020, // Print istep to simics console
MAGIC_PRINT_TWO_REGS = 7021, // Print 2 numbers passed in

MAGIC_CONTINUOUS_TRACE = 7055, // extract mixed trace buffer
};
Expand All @@ -485,5 +486,14 @@ enum
"r" (_major), "r" (_minor) : "4", "5"); \
MAGIC_INSTRUCTION(MAGIC_PRINT_ISTEP); \

/**
* @brief Display 2 numbers on the simics console
* @param[in] First number (uint64_t)
* @param[in] Second number (uint64_t)
*/
#define MAGIC_INST_PRINT_2_REGS(_first, _second) \
asm volatile("mr 4, %0; mr 5, %1" :: \
"r" (_first), "r" (_second) : "4", "5"); \
MAGIC_INSTRUCTION(MAGIC_PRINT_TWO_REGS); \

#endif
9 changes: 7 additions & 2 deletions src/usr/errl/runtime/test/rt_errltest.H
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,13 @@ public:
l_err->appendToFFDC( pffdc, pch, strlen(pch) );

// Collect trace
// NOTE Trace buffers are not currently kept in Runtime
// - tests deleted

// Collect runtime trace and append to error log
if( !l_err->collectTrace("DEVFW") )
{
TS_FAIL( "collectTrace(DEVFW) rets false." );
break;
}

// Add null data.
pffdc = l_err->addFFDC( ERRL_COMP_ID, NULL, 0, 9, 10 );
Expand Down
33 changes: 26 additions & 7 deletions src/usr/trace/buffer.H
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/* */
/* OpenPOWER HostBoot Project */
/* */
/* Contributors Listed Below - COPYRIGHT 2012,2015 */
/* Contributors Listed Below - COPYRIGHT 2012,2017 */
/* [+] International Business Machines Corp. */
/* */
/* */
Expand All @@ -31,16 +31,20 @@

#include <trace/interface.H>
#include <sys/sync.h>
#include "daemon/daemon.H"

#ifndef __HOSTBOOT_RUNTIME
namespace TRACEDAEMON { class Daemon; } // Forward declaration.
#endif

namespace TRACE
{
// Forward declarations.
class BufferPage;
class Entry;
#ifndef __HOSTBOOT_RUNTIME
class DaemonIf;

#endif
/** @class Buffer
* @brief Class to manage the front-side (client) buffers
*
Expand All @@ -62,14 +66,23 @@ namespace TRACE
UNLIMITED = UINT32_MAX
};

#ifndef __HOSTBOOT_RUNTIME
/** Constructor.
*
* @param[in] i_daemon - Daemon interface for this buffer.
* @param[in] i_maxPages - Maximum number of pages to consume
* before 'claimEntry' blocks.
*/
Buffer(DaemonIf* i_daemon, size_t i_maxPages = 4);

#else
/** Constructor.
*
* @param[in] i_daemon - Runtime "daemon" for this buffer.
* @param[in] i_maxPages - Maximum number of pages to consume
* before 'claimEntry' blocks.
*/
Buffer(TRACEDAEMON::Daemon * i_daemon, size_t i_maxPages = 4);
#endif
/** @brief Claim an entry from the buffer to write data to.
*
* @param[in] i_comp - Component which will own entry.
Expand Down Expand Up @@ -104,6 +117,7 @@ namespace TRACE

BufferPage* volatile iv_firstPage; //< Most recent page.

#ifndef __HOSTBOOT_RUNTIME
/** @union locklessCounter
*
* This class is mostly lockless in that multiple trace entries
Expand Down Expand Up @@ -141,6 +155,13 @@ namespace TRACE

DaemonIf* iv_daemon; //< Daemon interface.

void _producerEnter(); //< Enter client section.
void _producerExit(); //< Exit client section.
void _consumerEnter(); //< Enter daemon section.
void _consumerExit(); //< Exit daemon section.
#else
TRACEDAEMON::Daemon * iv_daemon; // Daemon
#endif
/** @brief Claim front-side buffer pages to be merged into the
* common buffer.
*
Expand Down Expand Up @@ -186,13 +207,11 @@ namespace TRACE
Entry* i_condActVal = NULL,
Entry** i_addr = NULL, Entry* i_val = NULL);

void _producerEnter(); //< Enter client section.
void _producerExit(); //< Exit client section.
void _consumerEnter(); //< Enter daemon section.
void _consumerExit(); //< Exit daemon section.

friend class BufferTest;

friend class TRACEDAEMON::Daemon;

};
}

Expand Down
20 changes: 19 additions & 1 deletion src/usr/trace/bufferpage.C
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
/* */
/* OpenPOWER HostBoot Project */
/* */
/* COPYRIGHT International Business Machines Corp. 2012,2014 */
/* Contributors Listed Below - COPYRIGHT 2012,2017 */
/* [+] International Business Machines Corp. */
/* */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); */
/* you may not use this file except in compliance with the License. */
Expand All @@ -25,7 +27,11 @@

#include <limits.h>
#include <stdlib.h>
#include <string.h>

#ifndef __HOSTBOOT_RUNTIME
#include <kernel/pagemgr.H>
#endif

namespace TRACE
{
Expand Down Expand Up @@ -60,7 +66,11 @@ namespace TRACE
{
BufferPage* page = NULL;

#ifndef __HOSTBOOT_RUNTIME
page = reinterpret_cast<BufferPage*>(PageManager::allocatePage());
#else
page = reinterpret_cast<BufferPage*>(malloc(PAGESIZE));
#endif
memset(page, '\0', PAGESIZE);

if (i_common)
Expand All @@ -73,7 +83,15 @@ namespace TRACE

void BufferPage::deallocate(BufferPage* i_page)
{
#ifndef __HOSTBOOT_RUNTIME
PageManager::freePage(i_page);
#else
if (i_page != nullptr)
{
free(i_page);
i_page = nullptr;
}
#endif
}

}
6 changes: 5 additions & 1 deletion src/usr/trace/daemon/daemon.H
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/* */
/* OpenPOWER HostBoot Project */
/* */
/* Contributors Listed Below - COPYRIGHT 2012,2016 */
/* Contributors Listed Below - COPYRIGHT 2012,2017 */
/* [+] International Business Machines Corp. */
/* */
/* */
Expand Down Expand Up @@ -66,6 +66,10 @@ namespace TRACEDAEMON
*/
static void* start(void*);

#ifdef __HOSTBOOT_RUNTIME
void signal_trace_daemon(void);
#endif

private:

/** @fn execute
Expand Down
6 changes: 5 additions & 1 deletion src/usr/trace/interface.C
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/* */
/* OpenPOWER HostBoot Project */
/* */
/* Contributors Listed Below - COPYRIGHT 2012,2016 */
/* Contributors Listed Below - COPYRIGHT 2012,2017 */
/* [+] International Business Machines Corp. */
/* */
/* */
Expand Down Expand Up @@ -64,6 +64,10 @@ namespace TRACE
i_size = KILOBYTE;
}

#ifdef __HOSTBOOT_RUNTIME
// Run all Runtime traces to same buffer
i_bufferType = BUFFER_FAST;
#endif
(*o_td) =
Singleton<ComponentList>::instance().getDescriptor(i_comp,
i_size,
Expand Down
11 changes: 10 additions & 1 deletion src/usr/trace/runtime/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
#
# OpenPOWER HostBoot Project
#
# COPYRIGHT International Business Machines Corp. 2013,2014
# Contributors Listed Below - COPYRIGHT 2013,2017
# [+] International Business Machines Corp.
#
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -27,7 +29,14 @@ MODULE = trace_rt
OBJS += interface.o
OBJS += assert.o
OBJS += compdesc.o
OBJS += complist.o
OBJS += rt_service.o
OBJS += bufferpage.o
OBJS += rt_daemon.o
OBJS += rt_buffer.o


VPATH += ..
VPATH += ../daemon

include $(ROOTPATH)/config.mk

0 comments on commit ad1909d

Please sign in to comment.