1. 18 2月, 2020 1 次提交
    • A
      proc: optimize parseG (#1866) · ecea2e18
      Alessandro Arzilli 提交于
      runtime.g is a large and growing struct, we only need a few fields.
      Instead of using loadValue to load the full contents of g, cache its
      memory and then only load the fields we care about.
      
      Benchmark before:
      
      BenchmarkConditionalBreakpoints-4              1        14586710018 ns/op
      
      Benchmark after:
      
      BenchmarkConditionalBreakpoints-4   	       1	12476166303 ns/op
      
      Conditional breakpoint evaluation: 1.45ms -> 1.24ms
      
      Updates #1549
      ecea2e18
  2. 14 2月, 2020 1 次提交
    • A
      proc: do not load g0 until it's needed when stacktracing (#1863) · 5b4f4a81
      Alessandro Arzilli 提交于
      The stacktrace code occasionally needs the value of g.m.g0.sched.sp to
      switch stacks. Since this is only needed rarely and calling parseG is
      relatively expensive we should delay doing it until we know it will be
      needed.
      
      Benchmark before:
      
      BenchmarkConditionalBreakpoints-4              1        17326345671 ns/op
      
      Benchmark after:
      
      BenchmarkConditionalBreakpoints-4   	       1	15649407130 ns/op
      
      Reduces conditional breakpoint latency from 1.7ms to 1.56ms.
      
      Updates #1549
      5b4f4a81
  3. 22 1月, 2020 1 次提交
  4. 26 9月, 2019 1 次提交
  5. 10 8月, 2019 2 次提交
  6. 02 8月, 2019 1 次提交
    • A
      cmd/dlv: actually disable C compiler optimizations when building (#1647) · c9c455cc
      Alessandro Arzilli 提交于
      * proc: fix stacktraces when a SIGSEGV happens during a cgo call
      
      When a SIGSEGV happens in a cgo call (for example as a result of
      dereferencing a NULL pointer) the stack layout will look like this:
      
      (system stack) runtime.fatalthrow
      (system stack) runtime.throw
      (system stack) runtime.sigpanic
      (system stack) offending C function
      ... other C functions...
      (system stack) runtime.asmcgocall
      (goroutine stack) call inside cgo
      
      The code in switchStack would switch directly from the
      runtime.fatalthrow frame to the first frame in the goroutine stack,
      hiding important information.
      
      Disable this switch for runtime.fatalthrow and reintroduce the check
      for runtime.mstart that existed before this version of the code was
      implemented in commit 7bec20.
      
      This problem was reported in comment:
      https://github.com/go-delve/delve/issues/935#issuecomment-512182533
      
      * cmd/dlv: actually disable C compiler optimizations when building
      c9c455cc
  7. 09 5月, 2019 1 次提交
    • A
      proc: support debugging plugins (#1414) · f3b149bd
      Alessandro Arzilli 提交于
      This change splits the BinaryInfo object into a slice of Image objects
      containing information about the base executable and each loaded shared
      library (note: go plugins are shared libraries).
      
      Delve backens are supposed to call BinaryInfo.AddImage whenever they
      detect that a new shared library has been loaded.
      
      Member fields of BinaryInfo that are used to speed up access to dwarf
      (Functions, packageVars, consts, etc...) remain part of BinaryInfo and
      are updated to reference the correct image object. This simplifies this
      change.
      
      This approach has a few shortcomings:
      
      1. Multiple shared libraries can define functions or globals with the
         same name and we have no way to disambiguate between them.
      
      2. We don't have a way to handle library unloading.
      
      Both of those affect C shared libraries much more than they affect go
      plugins. Go plugins can't be unloaded at all and a lot of name
      collisions are prevented by import paths.
      
      There's only one problem that is concerning: if two plugins both import
      the same package they will end up with multiple definition for the same
      function.
      For example if two plugins use fmt.Printf the final in-memory image
      (and therefore our BinaryInfo object) will end up with two copies of
      fmt.Printf at different memory addresses. If a user types
        break fmt.Printf
      a breakpoint should be created at *both* locations.
      Allowing this is a relatively complex change that should be done in a
      different PR than this.
      
      For this reason I consider this approach an acceptable and sustainable
      stopgap.
      
      Updates #865
      f3b149bd
  8. 19 3月, 2019 1 次提交
  9. 05 1月, 2019 1 次提交
    • D
      *: Update import name to github.com/go-delve/delve · 4c9a72e4
      Derek Parker 提交于
      The repository is being switched from the personal account
      github.com/derekparker/delve to the organization account
      github.com/go-delve/delve. This patch updates imports and docs, while
      preserving things which should not be changed such as my name in the
      CHANGELOG and in TODO comments.
      4c9a72e4
  10. 10 11月, 2018 1 次提交
    • A
      proc: Improve performance of loadMap on very large sparse maps · 89c8da65
      aarzilli 提交于
      Users can create sparse maps in two ways, either by:
      a) adding lots of entries to a map and then deleting most of them, or
      b) using the make(mapType, N) expression with a very large N
      
      When this happens reading the resulting map will be very slow
      because loadMap needs to scan many buckets for each entry it finds.
      
      Technically this is not a bug, the user just created a map that's
      very sparse and therefore very slow to read. However it's very
      annoying to have the debugger hang for several seconds when trying
      to read the local variables just because one of them (which you
      might not even be interested into) happens to be a very sparse map.
      
      There is an easy mitigation to this problem: not reading any
      additional buckets once we know that we have already read all
      entries of the map, or as many entries as we need to fulfill the
      MaxArrayValues parameter.
      
      Unfortunately this is mostly useless, a VLSM (Very Large Sparse Map)
      with a single entry will still be slow to access, because the single
      entry in the map could easily end up in the last bucket.
      
      The obvious solution to this problem is to set a limit to the
      number of buckets we read when loading a map. However there is no
      good way to set this limit.
      If we hardcode it there will be no way to print maps that are beyond
      whatever limit we pick.
      We could let users (or clients) specify it but the meaning of such
      knob would be arcane and they would have no way of picking a good
      value (because there is no objectively good value for it).
      
      The solution used in this commit is to set an arbirtray limit on
      the number of buckets we read but only when loadMap is invoked
      through API calls ListLocalVars and ListFunctionArgs. In this way
      `ListLocalVars` and `ListFunctionArgs` (which are often invoked
      automatically by GUI clients) remain fast even in presence of a
      VLSM, but the contents of the VLSM can still be inspected using
      `EvalVariable`.
      89c8da65
  11. 16 10月, 2018 1 次提交
  12. 12 10月, 2018 1 次提交
    • A
      proc: support position independent executables (PIE) · 74c98bc9
      aarzilli 提交于
      Support for position independent executables (PIE) on the native linux
      backend, the gdbserver backend on linux and the core backend.
      Also implemented in the windows native backend, but it can't be tested
      because go doesn't support PIE on windows yet.
      74c98bc9
  13. 20 9月, 2018 1 次提交
  14. 31 8月, 2018 1 次提交
    • A
      proc,service,terminal: information about stack trace truncation · ac74944d
      aarzilli 提交于
      Add a flag to Stackframe that indicates where the stack frame is the
      bottom-most frame of the stack. This allows clients to know whether the
      stack trace terminated normally or if it was truncated because the
      maximum depth was reached.
      Add a truncation message to the 'stack' command.
      ac74944d
  15. 25 7月, 2018 1 次提交
    • A
      proc,service,terminal: read defer list · 8f1fc63d
      aarzilli 提交于
      Adds -defer flag to the stack command that decorates the stack traces
      by associating each stack frame with its deferred calls.
      
      Reworks proc.next to use this feature instead of using proc.DeferPC,
      laying the groundwork to implement #1240.
      8f1fc63d
  16. 12 6月, 2018 1 次提交
  17. 27 3月, 2018 1 次提交
    • A
      proc: support inlining · 290e8e75
      aarzilli 提交于
      Go 1.10 added inlined calls to debug_info, this commit adds support
      for DW_TAG_inlined_call to delve, both for stack traces (where
      inlined calls will appear as normal stack frames) and to correct
      the behavior of next, step and stepout.
      
      The calls to Next and Frame of stackIterator continue to work
      unchanged and only return real stack frames, after reading each line
      appendInlinedCalls is called to unpacked all the inlined calls that
      involve the current PC.
      
      The fake stack frames produced by appendInlinedCalls are
      distinguished from real stack frames by having the Inlined attribute
      set to true. Also their Current and Call locations are treated
      differently. The Call location will be changed to represent the
      position inside the inlined call, while the Current location will
      always reference the real stack frame. This is done because:
      
      * next, step and stepout need to access the debug_info entry of
      the real function they are stepping through
      * we are already manipulating Call in different ways while Current
      is just what we read from the call stack
      
      The strategy remains mostly the same, we disassemble the function
      and we set a breakpoint on each instruction corresponding to a
      different file:line. The function in question will be the one
      corresponding to the first real (i.e. non-inlined) stack frame.
      
      * If the current function contains inlined calls, 'next' will not
      set any breakpoints on instructions that belong to inlined calls. We
      do not do this for 'step'.
      
      * If we are inside an inlined call that makes other inlined
      functions, 'next' will not set any breakpoints that belong to
      inlined calls that are children of the current inlined call.
      
      * If the current function is inlined the breakpoint on the return
      address won't be set, because inlined frames don't have a return
      address.
      
      * The code we use for stepout doesn't work at all if we are inside
      an inlined call, instead we call 'next' but instruct it to remove
      all PCs belonging to the current inlined call.
      290e8e75
  18. 20 3月, 2018 1 次提交
  19. 27 1月, 2018 1 次提交
  20. 06 1月, 2018 1 次提交
    • A
      proc: avoid scanning system stack if it's not executing cgo · 7bec20e5
      aarzilli 提交于
      The runtime calls into g0 in many places, not necessarily using
      runtime.systemstack or runtime.asmcgocall.
      One example of this is the call to runtime.newstack inside
      runtime.morestack.
      
      If we stop the process while one goroutine is executing
      runtime.newstack we would be unable to fully scan its stack because we
      don't know that we have to switch back to the goroutine stack after
      runtime.newstack.
      
      Instead of tracking down every possible way that the runtime switches
      to g0 we switch to the goroutine stack immediately after the top of the
      stack, unless cgo is being executed on the systemstack.
      
      Fixes #1066
      7bec20e5
  21. 21 12月, 2017 1 次提交
  22. 14 12月, 2017 1 次提交
  23. 29 11月, 2017 1 次提交
    • A
      proc: support cgo stacktraces · 5372588c
      aarzilli 提交于
      When creating a stack trace we should switch between the goroutine
      stack and the system stack (where cgo code is executed) as appropriate
      to reconstruct the logical stacktrace.
      
      Goroutines that are currently executing on the system stack will have
      the SystemStack flag set, frames of the goroutine stack will have a
      negative FrameOffset (like always) and frames of the system stack will
      have a positive FrameOffset (which is actually just the CFA value for
      the frame).
      
      Updates #935
      5372588c
  24. 22 11月, 2017 1 次提交
  25. 18 11月, 2017 2 次提交
    • A
      pkg/proc: remove callFrameRegs from stackIterator · 8d34bb5b
      aarzilli 提交于
      Since it's just a scratchpad to calculate the new set of registers it
      makes more sense to have it as a local variable in Next and
      advanceRegs.
      8d34bb5b
    • A
      proc: refactor stack.go to use DWARF registers · f4e2000f
      aarzilli 提交于
      Instead of only tracking a few cherrypicked registers in stack.go track
      all DWARF registers.
      
      This is needed for cgo code and for the locationlists emitted by go in
      1.10:
      * The debug_frame sections emitted by C compilers can not be used
        without tracking all registers
      * the loclists emitted by go1.10 need all registers of a frame to be
        interpreted.
      f4e2000f
  26. 04 11月, 2017 1 次提交
  27. 29 7月, 2017 1 次提交
  28. 27 7月, 2017 1 次提交
  29. 17 5月, 2017 1 次提交
    • A
      proc: next, stepout should work on recursive goroutines (#831) · 35405583
      Alessandro Arzilli 提交于
      Before this commit our temp breakpoints only checked that we would stay
      on the same goroutine.
      However this isn't enough for recursive functions we must check that we
      stay on the same goroutine AND on the same stack frame (or, in the case
      of the StepOut breakpoint, the previous stack frame).
      
      This commit:
      1. adds a new synthetic variable runtime.frameoff that returns the
         offset of the current frame from the base of the call stack.
         This is similar to runtime.curg
      2. Changes the condition used for breakpoints on the lines of the
         current function to check that runtime.frameoff hasn't changed.
      3. Changes the condition used for breakpoints on the return address to
         check that runtime.frameoff corresponds to the previous frame in the
         stack.
      4. All other temporary breakpoints (the step-into breakpoints and defer
         breakpoints) remain unchanged.
      
      Fixes #828
      35405583
  30. 22 4月, 2017 2 次提交
    • A
      proc: refactoring: merge target into proc · b6fe5aeb
      aarzilli 提交于
      - moved target.Interface into proc as proc.Process
      - rename proc.IThread to proc.Thread
      - replaced interfaces DisassembleInfo, Continuable and
        EvalScopeConvertible with Process.
      - removed superfluous Gdbserver prefix from types in the gdbserial
        backend.
      - removed superfluous Core prefix from types in the core backend.
      b6fe5aeb
    • A
      proc: refactoring: split backends to separate packages · 15bac719
      aarzilli 提交于
      - move native backend to pkg/proc/native
      - move gdbserver backend to pkg/proc/gdbserial
      - move core dumps backend to pkg/proc/core
      15bac719
  31. 19 4月, 2017 1 次提交
  32. 14 4月, 2017 1 次提交
  33. 07 4月, 2017 1 次提交
    • A
      proc refactor: split out BinaryInfo implementation (#745) · 436a3c21
      Alessandro Arzilli 提交于
      * proc: refactor BinaryInfo part of proc.Process to own type
      
      The data structures and associated code used by proc.Process
      to implement target.BinaryInfo will also be useful to support a
      backend for examining core dumps, split this part of proc.Process
      to a different type.
      
      * proc: compile support for all executable formats unconditionally
      
      So far we only compiled in support for loading the executable format
      supported by the host operating system.
      Once support for core files is introduced it is however useful to
      support loading in all executable formats, there is no reason why it
      shouldn't be possible to examine a linux coredump on windows, or
      viceversa.
      
      * proc: bugfix: do not resume threads on detach if killing
      
      * Replace BinaryInfo interface with BinInfo() method returning proc.BinaryInfo
      436a3c21
  34. 14 3月, 2017 1 次提交
    • D
      pkg/proc: tolerate absence of stack barriers in Go 1.9 (#762) · bd48358d
      dr2chase 提交于
      Stack barriers were removed in Go 1.9, and thus code that
      expected various stack-barrier-related symbols to exist
      does not find them.  Check for their absence and do not
      crash when they are missing.  Disable stack-barrier-handling
      test for 1.9 and beyond.
      
      Fixes #754.
      bd48358d
  35. 23 2月, 2017 1 次提交
    • A
      proc/stack: use BP when FDE is not available · 92faa95b
      aarzilli 提交于
      On Windows we can sometimes encounter threads stopped in locations for
      which we do not have entries in debug_frame.
      These cases seem to be due to calls to Windows API in the go runtime,
      we can still produce a (partial) stack trace in this circumstance by
      following frame pointers (starting with BP).
      We still prefer debug_frame entries when available since go functions
      do not have frame pointers before go1.8.
      92faa95b
  36. 17 2月, 2017 1 次提交
    • A
      proc: use original PC for Call position (#736) · dd3cc63d
      Alessandro Arzilli 提交于
      The PC we have is relative to the first instruction after the CALL
      instruction currently being executed.
      
      Anyone watching a disassembly will understand what's happening if we
      report the return PC, but reporting the first PC of the current line is
      useless and confusing.
      dd3cc63d
  37. 09 2月, 2017 1 次提交