Repository navigation
Expand file tree
/
Copy pathcmd_exception.cpp
More file actions
106 lines (96 loc) · 4.11 KB
/
Copy pathcmd_exception.cpp
File metadata and controls
106 lines (96 loc) · 4.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
/*
+----------------------------------------------------------------------+
| HipHop for PHP |
+----------------------------------------------------------------------+
| Copyright (c) 2010-2013 Facebook, Inc. (http://www.facebook.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
*/
#include "hphp/runtime/debugger/cmd/cmd_exception.h"
namespace HPHP { namespace Eval {
///////////////////////////////////////////////////////////////////////////////
TRACE_SET_MOD(debugger);
void CmdException::list(DebuggerClient &client) {
if (client.argCount() == 0) {
client.addCompletion(DebuggerClient::AutoCompleteClasses);
client.addCompletion("error");
client.addCompletion("regex");
client.addCompletion("once");
} else if (client.arg(1, "regex") || client.arg(1, "once")) {
client.addCompletion(DebuggerClient::AutoCompleteClasses);
} else {
client.addCompletion(DebuggerClient::AutoCompleteCode);
}
}
void CmdException::help(DebuggerClient &client) {
client.helpTitle("Exception Command");
client.helpCmds(
"[e]xception {cls}", "breaks if class of exception throws",
"[e]xception {ns}\{cls}", "breaks if class of exception throws",
"[e]xception error", "breaks on errors, warnings and notices",
"[e]xception {above}@{url}", "breaks only if url also matches",
"", "",
"[e]xception [r]egex {above}", "breaks at matching regex pattern",
"[e]xception [o]nce {above}", "breaks just once then disables it",
"", "",
"[e]xception {above} if {php}", "breaks if condition meets",
"[e]xception {above} && {php}", "breaks and evaluates an expression",
nullptr
);
client.helpBody(
"Exception command is similar to '[b]reak' command, except it's used "
"to specify how to break on (or catch) a throw of an exception. Program "
"stops right before the exception is about to throw. Resuming program "
"execution will continue to throw the exception as is.\n"
"\n"
"Only a class name can be specified with an optional namespace. All "
"exceptions of the class or its sub-classes will be matched. To specify "
"a perfect match without sub-classing test, use '[e]xception [r]egex "
"^{exact class name}$', although regex can match in a lot more different "
"ways.\n"
"\n"
"An exception breakpoint can be listed, cleared or toggled with '[b]reak' "
"commands."
);
}
void CmdException::onClient(DebuggerClient &client) {
if (DebuggerCommand::displayedHelp(client)) return;
if (client.argCount() == 0) {
help(client);
return;
}
bool regex = false;
BreakPointInfo::State state = BreakPointInfo::Always;
int index = 1;
if (client.arg(1, "regex")) {
regex = true;
index++;
} else if (client.arg(1, "once")) {
state = BreakPointInfo::Once;
index++;
}
BreakPointInfoPtr bpi(new BreakPointInfo(regex, state, ExceptionThrown,
client.argValue(index), ""));
if (!addToBreakpointListAndUpdateServer(client, bpi, index)) {
client.tutorial(
"This is the order of different arguments:\n"
"\n"
"\t[e]xception [r]egex|[o]nce {exp} if|&& {php}\n"
"\n"
"These are the components in an exception {exp}:\n"
"\n"
"\terror@{url}"
"\t{namespace}::{cls}@{url}"
"\n"
);
}
}
///////////////////////////////////////////////////////////////////////////////
}}