|
1 // eventhandler.cpp |
|
2 // |
|
3 // Copyright (c) 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 #include "eventhandler.h" |
|
13 #include <fshell/extrabtracek.h> |
|
14 #include <kern_priv.h> |
|
15 #include <fshell/btrace_parser_defs.h> |
|
16 |
|
17 DExtraBtraceEventHandler::DExtraBtraceEventHandler(DObject* aParent) |
|
18 : DKernelEventHandler(&Event, this), iParent(aParent) |
|
19 { |
|
20 // iParent has been opened on our behalf by the caller (or it is null) |
|
21 } |
|
22 |
|
23 DExtraBtraceEventHandler::~DExtraBtraceEventHandler() |
|
24 { |
|
25 if (iParent) |
|
26 { |
|
27 NKern::ThreadEnterCS(); |
|
28 iParent->AsyncClose(); |
|
29 NKern::ThreadLeaveCS(); |
|
30 } |
|
31 } |
|
32 |
|
33 TUint DExtraBtraceEventHandler::Event(TKernelEvent aEvent, TAny* a1, TAny* /*a2*/, TAny* /*aPrivateData*/) |
|
34 { |
|
35 switch (aEvent) |
|
36 { |
|
37 case EEventKillThread: |
|
38 { |
|
39 DObjectCon* threads=Kern::Containers()[EThread]; |
|
40 threads->Wait(); // hold mutex so so we can't interleave with priming data |
|
41 DThread* thread = static_cast<DThread*>(a1); |
|
42 switch (thread->iExitType) |
|
43 { |
|
44 case EExitKill: |
|
45 BTrace8(KAmTraceCategory, EAmTraceSubCategoryThreadKilled, thread->iId, thread->iExitReason); |
|
46 break; |
|
47 case EExitTerminate: |
|
48 BTrace8(KAmTraceCategory, EAmTraceSubCategoryThreadTerminated, thread->iId, thread->iExitReason); |
|
49 break; |
|
50 case EExitPanic: |
|
51 { |
|
52 BTraceN(KAmTraceCategory, EAmTraceSubCategoryThreadPanicked, thread->iId, thread->iExitReason, thread->iExitCategory.Ptr(), thread->iExitCategory.Size()); |
|
53 break; |
|
54 } |
|
55 default: |
|
56 break; |
|
57 } |
|
58 threads->Signal(); |
|
59 break; |
|
60 } |
|
61 case EEventRemoveProcess: |
|
62 { |
|
63 DProcess* process = static_cast<DProcess*>(a1); |
|
64 switch (process->iExitType) |
|
65 { |
|
66 case EExitKill: |
|
67 BTrace8(KAmTraceCategory, EAmTraceSubCategoryProcessKilled, process->iId, process->iExitReason); |
|
68 break; |
|
69 case EExitTerminate: |
|
70 BTrace8(KAmTraceCategory, EAmTraceSubCategoryProcessTerminated, process->iId, process->iExitReason); |
|
71 break; |
|
72 case EExitPanic: |
|
73 { |
|
74 BTraceN(KAmTraceCategory, EAmTraceSubCategoryProcessPanicked, process->iId, process->iExitReason, process->iExitCategory.Ptr(), process->iExitCategory.Size()); |
|
75 break; |
|
76 } |
|
77 default: |
|
78 break; |
|
79 } |
|
80 break; |
|
81 } |
|
82 default: |
|
83 break; |
|
84 } |
|
85 |
|
86 return ERunNext; |
|
87 } |