<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Single stepping on branches, exception or interrupts. in Software Tuning, Performance Optimization &amp; Platform Monitoring</title>
    <link>https://community.intel.com/t5/Software-Tuning-Performance/Single-stepping-on-branches-exception-or-interrupts/m-p/811865#M866</link>
    <description>&lt;P&gt;I hope someone can help with the following questions or point me at a document that explains how this works. I hope I am just missing something obvious. I haveread at all the SDMs (Vols 3a and 3b) without getting insight.&lt;/P&gt;&lt;P&gt;If I set the TR flag in the rflags register and also set the BTF flags in the MSR_DEBUGCTL MSR, then the processor will generate a "single step" debug exception the next time it takes a branch, services an interrupt or generates an exception. I am assuming that I have set the processor to only do this at ring level 3.&lt;/P&gt;&lt;P&gt;1: When is the interrupt or exception delivered to the actual interrupt or exception handler? As the debug exception has a higher priority then the other exceptions or interrupt, the processor will vector to the #DB (interrupt 1) IDT entry. When does it vector to the other exception or interrupt IDT entry? On the next iret? Or does the code after handling the debug exception have to jump to the correct handler (see next question).&lt;/P&gt;&lt;P&gt;2: In the #DB handler is there anyway to tell the reason for entering the debug handler. In other words can the handler code tell that it was a branch, exception or interrupt that cause the entry into the #DB handler. Note that it is possible that both a branch and an interrupt or exception can occur at the same time.&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
    <pubDate>Sat, 11 Feb 2012 07:56:09 GMT</pubDate>
    <dc:creator>Stott__Graham</dc:creator>
    <dc:date>2012-02-11T07:56:09Z</dc:date>
    <item>
      <title>Single stepping on branches, exception or interrupts.</title>
      <link>https://community.intel.com/t5/Software-Tuning-Performance/Single-stepping-on-branches-exception-or-interrupts/m-p/811865#M866</link>
      <description>&lt;P&gt;I hope someone can help with the following questions or point me at a document that explains how this works. I hope I am just missing something obvious. I haveread at all the SDMs (Vols 3a and 3b) without getting insight.&lt;/P&gt;&lt;P&gt;If I set the TR flag in the rflags register and also set the BTF flags in the MSR_DEBUGCTL MSR, then the processor will generate a "single step" debug exception the next time it takes a branch, services an interrupt or generates an exception. I am assuming that I have set the processor to only do this at ring level 3.&lt;/P&gt;&lt;P&gt;1: When is the interrupt or exception delivered to the actual interrupt or exception handler? As the debug exception has a higher priority then the other exceptions or interrupt, the processor will vector to the #DB (interrupt 1) IDT entry. When does it vector to the other exception or interrupt IDT entry? On the next iret? Or does the code after handling the debug exception have to jump to the correct handler (see next question).&lt;/P&gt;&lt;P&gt;2: In the #DB handler is there anyway to tell the reason for entering the debug handler. In other words can the handler code tell that it was a branch, exception or interrupt that cause the entry into the #DB handler. Note that it is possible that both a branch and an interrupt or exception can occur at the same time.&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Sat, 11 Feb 2012 07:56:09 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Tuning-Performance/Single-stepping-on-branches-exception-or-interrupts/m-p/811865#M866</guid>
      <dc:creator>Stott__Graham</dc:creator>
      <dc:date>2012-02-11T07:56:09Z</dc:date>
    </item>
    <item>
      <title>Single stepping on branches, exception or interrupts.</title>
      <link>https://community.intel.com/t5/Software-Tuning-Performance/Single-stepping-on-branches-exception-or-interrupts/m-p/811866#M867</link>
      <description>&lt;DIV id="tiny_quote"&gt;&lt;DIV style="margin-left: 2px; margin-right: 2px;"&gt;Quoting &lt;A jquery1329091886218="55" rel="/en-us/services/profile/quick_profile.php?is_paid=&amp;amp;user_id=552819" href="https://community.intel.com/en-us/profile/552819/" class="basic"&gt;stott1&lt;/A&gt;&lt;/DIV&gt;&lt;DIV style="background-color: #e5e5e5; margin-left: 2px; margin-right: 2px; border: 1px inset; padding: 5px;"&gt;&lt;I&gt;...&lt;BR /&gt;2: In the #DB handler &lt;SPAN style="text-decoration: underline;"&gt;is there anyway to tell the reason for entering the debug handler&lt;/SPAN&gt;. In other words can the handler code tell that it was a branch, exception or interrupt that cause the entry into the #DB handler. Note that it is possible that both a branch and an interrupt or exception can occur at the same time.&lt;BR /&gt;Thanks&lt;BR /&gt;&lt;/I&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&lt;BR /&gt;Here a couple of places I would look at:&lt;BR /&gt;&lt;BR /&gt;- &lt;STRONG&gt;Microsoft Platform SDK&lt;/STRONG&gt; ( any version ). Look at '&lt;STRONG&gt;..\Samples\WinBase\Debug\&lt;/STRONG&gt;' folder with examples&lt;BR /&gt; related to Debugging on Windows platforms;&lt;BR /&gt;&lt;BR /&gt;- On &lt;STRONG&gt;MSDN&lt;/STRONG&gt; "&lt;STRONG&gt;Debugging and Error Handling&lt;/STRONG&gt;" topic;&lt;BR /&gt;&lt;BR /&gt;- &lt;STRONG&gt;Win32 API&lt;/STRONG&gt; structure '&lt;STRONG&gt;EXCEPTION_DEBUG_INFO&lt;/STRONG&gt;' has '&lt;STRONG&gt;EXCEPTION_RECORD&lt;/STRONG&gt;' member (structure )and&lt;BR /&gt; it is filled with information about an exception.&lt;BR /&gt;&lt;BR /&gt;Best regards,&lt;BR /&gt;Sergey&lt;/P&gt;</description>
      <pubDate>Mon, 13 Feb 2012 00:22:10 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Tuning-Performance/Single-stepping-on-branches-exception-or-interrupts/m-p/811866#M867</guid>
      <dc:creator>SergeyKostrov</dc:creator>
      <dc:date>2012-02-13T00:22:10Z</dc:date>
    </item>
    <item>
      <title>Single stepping on branches, exception or interrupts.</title>
      <link>https://community.intel.com/t5/Software-Tuning-Performance/Single-stepping-on-branches-exception-or-interrupts/m-p/811867#M868</link>
      <description>First 32 interrupts (00h-1Fh) are reserved for
  exceptions. Exceptions behave very similarly to interrupts - every
  exception forces interrupting the program execution and control is
  transfered from the currently-executing program to the routine
  handling the interrupting exception. These routines are part of OS
  kernel and they are called "exception handlers". During the control
  transfer to the exception handler, the CPU stops execution of the
  program and saves its return instruction pointer (&lt;CODE&gt;RIP&lt;/CODE&gt;), stack
  pointer (&lt;CODE&gt;RSP&lt;/CODE&gt;), flags register (&lt;CODE&gt;RFLAGS&lt;/CODE&gt;). The handler is responsible
  for saving the remaining state of the interrupted program
  (&lt;ABBR&gt;GPR&lt;/ABBR&gt;, &lt;ABBR&gt;XMM&lt;/ABBR&gt;, ). Saving registers allows the CPU to restart the interrupted
  program after the handler finishes exception handling.</description>
      <pubDate>Mon, 13 Feb 2012 10:38:04 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Tuning-Performance/Single-stepping-on-branches-exception-or-interrupts/m-p/811867#M868</guid>
      <dc:creator>gladiolus</dc:creator>
      <dc:date>2012-02-13T10:38:04Z</dc:date>
    </item>
    <item>
      <title>Single stepping on branches, exception or interrupts.</title>
      <link>https://community.intel.com/t5/Software-Tuning-Performance/Single-stepping-on-branches-exception-or-interrupts/m-p/811868#M869</link>
      <description>&lt;P&gt;Hello Stot1,&lt;BR /&gt;These questions are out of my range of knowledge. &lt;BR /&gt;I've sent them off to some other folks but I don't know if they will have theknowledge or timeto respond.&lt;BR /&gt;What are trying to accomplish? Perhaps there are others ways of reaching your goals.&lt;BR /&gt;Have you looked at how GDB does single-instruction mode?&lt;BR /&gt;I assumegdb must do this.&lt;BR /&gt;Pat&lt;/P&gt;</description>
      <pubDate>Mon, 13 Feb 2012 13:38:26 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Tuning-Performance/Single-stepping-on-branches-exception-or-interrupts/m-p/811868#M869</guid>
      <dc:creator>Patrick_F_Intel1</dc:creator>
      <dc:date>2012-02-13T13:38:26Z</dc:date>
    </item>
    <item>
      <title>Single stepping on branches, exception or interrupts.</title>
      <link>https://community.intel.com/t5/Software-Tuning-Performance/Single-stepping-on-branches-exception-or-interrupts/m-p/811869#M870</link>
      <description>First of all, thanks for all the replies.&lt;BR /&gt;&lt;BR /&gt;I think I have mostly worked out the answer to my first question. &lt;BR /&gt;&lt;BR /&gt;The description in the SDM on Single-stepping on Branches, Exception and Interrupts talks about exceptions when it fact they are going to be faults. Faults occur before the instruction is executed. So after the debug trap has occurred and the handler does a iret to go back to the code being "stepped", it goes back to the same instruction. In this case, the rflags that were loaded by the iret will have the RF bit on. This will cause the hardware to not generate the debug fault again but will take the actual exception (fault). Note that the description of the stepping facility does not discuss this at all. For interrupts, the interrupt is held pending until interrupts are un-masked.&lt;BR /&gt;&lt;BR /&gt;The SDM also has a typo in that it says "The debugger must reset the BTF and TF flags before resuming ...". In fact it should be ".. set the BTF and TF ... ".&lt;BR /&gt;&lt;BR /&gt;Hopefully I can aslo work out the ansered to my second question.&lt;BR /&gt;&lt;BR /&gt;Thanks again.&lt;BR /&gt;&lt;BR /&gt;Stott1</description>
      <pubDate>Tue, 14 Feb 2012 07:51:35 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Tuning-Performance/Single-stepping-on-branches-exception-or-interrupts/m-p/811869#M870</guid>
      <dc:creator>Stott__Graham</dc:creator>
      <dc:date>2012-02-14T07:51:35Z</dc:date>
    </item>
  </channel>
</rss>

