|
1 // btraceout.cpp |
|
2 // |
|
3 // Copyright (c) 2009 - 2010 Accenture. All rights reserved. |
|
4 // This component and the accompanying materials are made available |
|
5 // under the terms of the "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 // Accenture - Initial contribution |
|
11 // |
|
12 |
|
13 #include <fshell/ioutils.h> |
|
14 #include <fshell/extrabtrace.h> |
|
15 |
|
16 using namespace IoUtils; |
|
17 |
|
18 class CCmdBtraceout : public CCommandBase |
|
19 { |
|
20 public: |
|
21 static CCommandBase* NewLC(); |
|
22 ~CCmdBtraceout(); |
|
23 private: |
|
24 CCmdBtraceout(); |
|
25 private: // From CCommandBase. |
|
26 virtual const TDesC& Name() const; |
|
27 virtual void DoRunL(); |
|
28 virtual void ArgumentsL(RCommandArgumentList& aArguments); |
|
29 virtual void OptionsL(RCommandOptionList& aOptions); |
|
30 private: |
|
31 TUint iCategory; |
|
32 TUint iSubcategory; |
|
33 TUint iArg1; |
|
34 TUint iArg2; |
|
35 TUint iArg3; |
|
36 TBool iStdin; |
|
37 TUint iFilterUid; |
|
38 TBool iTruncate; |
|
39 }; |
|
40 |
|
41 CCommandBase* CCmdBtraceout::NewLC() |
|
42 { |
|
43 CCmdBtraceout* self = new(ELeave) CCmdBtraceout(); |
|
44 CleanupStack::PushL(self); |
|
45 self->BaseConstructL(); |
|
46 return self; |
|
47 } |
|
48 |
|
49 CCmdBtraceout::~CCmdBtraceout() |
|
50 { |
|
51 } |
|
52 |
|
53 CCmdBtraceout::CCmdBtraceout() |
|
54 { |
|
55 } |
|
56 |
|
57 const TDesC& CCmdBtraceout::Name() const |
|
58 { |
|
59 _LIT(KName, "btraceout"); |
|
60 return KName; |
|
61 } |
|
62 |
|
63 void CCmdBtraceout::ArgumentsL(RCommandArgumentList& aArguments) |
|
64 { |
|
65 aArguments.AppendUintL(iCategory, _L("category")); |
|
66 aArguments.AppendUintL(iSubcategory, _L("subcategory")); |
|
67 aArguments.AppendUintL(iArg1, _L("arg_1")); |
|
68 aArguments.AppendUintL(iArg2, _L("arg_2")); |
|
69 aArguments.AppendUintL(iArg3, _L("arg_3")); |
|
70 } |
|
71 |
|
72 void CCmdBtraceout::OptionsL(RCommandOptionList& aOptions) |
|
73 { |
|
74 aOptions.AppendBoolL(iStdin, _L("stdin")); |
|
75 aOptions.AppendBoolL(iTruncate, _L("truncate")); |
|
76 aOptions.AppendUintL(iFilterUid, _L("filter")); |
|
77 } |
|
78 |
|
79 |
|
80 EXE_BOILER_PLATE(CCmdBtraceout) |
|
81 |
|
82 void CCmdBtraceout::DoRunL() |
|
83 { |
|
84 if (iStdin) |
|
85 { |
|
86 CTextBuffer* buffer = CTextBuffer::NewLC(512); |
|
87 Stdin().SetReadMode(RIoReadHandle::EOneOrMore); |
|
88 TBuf<256> buf; |
|
89 while (Stdin().Read(buf) == KErrNone) |
|
90 { |
|
91 buffer->AppendL(buf); |
|
92 } |
|
93 RBuf8 data; |
|
94 data.CreateL(buffer->Length()); |
|
95 data.Copy(buffer->Descriptor()); // This will collapse us back to real 8-bit data |
|
96 |
|
97 if (iTruncate) |
|
98 { |
|
99 if (iOptions.IsPresent(&iFilterUid)) |
|
100 { |
|
101 if (iArguments.IsPresent(3)) |
|
102 { |
|
103 PrintWarning(_L("Ignoring 'arg_2' (%u) and all following arguments"), iArg2); |
|
104 } |
|
105 BTraceFilteredN(iCategory, iSubcategory, iFilterUid, iArg1, data.Ptr(), data.Size()); |
|
106 } |
|
107 else |
|
108 { |
|
109 if (iArguments.IsPresent(3)) |
|
110 { |
|
111 PrintWarning(_L("Ignoring 'arg_3' (%u)"), iArg3); |
|
112 } |
|
113 BTraceN(iCategory, iSubcategory, iArg1, iArg2, data.Ptr(), data.Size()); |
|
114 } |
|
115 } |
|
116 else |
|
117 { |
|
118 if (iOptions.IsPresent(&iFilterUid)) |
|
119 { |
|
120 if (iArguments.IsPresent(2)) |
|
121 { |
|
122 PrintWarning(_L("Ignoring 'arg_1' (%u) and all following arguments"), iArg1); |
|
123 } |
|
124 BTraceFilteredBig(iCategory, iSubcategory, iFilterUid, data.Ptr(), data.Size()); |
|
125 } |
|
126 else |
|
127 { |
|
128 if (iArguments.IsPresent(3)) |
|
129 { |
|
130 PrintWarning(_L("Ignoring 'arg_2' (%u) and all following arguments"), iArg2); |
|
131 } |
|
132 BTraceBig(iCategory, iSubcategory, iArg1, data.Ptr(), data.Size()); |
|
133 } |
|
134 } |
|
135 |
|
136 data.Close(); |
|
137 CleanupStack::PopAndDestroy(buffer); |
|
138 } |
|
139 else |
|
140 { |
|
141 if (iArguments.IsPresent(4)) |
|
142 { |
|
143 if (iOptions.IsPresent(&iFilterUid)) |
|
144 { |
|
145 if (iArguments.IsPresent(3)) |
|
146 { |
|
147 PrintWarning(_L("Ignoring 'arg_3' (%u)"), iArg3); |
|
148 } |
|
149 BTraceFiltered12(iCategory, iSubcategory, iFilterUid, iArg1, iArg2); |
|
150 } |
|
151 else |
|
152 { |
|
153 BTrace12(iCategory, iSubcategory, iArg1, iArg2, iArg3); |
|
154 } |
|
155 } |
|
156 else if (iArguments.IsPresent(3)) |
|
157 { |
|
158 if (iOptions.IsPresent(&iFilterUid)) |
|
159 { |
|
160 BTraceFiltered12(iCategory, iSubcategory, iFilterUid, iArg1, iArg2); |
|
161 } |
|
162 else |
|
163 { |
|
164 BTrace8(iCategory, iSubcategory, iArg1, iArg2); |
|
165 } |
|
166 } |
|
167 else if (iArguments.IsPresent(2)) |
|
168 { |
|
169 if (iOptions.IsPresent(&iFilterUid)) |
|
170 { |
|
171 BTraceFiltered8(iCategory, iSubcategory, iFilterUid, iArg1); |
|
172 } |
|
173 else |
|
174 { |
|
175 BTrace4(iCategory, iSubcategory, iArg1); |
|
176 } |
|
177 } |
|
178 else |
|
179 { |
|
180 if (iOptions.IsPresent(&iFilterUid)) |
|
181 { |
|
182 BTraceFiltered4(iCategory, iSubcategory, iFilterUid); |
|
183 } |
|
184 else |
|
185 { |
|
186 BTrace0(iCategory, iSubcategory); |
|
187 } |
|
188 } |
|
189 } |
|
190 } |