7

Xcode/lldb のデバッグ中に実行ポイントを設定する方法はありますか? より具体的には、ブレークポイントにヒットした後、実行ポイントを手動で別のコード行に移動しますか?

4

4 に答える 4

14

メソッドで上下に移動する場合は、緑色の矢印をクリックして特定のポイントにドラッグできます。したがって、ブレークポイントの前の行をバックアップしたい場合。生成された緑色の矢印をクリックして上にドラッグします。実行をヒットすると、ブレークポイントに再びヒットします

于 2013-07-11T16:07:55.127 に答える
5

Xcode 6 では、以下を使用できますj lineNumber。以下のドキュメントを参照してください。

(lldb) help j
     Sets the program counter to a new address.  This command takes 'raw' input
     (no need to quote stuff).

Syntax: _regexp-jump [<line>]
_regexp-jump [<+-lineoffset>]
_regexp-jump [<file>:<line>]
_regexp-jump [*<addr>]


'j' is an abbreviation for '_regexp-jump'
于 2014-10-22T01:59:34.237 に答える
2

lldb の素晴らしい点の 1 つは、少しの Python スクリプトで簡単に拡張できることです。たとえば、私はjump問題なく新しいコマンドをまとめました。

import lldb

def jump(debugger, command, result, dict):
  """Usage: jump LINE-NUMBER
Jump to a specific source line of the current frame.
Finds the first code address for a given source line, sets the pc to that value.  
Jumping across any allocation/deallocation boundaries (may not be obvious with ARC!), or with optimized code, quickly leads to undefined/crashy behavior. """

  if lldb.frame and len(command) >= 1:
    line_num = int(command)
    context = lldb.frame.GetSymbolContext (lldb.eSymbolContextEverything)
    if context and context.GetCompileUnit():
      compile_unit = context.GetCompileUnit()
      line_index = compile_unit.FindLineEntryIndex (0, line_num, compile_unit.GetFileSpec(), False)
      target_line = compile_unit.GetLineEntryAtIndex (line_index)
      if target_line and target_line.GetStartAddress().IsValid():
        addr = target_line.GetStartAddress().GetLoadAddress (lldb.target)
        if addr != lldb.LLDB_INVALID_ADDRESS:
          if lldb.frame.SetPC (addr):
            print "PC has been set to 0x%x for %s:%d" % (addr, target_line.GetFileSpec().GetFilename(), target_line.GetLine())

def __lldb_init_module (debugger, dict):
  debugger.HandleCommand('command script add -f %s.jump jump' % __name__)

これを、lldb の Python コマンドを保持するディレクトリに配置し、ファイル~/lldb/にロードします。~/.lldbinit

command script import ~/lldb/jump.py

そして今、特定の行番号にジャンプするコマンドjump(動作)があります。j例えば

(lldb) j 5
PC has been set to 0x100000f0f for a.c:5
(lldb)

この新しいjumpコマンドは、ファイルにロードすると、コマンドライン lldb と Xcode の両方で使用でき~/.lldbinitます。エディター ウィンドウでインジケーターを移動する代わりに、Xcode のデバッガー コンソール ペインを使用して PC を移動する必要があります。

于 2013-07-14T21:44:39.680 に答える
0

lldb コマンドを使用して、lldb 内のプログラム カウンター (pc) を移動できますregister write pc。しかし、それは指示に基づいています。

ここには、lldb の概要として役立つ優れた lldb/gdb の比較があります。

于 2013-07-11T21:27:43.830 に答える