|
1 /* |
|
2 * Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the License "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: osa debug library implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 /* |
|
19 * %version: 4 % |
|
20 */ |
|
21 |
|
22 #include "osa_includeme.h" |
|
23 #include <wlanosa.h> |
|
24 #include "osacarray.h" |
|
25 |
|
26 // ======== MEMBER FUNCTIONS ======== |
|
27 |
|
28 // --------------------------------------------------------------------------- |
|
29 // |
|
30 // --------------------------------------------------------------------------- |
|
31 // |
|
32 void MWlanOsa::FormattedPrint( TUint32 aLevel, |
|
33 const TInt8* aFmt, |
|
34 ... ) |
|
35 { |
|
36 #ifndef NDEBUG |
|
37 |
|
38 if ( DEBUG_LEVEL & aLevel ) |
|
39 { |
|
40 TPtrC8 format((const TText8*)aFmt); |
|
41 |
|
42 const TInt KTraceBufLen( 512 ); |
|
43 TBuf8<KTraceBufLen> msg; |
|
44 |
|
45 VA_LIST list; |
|
46 VA_START(list,aFmt); |
|
47 msg.Zero(); |
|
48 Kern::AppendFormat( msg, (const char*)aFmt, list ); |
|
49 msg.Append('\0'); |
|
50 Kern::Printf( (const char*)&msg[0] ); |
|
51 VA_END(list); |
|
52 } |
|
53 #endif // NDEBUG |
|
54 } |
|
55 |
|
56 // --------------------------------------------------------------------------- |
|
57 // |
|
58 // --------------------------------------------------------------------------- |
|
59 // |
|
60 void MWlanOsa::Assert( const TInt8* aFile, TInt aLine, TBool aExpression ) |
|
61 { |
|
62 #ifndef NDEBUG |
|
63 |
|
64 if ( !aExpression ) |
|
65 { |
|
66 TraceDump( MWlanOsa::KFatalLevel, |
|
67 (reinterpret_cast<const char*>(aFile)) ); |
|
68 TraceDump( MWlanOsa::KFatalLevel, (("Line: %d"), aLine)); |
|
69 |
|
70 Kern::Fault(("[WLAN] Subsystem programmed fault"), 0); |
|
71 } |
|
72 else |
|
73 { |
|
74 // left intentionally empty |
|
75 } |
|
76 |
|
77 #endif // NDEBUG |
|
78 } |
|
79 |
|
80 // --------------------------------------------------------------------------- |
|
81 // |
|
82 // --------------------------------------------------------------------------- |
|
83 // |
|
84 void MWlanOsa::Dump( TUint32 aLevelMask, |
|
85 const TInt8* aData, |
|
86 TInt aDataSize ) |
|
87 { |
|
88 #ifndef NDEBUG |
|
89 |
|
90 // Defines how many values in a row |
|
91 const TInt ValuesInRow = 8; |
|
92 |
|
93 const TInt LineWidth = 3*ValuesInRow; |
|
94 const char hex[16] = { '0', '1', '2', '3', '4', '5', '6', '7', |
|
95 '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'}; |
|
96 |
|
97 if ( DEBUG_LEVEL & aLevelMask ) |
|
98 { |
|
99 TBuf8< LineWidth > line; |
|
100 line.Zero(); |
|
101 for ( TInt i=0; i<aDataSize; i++ ) |
|
102 { |
|
103 line.Append( hex[*aData/16] ); |
|
104 line.Append( hex[*aData%16] ); |
|
105 if ( !((i+1)%ValuesInRow) || aDataSize == (i + 1) ) |
|
106 { |
|
107 line.Append( '\0' ); |
|
108 Kern::Printf( (const char*)&line[0] ); |
|
109 line.Zero(); |
|
110 } |
|
111 else |
|
112 { |
|
113 line.Append( ' ' ); |
|
114 } |
|
115 aData++; |
|
116 } |
|
117 } |
|
118 |
|
119 #endif // NDEBUG |
|
120 } |
|
121 |
|
122 |
|
123 |
|
124 |
|
125 |
|
126 |
|
127 |