Skip to content

Commit

Permalink
bug 976077 - Part 1: Change utils.parse_dump to return the same forma…
Browse files Browse the repository at this point in the history
…t as the stackwalker JSON output, and change the report/index template to match
  • Loading branch information
luser committed Jul 11, 2014
1 parent e32f3dd commit 7c4d4be
Show file tree
Hide file tree
Showing 5 changed files with 157 additions and 134 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -351,19 +351,19 @@ <h2>Crashing Thread</h2>
</tr>
</thead>
<tbody>
{% for frame in parsed_dump.threads[parsed_dump.crashed_thread] %}
{% for frame in parsed_dump.threads[parsed_dump.crash_info.crashing_thread].frames %}
<tr>
<td>{{ frame.frame_num }}</td>
<td>{{ frame.module_name }}</td>
<td>{{ frame.frame }}</td>
<td>{{ frame.module }}</td>
<td title="{{ frame.signature }}">{{ frame.signature }}</td>
{% if frame.source_link %}
<td>
<a href="{{ frame.source_link }}">{{ frame.source_filename }}</a>
</td>
{% else %}
<td>
{% if frame.source %}
{{ frame.source }}:{{ frame.source_line }}
{% if frame.file %}
{{ frame.file }}:{{ frame.line }}
{% endif %}
</td>
{% endif %}
Expand All @@ -374,8 +374,9 @@ <h2>Crashing Thread</h2>

<p id="showallthreads" class="hidden"><a href="#allthreads">Show/hide other threads</a></p>
<div id="allthreads">
{% for thread_num in parsed_dump.remaining_threads | sort %}
<h2>Thread {{ thread_num }}</h2>
{% for thread in parsed_dump.threads %}
{%if thread.thread != parsed_dump.crash_info.crashing_thread %}
<h2>Thread {{ thread.thread }}</h2>
<table class="data-table">
<thead>
<tr>
Expand All @@ -386,23 +387,24 @@ <h2>Thread {{ thread_num }}</h2>
</tr>
</thead>
<tbody>
{% for frame in parsed_dump.threads[thread_num] %}
{% for frame in thread.frames %}
<tr >
<td>{{ frame.frame_num }}</td>
<td>{{ frame.module_name }}</td>
<td>{{ frame.frame }}</td>
<td>{{ frame.module }}</td>
<td title="{{ frame.signature }}">{{ frame.signature }}</td>
{% if frame.source_link %}
<td>
<a href="{{ frame.source_link }}">{{ frame.source_filename }}</a>
</td>
{% else %}
<td>{{ frame.source }}</td>
<td>{{ frame.file }}</td>
{% endif %}
</tr>
{% endfor %}
</tbody>
</table>
{% endfor %}
{% endif %}
{% endfor %}
</div>
</div><!-- /frames -->
{% endif %}
Expand Down Expand Up @@ -442,8 +444,8 @@ <h2>Thread {{ thread_num }}</h2>
<tr>
<td>{{ module.filename }}</td>
<td>{{ module.version }}</td>
<td>{{ module.debug_identifier }}</td>
<td>{{ module.debug_filename }}</td>
<td>{{ module.debug_id }}</td>
<td>{{ module.debug_file }}</td>
</tr>
{% endfor %}
</tbody>
Expand Down
143 changes: 76 additions & 67 deletions webapp-django/crashstats/crashstats/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ def test_parse_dump(self):
'0|1|bad.dll|signature|hg:hg.m.org/repo/name:fname:rev|576|0x0\n'
'1|0|ntdll.dll|KiFastSystemCallRet|||0x0\n'
'1|1|ntdll.dll|ZwClose|||0xb\n'
'1|2|ntdll.dll||||0xabc\n'
'1|3|||||0x1234\n'
)

vcs_mappings = {
Expand All @@ -66,73 +68,80 @@ def test_parse_dump(self):

actual = utils.parse_dump(dump, vcs_mappings)

expected = {'os_name': 'Windows NT',
'crashed_thread': 0,
'modules': [
{'debug_filename': 'debug.pdb',
'version': '1.0.0.1234',
'debug_identifier': 'debugver',
'filename': 'bad.exe'}
],
'cpu_name': 'x86',
'cpu_version': ('GenuineIntel family '
'15 model 4 stepping 9'),
'os_version': '6.1.7601 Service Pack 1',
'reason': 'EXCEPTION_ACCESS_VIOLATION_READ',
'threads': {
1: [
{'function': 'KiFastSystemCallRet',
'short_signature': 'KiFastSystemCallRet',
'source_line': '',
'source_link': '',
'source_filename': '',
'source_info': '',
'instruction': '0x0',
'source': '',
'frame_num': '0',
'signature': 'KiFastSystemCallRet',
'module_name': 'ntdll.dll'},
{'function': 'ZwClose',
'short_signature': 'ZwClose',
'source_line': '',
'source_link': '',
'source_filename': '',
'source_info': '',
'instruction': '0xb',
'source': '',
'frame_num': '1',
'signature': 'ZwClose',
'module_name': 'ntdll.dll'}
],
0: [
{'function': 'signature',
'short_signature': 'signature',
'source_line': '576',
'source_link': ('http://bonsai.m.org/'
'cvsblame.cgi?file=fname&'
'rev=rev&mark=576#576'),
'source_filename': 'fname',
'source_info': 'fname:576',
'instruction': '0x0',
'source': 'cvs:cvs.m.org/repo:fname:rev',
'frame_num': '0',
'signature': 'signature',
'module_name': 'bad.dll'},
{'function': 'signature',
'short_signature': 'signature',
'source_line': '576',
'source_link': ('http://hg.m.org/repo/name/'
'annotate/rev/fname#l576'),
'source_filename': 'fname',
'source_info': 'fname:576',
'instruction': '0x0',
'source': 'hg:hg.m.org/repo/name:fname:rev',
'frame_num': '1',
'signature': 'signature',
'module_name': 'bad.dll'}
]
},
'address': '0x290'}
expected = {
'status': 'OK',
'system_info': {
'os': 'Windows NT',
'os_ver': '6.1.7601 Service Pack 1',
'cpu_arch': 'x86',
'cpu_info': 'GenuineIntel family 15 model 4 stepping 9',
'cpu_count': 2},
'crash_info': {
'crashing_thread': 0,
'crash_address': '0x290',
'type': 'EXCEPTION_ACCESS_VIOLATION_READ'},
'main_module': 0,
'modules': [
{'debug_file': 'debug.pdb',
'version': '1.0.0.1234',
'debug_id': 'debugver',
'filename': 'bad.exe',
'base_addr': 'saddr',
'end_addr': 'eaddr'}],
'thread_count': 2,
'threads': [
{'thread': 0,
'frame_count': 2,
'frames': [
{'function': 'signature',
'short_signature': 'signature',
'line': 576,
'source_link': ('http://bonsai.m.org/'
'cvsblame.cgi?file=fname&'
'rev=rev&mark=576#576'),
'source_filename': 'fname',
'source_info': 'fname:576',
'file': 'cvs:cvs.m.org/repo:fname:rev',
'frame': 0,
'signature': 'signature',
'module': 'bad.dll'},
{'function': 'signature',
'short_signature': 'signature',
'line': 576,
'source_link': ('http://hg.m.org/repo/name/'
'annotate/rev/fname#l576'),
'source_filename': 'fname',
'source_info': 'fname:576',
'file': 'hg:hg.m.org/repo/name:fname:rev',
'frame': 1,
'signature': 'signature',
'module': 'bad.dll'}
]},
{'thread': 1,
'frame_count': 4,
'frames': [
{'function': 'KiFastSystemCallRet',
'short_signature': 'KiFastSystemCallRet',
'function_offset': '0x0',
'frame': 0,
'signature': 'KiFastSystemCallRet',
'module': 'ntdll.dll'},
{'function': 'ZwClose',
'short_signature': 'ZwClose',
'function_offset': '0xb',
'frame': 1,
'signature': 'ZwClose',
'module': 'ntdll.dll'},
{'signature': 'ntdll.dll@0xabc',
'short_signature': 'ntdll.dll@0xabc',
'module_offset': '0xabc',
'frame': 2,
'module': 'ntdll.dll'},
{'offset': '0x1234',
'frame': 3,
'signature': '@0x1234',
'short_signature': '@0x1234'}]}]
}

# the default line length for assert would be too short to be useful
self.maxDiff = None
Expand Down
14 changes: 7 additions & 7 deletions webapp-django/crashstats/crashstats/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -3149,7 +3149,7 @@ def mocked_get(url, params, **options):
@mock.patch('requests.get')
def test_report_index(self, rget, rpost):
# using \\n because it goes into the JSON string
dump = "OS|Mac OS X|10.6.8 10K549\\nCPU|amd64|family 6 mod"
dump = "OS|Mac OS X|10.6.8 10K549\\nCPU|amd64|family 6 mod|1"
comment0 = "This is a comment\\nOn multiple lines"
comment0 += "\\npeterbe@mozilla.com"
comment0 += "\\nwww.p0rn.com"
Expand Down Expand Up @@ -3232,7 +3232,7 @@ def test_report_index_odd_product_and_version(self, rget, rpost):
version it should not use that to make links in the nav to
reports for that unfamiliar product and version."""
# using \\n because it goes into the JSON string
dump = "OS|Mac OS X|10.6.8 10K549\\nCPU|amd64|family 6 mod"
dump = "OS|Mac OS X|10.6.8 10K549\\nCPU|amd64|family 6 mod|1"
comment0 = "This is a comment\\nOn multiple lines"
comment0 += "\\npeterbe@mozilla.com"
comment0 += "\\nwww.p0rn.com"
Expand Down Expand Up @@ -3297,7 +3297,7 @@ def mocked_post(url, **options):
@mock.patch('requests.get')
def test_report_index_correlations_failed(self, rget, rpost):
# using \\n because it goes into the JSON string
dump = "OS|Mac OS X|10.6.8 10K549\\nCPU|amd64|family 6 mod"
dump = "OS|Mac OS X|10.6.8 10K549\\nCPU|amd64|family 6 mod|1"
comment0 = "This is a comment"
email0 = "some@emailaddress.com"
url0 = "someaddress.com"
Expand Down Expand Up @@ -3372,7 +3372,7 @@ def mocked_get(url, params, **options):
@mock.patch('requests.post')
@mock.patch('requests.get')
def test_report_index_with_hangid_in_raw_data(self, rget, rpost):
dump = "OS|Mac OS X|10.6.8 10K549\\nCPU|amd64|family 6 mod"
dump = "OS|Mac OS X|10.6.8 10K549\\nCPU|amd64|family 6 mod|1"
comment0 = "This is a comment"
email0 = "some@emailaddress.com"
url0 = "someaddress.com"
Expand Down Expand Up @@ -3481,7 +3481,7 @@ def mocked_post(url, **options):
@mock.patch('requests.post')
@mock.patch('requests.get')
def test_report_index_with_invalid_InstallTime(self, rget, rpost):
dump = "OS|Mac OS X|10.6.8 10K549\\nCPU|amd64|family 6 mod"
dump = "OS|Mac OS X|10.6.8 10K549\\nCPU|amd64|family 6 mod|1"
comment0 = "This is a comment"
email0 = "some@emailaddress.com"
url0 = "someaddress.com"
Expand Down Expand Up @@ -3588,7 +3588,7 @@ def mocked_post(url, **options):
@mock.patch('requests.post')
@mock.patch('requests.get')
def test_report_index_with_crash_exploitability(self, rget, rpost):
dump = "OS|Mac OS X|10.6.8 10K549\\nCPU|amd64|family 6 mod"
dump = "OS|Mac OS X|10.6.8 10K549\\nCPU|amd64|family 6 mod|1"
comment0 = "This is a comment"
email0 = "some@emailaddress.com"
url0 = "someaddress.com"
Expand Down Expand Up @@ -4825,7 +4825,7 @@ def mocked_get(url, params, **options):
@mock.patch('requests.get')
def test_report_index_redirect_by_prefix(self, rget, rpost):

dump = "OS|Mac OS X|10.6.8 10K549\\nCPU|amd64|family 6 mod"
dump = "OS|Mac OS X|10.6.8 10K549\\nCPU|amd64|family 6 mod|1"
comment0 = "This is a comment"
email0 = "some@emailaddress.com"
url0 = "someaddress.com"
Expand Down
Loading

0 comments on commit 7c4d4be

Please sign in to comment.