Loading...
Searching...
No Matches
ocsd_code_follower.h
Go to the documentation of this file.
/*
* \file ocsd_code_follower.h
* \brief OpenCSD : Code follower for instruction trace decode
*
* \copyright Copyright (c) 2016, ARM Limited. All Rights Reserved.
*/
/*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef ARM_OCSD_CODE_FOLLOWER_H_INCLUDED
#define ARM_OCSD_CODE_FOLLOWER_H_INCLUDED
#include "opencsd/ocsd_if_types.h"
#include "opencsd/trc_pkt_types.h"
#include "comp_attach_pt_t.h"
#include "interfaces/trc_tgt_mem_access_i.h"
#include "interfaces/trc_instr_decode_i.h"
class OcsdCodeFollower
{
public:
OcsdCodeFollower();
~OcsdCodeFollower();
//*********** setup API
void initInterfaces(componentAttachPt<ITargetMemAccess> *pMemAccess, componentAttachPt<IInstrDecode> *pIDecode);
// set information for decode operation - static or occasionally changing settings
// per decode values are passed as parameters into the decode API calls.
void setArchProfile(const ocsd_arch_profile_t profile);
void setMemSpaceAccess(const ocsd_mem_space_acc_t mem_acc_rule);
void setMemSpaceCSID(const uint8_t csid);
void setISA(const ocsd_isa isa);
void setDSBDMBasWP();
//********** code following API
// standard WP search - for program flow trace
//ocsd_err_t followToAtomWP(idec_res_t &op_result, const ocsd_vaddr_t addrStart, const ocsd_atm_val A);
// PTM exception code may require follow to an address
//ocsd_err_t followToAddress(idec_res_t &op_result, const ocsd_vaddr_t addrStart, const ocsd_atm_val A, const ocsd_vaddr_t addrMatch);
// single instruction atom format such as ETMv3
ocsd_err_t followSingleAtom(const ocsd_vaddr_t addrStart, const ocsd_atm_val A);
// follow N instructions
// ocsd_err_t followNInstructions(idec_res_t &op_result) // ETMv4 Q elements
//*********************** results API
const ocsd_vaddr_t getRangeSt() const;
const ocsd_vaddr_t getRangeEn() const;
const bool hasRange() const;
const bool hasNextAddr() const;
const ocsd_vaddr_t getNextAddr() const;
// information on last instruction executed in range.
const ocsd_instr_type getInstrType() const;
const ocsd_instr_subtype getInstrSubType() const;
const bool isCondInstr() const;
const bool isLink() const;
const bool ISAChanged() const;
const ocsd_isa nextISA() const;
const uint8_t getInstrSize() const;
// information on error conditions
const bool isNacc() const;
void clearNacc();
const ocsd_vaddr_t getNaccAddr() const;
const ocsd_mem_space_acc_t getMemSpaceAccess() const;
private:
bool initFollowerState();
ocsd_err_t decodeSingleOpCode();
ocsd_instr_info m_instr_info;
ocsd_vaddr_t m_st_range_addr;
ocsd_vaddr_t m_en_range_addr;
ocsd_vaddr_t m_next_addr;
bool m_b_next_valid;
ocsd_mem_space_acc_t m_mem_acc_rule;
uint8_t m_mem_space_csid;
ocsd_vaddr_t m_nacc_address;
bool m_b_nacc_err;
componentAttachPt<ITargetMemAccess> *m_pMemAccess;
componentAttachPt<IInstrDecode> *m_pIDecode;
};
#endif // ARM_OCSD_CODE_FOLLOWER_H_INCLUDED
//*********** setup API
inline void OcsdCodeFollower::setArchProfile(const ocsd_arch_profile_t profile)
{
m_instr_info.pe_type = profile;
}
inline void OcsdCodeFollower::setMemSpaceAccess(const ocsd_mem_space_acc_t mem_acc_rule)
{
m_mem_acc_rule = mem_acc_rule;
}
inline const ocsd_mem_space_acc_t OcsdCodeFollower::getMemSpaceAccess() const
{
return m_mem_acc_rule;
}
inline void OcsdCodeFollower::setMemSpaceCSID(const uint8_t csid)
{
m_mem_space_csid = csid;
}
inline void OcsdCodeFollower::setISA(const ocsd_isa isa)
{
m_instr_info.isa = isa;
}
inline void OcsdCodeFollower::setDSBDMBasWP()
{
m_instr_info.dsb_dmb_waypoints = 1;
}
//**************************************** results API
inline const ocsd_vaddr_t OcsdCodeFollower::getRangeSt() const
{
return m_st_range_addr;
}
inline const ocsd_vaddr_t OcsdCodeFollower::getRangeEn() const
{
return m_en_range_addr;
}
inline const bool OcsdCodeFollower::hasRange() const
{
return m_st_range_addr < m_en_range_addr;
}
inline const bool OcsdCodeFollower::hasNextAddr() const
{
return m_b_next_valid;
}
inline const ocsd_vaddr_t OcsdCodeFollower::getNextAddr() const
{
return m_next_addr;
}
// information on last instruction executed in range.
inline const ocsd_instr_type OcsdCodeFollower::getInstrType() const
{
return m_instr_info.type;
}
inline const ocsd_instr_subtype OcsdCodeFollower::getInstrSubType() const
{
return m_instr_info.sub_type;
}
inline const uint8_t OcsdCodeFollower::getInstrSize() const
{
return m_instr_info.instr_size;
}
inline const bool OcsdCodeFollower::isCondInstr() const
{
return (bool)(m_instr_info.is_conditional == 1);
}
inline const bool OcsdCodeFollower::isLink() const
{
return (bool)(m_instr_info.is_link == 1);
}
inline const bool OcsdCodeFollower::ISAChanged() const
{
return (bool)(m_instr_info.isa != m_instr_info.next_isa);
}
inline const ocsd_isa OcsdCodeFollower::nextISA() const
{
return m_instr_info.next_isa;
}
// information on error conditions
inline const bool OcsdCodeFollower::isNacc() const
{
return m_b_nacc_err;
}
inline void OcsdCodeFollower::clearNacc()
{
m_b_nacc_err = false;
}
inline const ocsd_vaddr_t OcsdCodeFollower::getNaccAddr() const
{
return m_nacc_address;
}
/* End of File ocsd_code_follower.h */
OcsdCodeFollower
The code follower looks for waypoints or addresses.
Definition ocsd_code_follower.h:53
OcsdCodeFollower::followSingleAtom
ocsd_err_t followSingleAtom(const ocsd_vaddr_t addrStart, const ocsd_atm_val A)
OcsdCodeFollower::getMemSpaceAccess
const ocsd_mem_space_acc_t getMemSpaceAccess() const
get the memory space used for access.
Definition ocsd_code_follower.h:145
OcsdCodeFollower::getNextAddr
const ocsd_vaddr_t getNextAddr() const
next address - valid if hasNextAddr() true.
Definition ocsd_code_follower.h:186
OcsdCodeFollower::isNacc
const bool isNacc() const
true if Memory Not Accessible (nacc) error occurred
Definition ocsd_code_follower.h:228
OcsdCodeFollower::nextISA
const ocsd_isa nextISA() const
ISA for next instruction.
Definition ocsd_code_follower.h:222
OcsdCodeFollower::setMemSpaceCSID
void setMemSpaceCSID(const uint8_t csid)
memory spaces might be partitioned by CSID
Definition ocsd_code_follower.h:150
OcsdCodeFollower::setISA
void setISA(const ocsd_isa isa)
set the ISA for the decode.
Definition ocsd_code_follower.h:155
OcsdCodeFollower::initInterfaces
void initInterfaces(componentAttachPt< ITargetMemAccess > *pMemAccess, componentAttachPt< IInstrDecode > *pIDecode)
OcsdCodeFollower::getNaccAddr
const ocsd_vaddr_t getNaccAddr() const
get the nacc error address.
Definition ocsd_code_follower.h:238
OcsdCodeFollower::~OcsdCodeFollower
~OcsdCodeFollower()
OcsdCodeFollower::setArchProfile
void setArchProfile(const ocsd_arch_profile_t profile)
core profile
Definition ocsd_code_follower.h:135
OcsdCodeFollower::getInstrSize
const uint8_t getInstrSize() const
Get the last instruction size.
Definition ocsd_code_follower.h:202
OcsdCodeFollower::ISAChanged
const bool ISAChanged() const
next ISA different from input ISA.
Definition ocsd_code_follower.h:217
OcsdCodeFollower::getRangeSt
const ocsd_vaddr_t getRangeSt() const
inclusive start address of decoded range (value passed in)
Definition ocsd_code_follower.h:166
OcsdCodeFollower::hasRange
const bool hasRange() const
we have a valid range executed (may be false if nacc).
Definition ocsd_code_follower.h:176
OcsdCodeFollower::hasNextAddr
const bool hasNextAddr() const
we have calulated the next address - otherwise this is needed from trace packets.
Definition ocsd_code_follower.h:181
OcsdCodeFollower::isCondInstr
const bool isCondInstr() const
is a conditional instruction
Definition ocsd_code_follower.h:207
OcsdCodeFollower::setMemSpaceAccess
void setMemSpaceAccess(const ocsd_mem_space_acc_t mem_acc_rule)
memory space to use for access (filtered by S/NS, EL etc).
Definition ocsd_code_follower.h:140
OcsdCodeFollower::OcsdCodeFollower
OcsdCodeFollower()
OcsdCodeFollower::getRangeEn
const ocsd_vaddr_t getRangeEn() const
exclusive end address of decoded range (first instruction not executed / potential next instruction).
Definition ocsd_code_follower.h:171
OcsdCodeFollower::isLink
const bool isLink() const
is a link (branch with link etc)
Definition ocsd_code_follower.h:212
OcsdCodeFollower::setDSBDMBasWP
void setDSBDMBasWP()
DSB and DMB can be treated as WP in some archs.
Definition ocsd_code_follower.h:160
OcsdCodeFollower::getInstrType
const ocsd_instr_type getInstrType() const
last instruction type
Definition ocsd_code_follower.h:192
OcsdCodeFollower::clearNacc
void clearNacc()
clear the nacc error flag
Definition ocsd_code_follower.h:233
OcsdCodeFollower::getInstrSubType
const ocsd_instr_subtype getInstrSubType() const
last instruction sub-type
Definition ocsd_code_follower.h:197
componentAttachPt
Single component interface pointer attachment point.
Definition comp_attach_pt_t.h:61
comp_attach_pt_t.h
OpenCSD : Component attachment point interface class.
ocsd_instr_subtype
enum _ocsd_instr_subtype ocsd_instr_subtype
ocsd_instr_type
enum _ocsd_instr_type ocsd_instr_type
ocsd_mem_space_acc_t
enum _ocsd_mem_space_acc_t ocsd_mem_space_acc_t
ocsd_err_t
enum _ocsd_err_t ocsd_err_t
ocsd_isa
enum _ocsd_isa ocsd_isa
ocsd_vaddr_t
uint64_t ocsd_vaddr_t
Definition ocsd_if_types.h:306
ocsd_atm_val
enum _ocsd_atm_val ocsd_atm_val
ocsd_if_types.h
OpenCSD : Standard Types used in the library interfaces.
_ocsd_arch_profile_t
Definition ocsd_if_types.h:295
_ocsd_instr_info
Definition ocsd_if_types.h:383
_ocsd_instr_info::dsb_dmb_waypoints
uint8_t dsb_dmb_waypoints
Definition ocsd_if_types.h:389
_ocsd_instr_info::type
ocsd_instr_type type
Definition ocsd_if_types.h:393
_ocsd_instr_info::sub_type
ocsd_instr_subtype sub_type
Definition ocsd_if_types.h:400
_ocsd_instr_info::is_conditional
uint8_t is_conditional
Definition ocsd_if_types.h:397
_ocsd_instr_info::next_isa
ocsd_isa next_isa
Definition ocsd_if_types.h:395
_ocsd_instr_info::instr_size
uint8_t instr_size
Definition ocsd_if_types.h:396
_ocsd_instr_info::pe_type
ocsd_arch_profile_t pe_type
Definition ocsd_if_types.h:385
_ocsd_instr_info::isa
ocsd_isa isa
Definition ocsd_if_types.h:386
_ocsd_instr_info::is_link
uint8_t is_link
Definition ocsd_if_types.h:398
trc_instr_decode_i.h
trc_pkt_types.h
OpenCSD: Common "C" types for trace packets.
trc_tgt_mem_access_i.h