sdkcreationmw/sdkruntimes/scard/src/SdkCardDebug.cpp
author rajpuroh
Mon, 08 Mar 2010 12:09:11 +0530
changeset 0 b26acd06ea60
permissions -rw-r--r--
First Contribution of SDK components
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
     1
/*
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
     2
* Copyright (c) 2003-2005 Nokia Corporation and/or its subsidiary(-ies).
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
     3
* All rights reserved.
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
     4
* This component and the accompanying materials are made available
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
     6
* which accompanies this distribution, and is available
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
     8
*
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
     9
* Initial Contributors:
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    11
*
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    12
* Contributors:
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    13
*
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    14
* Description: 
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    15
*
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    16
*/
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    17
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    18
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    19
#include "SdkCardDebug.h"
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    20
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    21
//===========================================================================
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    22
// Debugging support
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    23
//===========================================================================
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    24
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    25
#ifdef _REALLY_DEBUG
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    26
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    27
extern "C" int __stdcall IsDebuggerPresent(void);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    28
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    29
// ASSERT
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    30
void SdkCardAssert(const TText* s, const TText* f, TInt l)
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    31
{
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    32
    TRACE1("Assertion failed: %s",s);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    33
    TRACE1("File: %s",f);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    34
    TRACE1("Line: %d",l);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    35
    if (IsDebuggerPresent())
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    36
    {
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    37
        __BREAKPOINT();
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    38
    }
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    39
}
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    40
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    41
// ASSERT_SUCCESS
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    42
TInt SdkCardAssertSuccess(TInt err, const TText* s, const TText* f, TInt l)
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    43
{
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    44
    if (err != KErrNone)
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    45
    {
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    46
        TRACE1("Unexpected error: %d",err);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    47
        TRACE1("Expression: %s",s);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    48
        TRACE1("File: %s",f);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    49
        TRACE1("Line: %d",l);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    50
        if (IsDebuggerPresent())
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    51
        {
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    52
            __BREAKPOINT();
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    53
        }
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    54
    }
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    55
    return err;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    56
}
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    57
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    58
// LEAVE
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    59
void SdkCardLeave(TInt err, const TText* s, const TText* f, TInt l)
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    60
{
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    61
    TRACE2("Leaving with error %d (%s)",err,s);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    62
    TRACE1("File: %s",f);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    63
    TRACE1("Line: %d",l);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    64
    if (IsDebuggerPresent())
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    65
    {
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    66
        __BREAKPOINT();
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    67
    }
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    68
    User::Leave(err);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    69
}
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    70
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    71
// LEAVE_IF_NULL
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    72
void SdkCardLeaveIfNull(void* ptr,const TText* s,const TText* f,TInt l)
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    73
{
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    74
    if (ptr != KErrNone)
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    75
    {
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    76
        TRACE1("Expression is NULL: %s",s);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    77
        TRACE1("File: %s",f);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    78
        TRACE1("Line: %d",l);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    79
        if (IsDebuggerPresent())
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    80
        {
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    81
            __BREAKPOINT();
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    82
        }
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    83
        User::Leave(KErrNoMemory);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    84
    }
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    85
}
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    86
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    87
// LEAVE_IF_ERROR
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    88
void SdkCardLeaveIfError(TInt err, const TText* s, const TText* f, TInt l)
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    89
{
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    90
    if (err != KErrNone)
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    91
    {
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    92
        TRACE1("Unexpected error: %d",err);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    93
        TRACE1("Expression: %s",s);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    94
        TRACE1("File: %s",f);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    95
        TRACE1("Line: %d",l);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    96
        if (IsDebuggerPresent())
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    97
        {
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    98
            __BREAKPOINT();
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    99
        }
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   100
        User::Leave(err);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   101
    }
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   102
}
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   103
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   104
#endif // _REALLY_DEBUG