{% extends "crashstats_base.html" %}

{% block site_css %}
  {{ super() }}

  {% compress css %}
  <link rel="stylesheet" type="text/css" href="{{ static('crashstats/css/lib/jquery-ui.css') }}" media="screen" />
  <link rel="stylesheet" type="text/css" href="{{ static('crashstats/css/lib/jquery-ui.structure.css') }}" media="screen" />
  <link rel="stylesheet" type="text/css" href="{{ static('crashstats/css/lib/jquery-ui.theme.css') }}" media="screen" />
  {% endcompress %}

  {% compress css %}
  <style type="text/css">
  #details th, #metadata th {
      width: 15%;
  }
  </style>
  {% endcompress %}

{% endblock %}

{% block page_title %}
  [@ {{ report.signature }}] - {{ report.product }} {{ report.version }} Crash Report - Report ID: {{ report.uuid }}
{% endblock %}

{% block content %}

<div id="mainbody">
  <div class="page-heading">
    <h2>{{ report.product }} {{ report.version }} Crash Report [@ {{ report.signature }} ]</h2>
  </div>

  <div class="panel">
    <div class="body">
      <div id="sumo-link"><a href="http://support.mozilla.org/search?q={{ report.signature|urlencode }}" title="Find more answers at support.mozilla.org!">Search Mozilla Support for Help</a></div>

      {% if hang_id %}
      <div class="oopp-hang">
        <div class="current">Hang Minidump <span class="type">({{ process_type }})</span></div>
        {% if crash_pairs.total == 0 %}
        <div class="pair">Hang ID {{ hang_id }} but no other UUID pair found</div>
        {% else %}
        <div class="pair">Hang ID <a href="{{ hang_id }}">{{ hang_id }}</a></div>
        {% endif%}
      </div>
      {% endif %}

      <div id="report-header-details">ID: <span>{{ report.uuid }}</span><br/> Signature: <span>{{ report.signature }}</span></div>
      <div id="report-index" class="no-border ui-tabs ui-widget ui-widget-content ui-corner-all">

      <ul class="ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all">
        <li class="ui-state-default ui-corner-top"><a href="#details" class="ui-tabs-anchor"><span>Details</span></a></li>
        <li class="ui-state-default ui-corner-top"><a href="#metadata" class="ui-tabs-anchor"><span>Metadata</span></a></li>
        <li class="ui-state-default ui-corner-top"><a href="#modules" class="ui-tabs-anchor"><span>Modules</span></a></li>
        <li class="ui-state-default ui-corner-top"><a href="#rawdump" class="ui-tabs-anchor"><span>Raw Dump</span></a></li>
        <li class="ui-state-default ui-corner-top"><a href="#extensions" class="ui-tabs-anchor"><span>Extensions</span></a></li>
        {% if total_correlations > 0 %}
        <li class="ui-state-default ui-corner-top"><a href="#correlation" class="ui-tabs-anchor"><span>Correlations</span></a></li>
        {% endif %}
      </ul>

      <div id="details" class="ui-tabs-panel ui-widget-content ui-corner-bottom">
        <table class="record data-table vertical">
          <tbody>
            <tr>
              <th scope="row">Signature</th>
              <td>
                {{ report.signature }}
                <a href="{{ url('crashstats:report_list') }}?product={{ report.product }}&amp;signature={{ report.signature|urlencode }}" class="sig-overview" title="View more reports of this type">More Reports</a>
                <a href="{{ url('crashstats:query') }}?signature={{ report.signature|urlencode }}#advanced" class="sig-search" title="Search for more reports of this type">Search</a>
              </td>
            </tr>
            <tr>
              <th scope="row">UUID</th>
              <td>{{ report.uuid }}</td>
            </tr>
            <tr>
              <th scope="row">Date Processed</th><td>{{ report.date_processed }}</td>
            </tr>
            {% if report.process_type %}
            <tr>
              <th scope="row">Process Type</th>
              <td>{{ report.process_type }}
                {% if report.PluginName %}
                  <strong class="name">{{ report.PluginName }}</strong>
                {% endif %}
                {% if report.PluginVersion %}
                  <span>Version:</span><span class="version">{{ report.PluginVersion }}</span>
                {% endif %}
                {% if report.PluginFilename %}
                  <span>Filename:</span><span class="filename">{{ report.PluginFilename }}</span>
                {% endif %}
              </td>
            </tr>
            {% endif %}
            <tr>
              <th scope="row">Uptime</th><td>{{ report.uptime }}</td>
            </tr>
            {% if report.last_crash %}
            <tr>
              <th scope="row">Last Crash</th><td>{{ report.last_crash }} seconds before submission</td>
            </tr>
            {% endif %}
            {% if report.install_age %}
            <tr>
              <th scope="row">Install Age</th>
              <td>{{ report.install_age }} since version was first installed.</td>
            </tr>
            {% endif %}
            {% if install_time %}
            <tr>
              <th scope="row">Install Time</th>
              <td>{{ install_time }}</td>
            </tr>
            {% endif %}
            <tr>
              <th scope="row">Product</th>
              <td>{{ report.product }}</td>
            </tr>
            <tr>
              <th scope="row">Version</th>
              <td>{{ report.version }}</td>
            </tr>
            <tr>
              <th scope="row">Build ID</th>
              <td>{{ report.build }}</td>
            </tr>
            <tr>
              <th scope="row">Release Channel</th>
              <td>{{ report.release_channel }}</td>
            </tr>
            <tr>
              <th scope="row">OS</th>
              <td>{{ report.os_name }}</td>
            </tr>
            <tr>
              <th scope="row">OS Version</th>
              <td>{{ report.os_version }}</td>
            </tr>
            {% if raw.B2G_OS_Version %}
            <tr>
              <th scope="row">B2G OS Version</th>
              <td><pre>{{ raw.B2G_OS_Version }}</pre></td>
            </tr>
            {% endif %}
            <tr>
              <th scope="row">Build Architecture</th>
              <td>{{ report.cpu_name }}</td>
            </tr>
            <tr>
              <th scope="row">Build Architecture Info</th>
              <td>{{ report.cpu_info }}</td>
            </tr>
            <tr>
              <th scope="row">Crash Reason</th>
              <td>{{ report.reason }}</td>
            </tr>
            <tr>
              <th scope="row">Crash Address</th>
              <td>{{ report.address }}</td>
            </tr>
	    {% if request.user.has_perm('crashstats.view_pii') %}
	    <tr>
	      <th scope="row">Email Address</th>
	      <td>
	        {% if raw.Email %}
		  <a href="mailto:{{ raw.Email }}">{{ raw.Email }}</a> - Super Sensitive! Don't mess around!
		{% endif %}
	      </td>
	    </tr>
	    <tr>
	      <th scope="row">URL</th>
	      <td>
	        {% if raw.URL %}
		  <a href="{{ raw.URL }}" title="{{ raw.URL }}">{{ raw.URL }}</a> - Super Sensitive! Don't mess around!
		{% endif %}
	      </td>
	    </tr>
	    {% endif %}
            {% if request.user.has_perm('crashstats.view_exploitability') %}
	    <tr>
	      <th scope="row">Exploitability</th>
	      <td>
	        {% if report.exploitability %}
		  {{ report.exploitability }}
		{% endif %}
	      </td>
	    </tr>
            {% endif %}
            <tr>
              <th scope="row">User Comments</th>
              <td>
                {% if report.user_comments %}
                  {% if request.user.has_perm('crashstats.view_pii') %}
                    {{ report.user_comments | nl2br }}
                  {% else %}
                    {{ report.user_comments | scrub_pii | nl2br }}
                  {% endif %}
                {% endif %}
              </td>
            </tr>
            {% if report.app_notes %}
            <tr>
              <th title="Notes added by the application's code during crash" scope="row">App Notes</th>
              <td><pre>{{ report.app_notes }}</pre></td>
            </tr>
            {% endif %}
            {% if report.processor_notes %}
            <tr>
              <th title="Notes added by Socorro when accepting the crash report" scope="row">Processor Notes</th>
              <td><code>{{ report.processor_notes }}</code></td>
            </tr>
            {% endif %}
            {% if report.distributor %}
            <tr>
              <th>
              <td><pre>{{ report.distributor }}</pre></td>
            </tr>
            {% endif %}
            {% if report.distributor_version %}
            <tr>
              <th>
              <td><pre>{{ report.distributor_version }}</pre></td>
            </tr>
            {% endif %}
            <tr>
              <th scope="row">EMCheckCompatibility</th>
              <td>
                <pre>{% if report.addons_checked %}True{% else %}False{% endif %}</pre>
              </td>
            </tr>
            <tr>
              <th scope="row">Winsock LSP</th>
              <td><pre>{{ report.Winsock_LSP }}</pre></td>
            </tr>
            <tr>
              <th scope="row">Adapter Vendor ID</th>
              <td><pre>{{ raw.AdapterVendorID }}</pre></td>
            </tr>
            <tr>
              <th scope="row">Adapter Device ID</th>
              <td><pre>{{ raw.AdapterDeviceID }}</pre></td>
            </tr>
            {% if raw.JavaStackTrace %}
            <tr>
              <th scope="row">Java Stack Trace</th>
              <td><pre>{{ raw.JavaStackTrace }}</pre></td>
            </tr>
            {% endif %}
            {% if raw.TotalVirtualMemory %}
            <tr>
              <th scope="row">Total Virtual Memory</th>
              <td><pre>{{ raw.TotalVirtualMemory }}</pre></td>
            </tr>
            {% endif %}
            {% if raw.AvailableVirtualMemory %}
            <tr>
              <th scope="row">Available Virtual Memory</th>
              <td><pre>{{ raw.AvailableVirtualMemory }}</pre></td>
            </tr>
            {% endif %}
            {% if raw.SystemMemoryUsePercentage %}
            <tr>
              <th scope="row">System Memory Use Percentage</th>
              <td><pre>{{ raw.SystemMemoryUsePercentage }}</pre></td>
            </tr>
            {% endif %}
            {% if raw.AvailablePageFile %}
            <tr>
              <th scope="row">Available Page File</th>
              <td><pre>{{ raw.AvailablePageFile }}</pre></td>
            </tr>
            {% endif %}
            {% if raw.AvailablePhysicalMemory %}
            <tr>
              <th scope="row">Available Physical Memory</th>
              <td><pre>{{ raw.AvailablePhysicalMemory }}</pre></td>
            </tr>
            {% endif %}
            {% if raw.OOMAllocationSize %}
            <tr>
              <th scope="row">OOM Allocation Size</th>
              <td><pre>{{ raw.OOMAllocationSize }}</pre></td>
            </tr>
            {% endif %}
            {% if raw.FlashProcessDump %}
            <tr>
              <th scope="row">Flash Process Dump</th>
              <td><pre>{{ raw.FlashProcessDump }}</pre></td>
            </tr>
            {% endif %}
            {% if raw.Accessibility %}
            <tr>
              <th scope="row">Accessibility</th>
              <td><pre>{{ raw.Accessibility }}</pre></td>
            </tr>
            {% endif %}
            {% if raw.Android_CPU_ABI%}
            <tr>
              <th scope="row">Android CPU ABI</th>
              <td><pre>{{ raw.Android_CPU_ABI}}</pre></td>
            </tr>
            {% endif %}
            {% if raw.Android_Manufacturer %}
            <tr>
              <th scope="row">Android Manufacturer</th>
              <td><pre>{{ raw.Android_Manufacturer }}</pre></td>
            </tr>
            {% endif %}
            {% if raw.Android_Model %}
            <tr>
              <th scope="row">Android Model</th>
              <td><pre>{{ raw.Android_Model }}</pre></td>
            </tr>
            {% endif %}
            {% if raw.Android_Version %}
            <tr>
              <th scope="row">Android Version</th>
              <td><pre>{{ raw.Android_Version }}</pre></td>
            </tr>
            {% endif %}
          </tbody>
        </table>

        <div id="bugzilla" class="bugreporter">
          <p><strong>Bugzilla</strong> - Report this bug in
          {% for bug_product in [report.product, 'Core', 'Plugins', 'Toolkit'] %}
            {% if bug_product in bug_product_map %}
              {% set bug_product = BUG_PRODUCT_MAP[bug_product] %}
            {% endif %}
            <a href="https://bugzilla.mozilla.org/enter_bug.cgi?bug_severity=critical&amp;keywords=crash&amp;product={{ bug_product | urlencode }}&amp;op_sys={{ report.os_name }}&amp;rep_platform={{ report.cpu_name }}&amp;cf_crash_signature={{ '[@' | urlencode }} {{ report.signature|urlencode }}{{ ']' | urlencode }}&amp;short_desc=crash in {{ report.signature|urlencode }}&amp;comment=This bug was filed from the Socorro interface and is %0Areport bp-{{ report.uuid }}.%0A=============================================================%0A" target="_blank">{{ bug_product }}</a>
          {% endfor %}
          </p>

          <h2>Related Bugs</h2>
          <div class="bug_ids_expanded_list">
            <ul class="bug_ids_expanded full_bug_ids full">
            {% for bug in bug_associations %}
              <li>{{ show_bug_link(bug.id) }}</li>
            {% endfor %}
            </ul>
          </div>
        </div><!-- /bugzilla -->

        {% if parsed_dump.threads %}
          <div id="frames">
            <h2>Crashing Thread</h2>
            <table class="data-table">
              <thead>
                <tr>
                  <th scope="col">Frame</th>
                  <th scope="col">Module</th>
                  <th class="signature-column" scope="col">Signature</th>
                  <th scope="col">Source</th>
                </tr>
              </thead>
              <tbody>
                {% for frame in parsed_dump.threads[parsed_dump.crash_info.crashing_thread].frames %}
                <tr class="{%if frame.missing_symbols %}missingsymbols{% endif %}">
                  <td>
                      {%if frame.missing_symbols %}
                          <span class="row-notice" title="missing symbol">&Oslash;</span>
                      {% endif %}
                      {{ 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.file }}</a>
                  </td>
                  {% else %}
                  <td>
                    {% if frame.file %}
                      {{ frame.file }}:{{ frame.line }}
                    {% endif %}
                  </td>
                  {% endif %}
                </tr>
                {% endfor %}
              </tbody>
            </table>

            <p id="showallthreads" class="hidden"><a href="#allthreads">Show/hide other threads</a></p>
            <div id="allthreads">
            {% 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>
                    <th scope="col">Frame</th>
                    <th scope="col">Module</th>
                    <th class="signature-column" scope="col">Signature</th>
                    <th scope="col">Source</th>
                  </tr>
                </thead>
                <tbody>
                  {% for frame in thread.frames %}
                  <tr class="{%if frame.missing_symbols %}missingsymbols{% endif %}">
                    <td>
                        {%if frame.missing_symbols %}
                            <span class="row-notice" title="missing symbol">&Oslash;</span>
                        {% endif %}
                        {{ 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.file }}</a>
                    </td>
                    {% else %}
                    <td>{{ frame.file }}</td>
                    {% endif %}
                  </tr>
                  {% endfor %}
                </tbody>
              </table>
              {% endif %}
            {% endfor %}
            </div>
          </div><!-- /frames -->
        {% endif %}
        </div><!-- /details -->

      <div id="metadata" class="ui-tabs-hide">
        <table class="record data-table vertical">
          <tbody>
            {% for key in raw_keys %}
            <tr>
              <th scope="row">{{ key }}</th>
              {% if key == 'Comments' %}
              <td>{{ raw[key] | scrub_pii }}</td>
              {% else %}
              <td>{{ raw[key] }}</td>
              {% endif %}
            </tr>
            {% endfor %}
          </tbody>
        </table>

        </div><!-- /#rawdetails -->

          <div id="modules" class="ui-tabs-hide">
            {% if parsed_dump.modules %}
            <table class="tablesorter data-table" id="modules-list">
              <thead>
                <tr>
                  <th scope="col">Filename</th>
                  <th scope="col">Version</th>
                  <th scope="col">Debug Identifier</th>
                  <th scope="col">Debug Filename</th>
                </tr>
              </thead>
              <tbody>
                {% for module in parsed_dump.modules %}
                <tr class="{%if module.missing_symbols %}missingsymbols{% endif %}">
                  <td>
                      {%if module.missing_symbols %}
                        <span class="row-notice" title="missing symbol">&Oslash;</span>
                      {% endif %}
                      {{ module.filename }}
                  </td>
                  <td>{{ module.version }}</td>
                  <td>{{ module.debug_id }}</td>
                  <td>{{ module.debug_file }}</td>
                </tr>
                {% endfor %}
              </tbody>
            </table>
            {% endif %}
          </div><!-- /modules -->

          <div id="rawdump" class="ui-tabs-hide">
            <div class="code">{{ raw_stackwalker_output }}</div>

	    {% if request.user.has_perm('crashstats.view_rawdump') %}
            <h3>Download the Raw Dump</h3>
              {% for url in raw_dump_urls %}
                <p><a href="{{ url }}">{{ url }}</a></p>
              {% endfor %}
	    {% else %}
	      <p>You need to be signed in to be able to download raw dumps.</p>
	    {% endif %}
          </div><!-- /rawdump -->

          <div id="extensions" class="ui-tabs-hide">
          {% if report.addons %}
            <table class="data-table">
              <thead>
                <tr>
                  <th scope="col">Extension</th>
                  <th scope="col">Extension Id</th>
                  <th scope="col">Version</th>
                  <th scope="col">Current?</th>
                </tr>
              </thead>
            <tbody>
            {% for addon in report.addons %}
              <tr>
                <td><a href=""></a></td>
                <td>{{ addon[0] }}</td>
                <td>{{ addon[1] }}</td>
                <td><strong>{{ addon[2] }}</strong></td>
              </tr>
            {% endfor %}
            </tbody>
            </table>
          {% else %}
            <p>No extensions were installed.</p>
          {% endif %}
          </div><!-- /extensions -->

          {% if total_correlations > 0 %}
          <div id="correlation" class="ui-tabs-hide"><h2>Correlations for {{ product }} {{ version }} {{ report.os_name }} </h2>
            <p>Below are tables of correlation data generated by <a href="http://dbaron.org/mozilla/topcrash-modules">dbaron's scripts</a>. If this crash signature is
      a top crasher, then we should be able to load it from <a href="http://crash-analysis.mozilla.com/crash_analysis/">the original text files</a>. Only the first 2MB of each Platform's output is loaded. If this screen has data from multiple product/version/platforms, the crashiest was picked ({{ product }} {{ version }} {{ report.os_name }}).</p>
            <ul>
              <li id="mod">
                <h3>Modules <a href="#modver" title="Skip Down to Module Versions">Next</a></h3>
                <div id="interesting-modules_correlation">Loading <img src="{{ static('img/loading.png') }}" width="16" height="17" alt="Loading..." /></div>
              </li>

              <li id="modver">
                <h3>Modules by versions <a href="#add" title="Skip Down to Add-ons">Next</a>
                <a href="#mod" title="Skip Up to Modules">Previous</a></h3>
                <div id="interesting-modules-with-versions-panel"><button name="interesting-modules-with-versions" class="load-version-data">Load</button></div>
              </li>

              <li id="add">
                <h3>Add-ons <a href="#addver" title="Skip Down to Add-on Versions">Next</a>
                <a href="#modver" title="Skip Up to Module Versions">Previous</a></h3>
                <div id="interesting-addons_correlation">Loading <img src="{{ static('img/loading.png') }}" width="16" height="17" alt="Loading..." /></div>
              </li>

              <li id="addver">
                <h3>Add-ons by versions <a href="#core-counts" title="Skip Down to CPU Cores">Next</a>
                <a href="#add" title="Skip Up to Add-ons">Previous</a></h3>
                <div id="interesting-addons-with-versions-panel"><button name="interesting-addons-with-versions" class="load-version-data">Load</button></div>
              </li>

              <li id="core-counts">
                <h3>CPU Cores <a href="#addver" title="Skip Up to Add-on Versions">Previous</a></h3>
                <div id="core-counts_correlation">Loading <img src="{{ static('img/loading.png') }}" width="16" height="17" alt="Loading..." /></div>
              </li>
            </ul>
        </div><!-- /correlation -->
        {% endif %}
      </div> <!-- /report-index -->
    </div>
  </div>
</div>
<script type="text/javascript">
var SocReport = {
    base: '{{ url('crashstats:correlations_json') }}',
    path: 'product={{ product }}&version={{ version }}&platform={{ report.os_name }}&signature={{ report.signature|urlencode }}',
    loading: 'Loading <img src="{{ static('img/loading.png') }}" width="16" height="17" alt="Loading..." />'
};
</script>
{% endblock %}
{% block site_js %}
  {{ super() }}

  {% compress js %}
  <script src="{{ static('crashstats/js/jquery/plugins/jquery-ui.js') }}"></script>
  <script src="{{ static('crashstats/js/jquery/plugins/jquery.tablesorter.js') }}"></script>
  {% endcompress %}

  {% compress js %}
  <script type="text/javascript" src="{{ static('crashstats/js/socorro/bugzilla.js') }}"></script>
  <script type="text/javascript" src="{{ static('crashstats/js/socorro/report.js') }}"></script>
  <script type="text/javascript" src="{{ static('crashstats/js/socorro/correlation.js') }}"></script>
  {% endcompress %}
{% endblock %}
