| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -439,6 +439,11 @@ intl_optgroup.add_option('--download-path', | |||
| 439 | 439 | ||
| 440 | 440 | parser.add_option_group(intl_optgroup) | |
| 441 | 441 | ||
| 442 | + parser.add_option('--debug-lib', | ||
| 443 | + action='store_true', | ||
| 444 | + dest='node_debug_lib', | ||
| 445 | + help='build lib with DCHECK macros') | ||
| 446 | + | ||
| 442 | 447 | http2_optgroup.add_option('--debug-http2', | |
| 443 | 448 | action='store_true', | |
| 444 | 449 | dest='debug_http2', | |
@@ -949,6 +954,8 @@ def configure_node(o): | |||
| 949 | 954 | if options.enable_static: | |
| 950 | 955 | o['variables']['node_target_type'] = 'static_library' | |
| 951 | 956 | ||
| 957 | + o['variables']['node_debug_lib'] = b(options.node_debug_lib) | ||
| 958 | + | ||
| 952 | 959 | if options.debug_http2: | |
| 953 | 960 | o['variables']['debug_http2'] = 1 | |
| 954 | 961 | else: | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -5,3 +5,18 @@ rules: | |||
| 5 | 5 | no-let-in-for-declaration: error | |
| 6 | 6 | lowercase-name-for-primitive: error | |
| 7 | 7 | non-ascii-character: error | |
| 8 | + globals: | ||
| 9 | + CHECK: false | ||
| 10 | + CHECK_EQ: false | ||
| 11 | + CHECK_GE: false | ||
| 12 | + CHECK_GT: false | ||
| 13 | + CHECK_LE: false | ||
| 14 | + CHECK_LT: false | ||
| 15 | + CHECK_NE: false | ||
| 16 | + DCHECK: false | ||
| 17 | + DCHECK_EQ: false | ||
| 18 | + DCHECK_GE: false | ||
| 19 | + DCHECK_GT: false | ||
| 20 | + DCHECK_LE: false | ||
| 21 | + DCHECK_LT: false | ||
| 22 | + DCHECK_NE: false | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -702,6 +702,7 @@ | |||
| 702 | 702 | 'inputs': [ | |
| 703 | 703 | '<@(library_files)', | |
| 704 | 704 | './config.gypi', | |
| 705 | + 'tools/check_macros.py' | ||
| 705 | 706 | ], | |
| 706 | 707 | 'outputs': [ | |
| 707 | 708 | '<(SHARED_INTERMEDIATE_DIR)/node_javascript.cc', | |
@@ -715,6 +716,12 @@ | |||
| 715 | 716 | }], | |
| 716 | 717 | [ 'node_use_perfctr=="false"', { | |
| 717 | 718 | 'inputs': [ 'src/noperfctr_macros.py' ] | |
| 719 | + }], | ||
| 720 | + [ 'node_debug_lib=="false"', { | ||
| 721 | + 'inputs': [ 'tools/nodcheck_macros.py' ] | ||
| 722 | + }], | ||
| 723 | + [ 'node_debug_lib=="true"', { | ||
| 724 | + 'inputs': [ 'tools/dcheck_macros.py' ] | ||
| 718 | 725 | }] | |
| 719 | 726 | ], | |
| 720 | 727 | 'action': [ | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,7 @@ | |||
| 1 | + macro CHECK(x) = do { if (!(x)) (process._rawDebug("CHECK: x == true"), process.abort()) } while (0); | ||
| 2 | + macro CHECK_EQ(a, b) = CHECK((a) === (b)); | ||
| 3 | + macro CHECK_GE(a, b) = CHECK((a) >= (b)); | ||
| 4 | + macro CHECK_GT(a, b) = CHECK((a) > (b)); | ||
| 5 | + macro CHECK_LE(a, b) = CHECK((a) <= (b)); | ||
| 6 | + macro CHECK_LT(a, b) = CHECK((a) < (b)); | ||
| 7 | + macro CHECK_NE(a, b) = CHECK((a) !== (b)); | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,7 @@ | |||
| 1 | + macro DCHECK(x) = do { if (!(x)) (process._rawDebug("DCHECK: x == true"), process.abort()) } while (0); | ||
| 2 | + macro DCHECK_EQ(a, b) = DCHECK((a) === (b)); | ||
| 3 | + macro DCHECK_GE(a, b) = DCHECK((a) >= (b)); | ||
| 4 | + macro DCHECK_GT(a, b) = DCHECK((a) > (b)); | ||
| 5 | + macro DCHECK_LE(a, b) = DCHECK((a) <= (b)); | ||
| 6 | + macro DCHECK_LT(a, b) = DCHECK((a) < (b)); | ||
| 7 | + macro DCHECK_NE(a, b) = DCHECK((a) !== (b)); | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -74,20 +74,27 @@ def ExpandConstants(lines, constants): | |||
| 74 | 74 | ||
| 75 | 75 | ||
| 76 | 76 | def ExpandMacros(lines, macros): | |
| 77 | + def expander(s): | ||
| 78 | + return ExpandMacros(s, macros) | ||
| 77 | 79 | for name, macro in macros.items(): | |
| 78 | - start = lines.find(name + '(', 0) | ||
| 79 | - while start != -1: | ||
| 80 | + name_pattern = re.compile("\\b%s\\(" % name) | ||
| 81 | + pattern_match = name_pattern.search(lines, 0) | ||
| 82 | + while pattern_match is not None: | ||
| 80 | 83 | # Scan over the arguments | |
| 81 | - assert lines[start + len(name)] == '(' | ||
| 82 | 84 | height = 1 | |
| 83 | - end = start + len(name) + 1 | ||
| 85 | + start = pattern_match.start() | ||
| 86 | + end = pattern_match.end() | ||
| 87 | + assert lines[end - 1] == '(' | ||
| 84 | 88 | last_match = end | |
| 85 | - arg_index = 0 | ||
| 86 | - mapping = { } | ||
| 89 | + arg_index = [0] # Wrap state into array, to work around Python "scoping" | ||
| 90 | + mapping = {} | ||
| 87 | 91 | def add_arg(str): | |
| 88 | 92 | # Remember to expand recursively in the arguments | |
| 89 | - replacement = ExpandMacros(str.strip(), macros) | ||
| 90 | - mapping[macro.args[arg_index]] = replacement | ||
| 93 | + if arg_index[0] >= len(macro.args): | ||
| 94 | + return | ||
| 95 | + replacement = expander(str.strip()) | ||
| 96 | + mapping[macro.args[arg_index[0]]] = replacement | ||
| 97 | + arg_index[0] += 1 | ||
| 91 | 98 | while end < len(lines) and height > 0: | |
| 92 | 99 | # We don't count commas at higher nesting levels. | |
| 93 | 100 | if lines[end] == ',' and height == 1: | |
@@ -100,10 +107,13 @@ def add_arg(str): | |||
| 100 | 107 | end = end + 1 | |
| 101 | 108 | # Remember to add the last match. | |
| 102 | 109 | add_arg(lines[last_match:end-1]) | |
| 110 | + if arg_index[0] < len(macro.args) -1: | ||
| 111 | + lineno = lines.count(os.linesep, 0, start) + 1 | ||
| 112 | + raise Exception('line %s: Too few arguments for macro "%s"' % (lineno, name)) | ||
| 103 | 113 | result = macro.expand(mapping) | |
| 104 | 114 | # Replace the occurrence of the macro with the expansion | |
| 105 | 115 | lines = lines[:start] + result + lines[end:] | |
| 106 | - start = lines.find(name + '(', start) | ||
| 116 | + pattern_match = name_pattern.search(lines, start + len(result)) | ||
| 107 | 117 | return lines | |
| 108 | 118 | ||
| 109 | 119 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,7 @@ | |||
| 1 | + macro DCHECK(x) = void(x); | ||
| 2 | + macro DCHECK_EQ(a, b) = void(a, b); | ||
| 3 | + macro DCHECK_GE(a, b) = void(a, b); | ||
| 4 | + macro DCHECK_GT(a, b) = void(a, b); | ||
| 5 | + macro DCHECK_LE(a, b) = void(a, b); | ||
| 6 | + macro DCHECK_LT(a, b) = void(a, b); | ||
| 7 | + macro DCHECK_NE(a, b) = void(a, b); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments