1. 28 1月, 2020 1 次提交
  2. 22 1月, 2020 4 次提交
  3. 10 1月, 2020 3 次提交
    • A
      proc: fix inlined stack reading for midstack inlined calls · adb1746c
      aarzilli 提交于
      Due to a bug in the Go compiler midstack inlined calls do not report
      their ranges correctly. We can't check if an address is in the range of
      a DIE by simply looking at that DIE's range, we should also recursively
      check the DIE's children's ranges.
      
      Also fixes the way stacktraces of midstack inlined calls are reported
      (they used to be inverted, with the deepest inlined stack frame
      reported last).
      
      Fixes #1795
      adb1746c
    • A
      proc,service: return build informations for each package · a8606afb
      aarzilli 提交于
      Adds an API call that returns a list of packages contained in the
      program and the files that were used to build them, and also a best
      guess at which filesystem directory contained the package when it was
      built.
      
      This can be used by IDEs to map file paths if the debugging environment
      doesn't match the build environment exactly.
      a8606afb
    • A
      dwarf/line: make LineToPCIn behave like LineToPC for lines without stmt · 0e0d6892
      aarzilli 提交于
      When a line has instructions associated but none of them have is_stmt
      set LineToPC and LineToPCIn should behave in the same way.
      
      Fixes #1817
      0e0d6892
  4. 03 1月, 2020 1 次提交
    • A
      proc: build disassemblers unconditionally · 4a6b53c0
      aarzilli 提交于
      Remove build tags from disassembler code, move architecture specific
      functionality inside proc.Arch.
      This is necessary because Delve should be able to debug corefiles
      cross-platform.
      4a6b53c0
  5. 12 12月, 2019 1 次提交
  6. 28 11月, 2019 5 次提交
  7. 12 11月, 2019 1 次提交
    • A
      proc/linux: do not route signals to threads while stopping (#1752) · 4fc85289
      Alessandro Arzilli 提交于
      * proc/linux: do not route signals to threads while stopping
      
      While we are trying to stop the process we should not route signals
      sent to threads because that will result in threads being resumed.
      Also keep better track of which threads are stopped.
      
      This fixes an incompatibility with Go 1.14, which sends a lot of
      signals to its threads to implement non-cooperative preemption,
      resulting in Delve hanging waiting for an already-stopped thread to
      stop.
      
      In principle however this bug has nothing to do with Go 1.14 and could
      manifest in any instance of high signal pressure.
      
      * Makefile: discard stderr of "go list"
      
      In module mode "go" will print messages about downloading modules to
      stderr, we shouldn't confuse them for the real command output.
      4fc85289
  8. 02 11月, 2019 1 次提交
    • A
      proc,debugger: implement logical breakpoints (#1717) · 222deeec
      Alessandro Arzilli 提交于
      Modifies FindFileLocation, FindFunctionLocation and LineToPC as well as
      service/debugger to support inlining and introduces the concept of
      logical breakpoints.
      
      For inlined functions FindFileLocation, FindFunctionLocation and
      LineToPC will now return one PC address for each inlining and one PC
      for the concrete implementation of the function (if present).
      
      A proc.Breakpoint will continue to represent a physical breakpoint, at
      a single memory location.
      
      Breakpoints returned by service/debugger, however, will represent
      logical breakpoints and may be associated with multiple memory
      locations and, therefore, multiple proc.Breakpoints.
      
      The necessary logic is introduced in service/debugger so that a change
      to a logical breakpoint will be mirrored to all its physical
      breakpoints and physical breakpoints are aggregated into a single
      logical breakpoint when returned.
      222deeec
  9. 29 10月, 2019 2 次提交
    • A
      proc: always resolve array types even if they don't appear in the · 5a947bce
      aarzilli 提交于
      program
      
      When evaluating type casts always resolve array types.
      
      Instead of resolving them by looking up the string in debug_info
      construct a fake array type so that a type cast to an array type always
      works as long as the element type exists.
      
      We already did this for byte arrays, this commit extends this to any
      array type. The reason is that we return a fake array type (that
      doesn't exist in the target program) for the array of a channel type.
      
      Fixes #1736
      5a947bce
    • A
      proc: fix breakpoint confusion on resume (#1738) · f1a5e654
      Alessandro Arzilli 提交于
      Fixes a case of breakpoint confusion on resume caused by having two
      breakpoints one byte apart. This bug can cause the target program to
      resume execution a single byte inside an instruction and crash either
      with SIGILL or a SIGSEGV, or misbehave (depending on how the truncated
      instruction is decoded).
      
      native.(*Thread).StepInstruction should call FindBreakpoint using
      adjustPC==false because at that point the PC of the thread should
      already have been adjusted (and it has been).
      f1a5e654
  10. 22 10月, 2019 1 次提交
  11. 26 9月, 2019 1 次提交
  12. 14 8月, 2019 1 次提交
  13. 13 8月, 2019 1 次提交
    • A
      proc: next/step/stepout restarts thread from wrong instruction (#1657) · 3b0c8865
      Alessandro Arzilli 提交于
      proc.Next and proc.Step will call, after setting their temp
      breakpoints, curthread.SetCurrentBreakpoint. This is intended to find
      if one of the newly created breakpoints happens to be at the same
      instruction that curthread is stopped at.
      However SetCurrentBreakpoint is intended to be called after a Continue
      and StepInstruction operation so it will also detect if curthread is
      stopped one byte after a breakpoint.
      If the instruction immediately preceeding the current instruction of
      curthread happens to:
       1. have one of the newly created temp breakpoints
       2. be one byte long
      SetCurrentBreakpoint will believe that we just hit that breakpoint and
      therefore the instruction should be repeated, and thus rewind the PC of
      curthread by 1.
      
      We should distinguish between the two uses of SetCurrentBreakpoint and
      disable the check for "just hit" breakpoints when inappropriate.
      
      Fixes #1656
      3b0c8865
  14. 10 8月, 2019 1 次提交
  15. 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
  16. 30 7月, 2019 1 次提交
    • D
      *: Add .cirrus.yml for FreeBSD testing (#1639) · f4eaad69
      Derek Parker 提交于
      * *: Add .cirrus.yml for FreeBSD testing
      
      * *: run go mod tidy
      
      * service/test: prefer 127.0.0.1 over localhost
      
      * dwarf/line: fix TestDebugLinePrologueParser
      
      * vendor: rerun go mod vendor
      f4eaad69
  17. 17 7月, 2019 1 次提交
  18. 13 7月, 2019 1 次提交
    • R
      *: FreeBSD initial support (#1480) · df65be43
      Robert Ayrapetyan 提交于
      * FreeBSD initial support
      
      * first code review fixes
      
      * regs slice upd
      
      * execPtraceFunc wrap
      
      * disabled concurrency tests
      fixed kill() issue
      
      * disabled concurrency tests
      fixed kill() issue
      
      * cleanup vendor related code
      
      * cleanup ptrace calls
      
      * vendoring latest changes
      
      * Revert "vendoring latest changes"
      
      This reverts commit 833cb87b
      
      * vendoring latest changes
      
      * requested changes
      df65be43
  19. 09 7月, 2019 1 次提交
    • A
      godwarf: support recursive types involving C qualifiers and typedefs (#1603) · a8b8f30d
      Alessandro Arzilli 提交于
      Backports debug/dwarf commit: 535741a69a1300d1fe2800778b99c8a1b75d7fdd
      CL: https://go-review.googlesource.com/18459
      
      The x/debug/dwarf that we used for dwarf/godwarf/type.go was forked
      from debug/dwarf long before this commit.
      
      Original description:
      
          Currently readType simultaneously constructs a type graph and resolves
          the sizes of the types. However, these two operations are
          fundamentally at odds: the order we parse a cyclic structure in may be
          different than the order we need to resolve type sizes in. As a
          result, it's possible that when readType attempts to resolve the size
          of a typedef, it may dereference a nil Type field of another typedef
          retrieved from the type cache that's only partially constructed.
      
          To fix this, we delay resolving typedef sizes until the end of the
          readType recursion, when the full type graph is constructed.
      
      Fixes #1601
      a8b8f30d
  20. 01 7月, 2019 2 次提交
    • A
      proc: allow simultaneous call injection to multiple goroutines (#1591) · dd4fd5dc
      Alessandro Arzilli 提交于
      * proc: allow simultaneous call injection to multiple goroutines
      
      Changes the call injection code so that we can have multiple call
      injections going on at the same time as long as they happen on distinct
      goroutines.
      
      * proc: fix EvalExpressionWithCalls for constant expressions
      
      The lack of address of constant expressions would confuse EvalExpressionWithCalls
      
      Fixes #1577
      dd4fd5dc
    • A
      Go 1.13 support (#1546) · 55eed318
      Alessandro Arzilli 提交于
      * tests: fix tests for Go 1.13
      
      - Go 1.13 doesn't autogenerate init functions anymore, tests that
        expected that now fail and should be skipped.
      - Plugin tests now need -gcflags'all=-N -l' now, we were probably
        getting lucky with -gcflags='-N -l' before.
      
      * proc: allow signed integers as shift counts
      
      Go1.13 allows signed integers to be used as the right hand side of a
      shift operator, change eval to match.
      
      * goversion: update maximum supported version
      
      * travis: force Go to use vendor directory
      
      Travis scripts get confused by "go: downloading" lines, the exact
      reason is not clear. Testing that the vendor directory is up to date is
      a good idea anyway.
      55eed318
  21. 28 6月, 2019 1 次提交
  22. 26 6月, 2019 1 次提交
    • A
      proc,service: remove support for locspec '<fnname>:0' (#1588) · 7afda8db
      Alessandro Arzilli 提交于
      The location specified '<fnname>:0' could be used to set a breakpoint
      on the entry point of the function (as opposed to locspec '<fnname>'
      which sets it after the prologue).
      Setting a breakpoint on an entry point is almost never useful, the way
      this feature was implemented could cause it to be used accidentally and
      there are other ways to accomplish the same task (by setting a
      breakpoint on the PC address directly).
      7afda8db
  23. 04 6月, 2019 1 次提交
  24. 09 5月, 2019 2 次提交
    • A
      proc: allow function calls to appear inside an expression (#1503) · c30a333f
      Alessandro Arzilli 提交于
      The initial implementation of the 'call' command required the
      function call to be the root expression, i.e. something like:
      
      	double(3) + 1
      
      was not allowed, because the root expression was the binary operator
      '+', not the function call.
      
      With this change expressions like the one above and others are
      allowed.
      
      This is the first step necessary to implement nested function calls
      (where the result of a function call is used as argument to another
      function call).
      
      This is implemented by replacing proc.CallFunction with
      proc.EvalExpressionWithCalls. EvalExpressionWithCalls will run
      proc.(*EvalScope).EvalExpression in a different goroutine. This
      goroutine, the 'eval' goroutine, will communicate with the main
      goroutine of the debugger by means of two channels: continueRequest
      and continueCompleted.
      
      The eval goroutine evaluates the expression recursively, when
      a function call is encountered it takes care of setting up the
      function call on the target program and writes a request to the
      continueRequest channel, this causes the 'main' goroutine to restart
      the target program by calling proc.Continue.
      
      Whenever Continue encounters a breakpoint that belongs to the
      function call injection protocol (runtime.debugCallV1 and associated
      functions) it writes to continueCompleted which resumes the 'eval'
      goroutine.
      
      The 'eval' goroutine takes care of implementing the function call
      injection protocol.
      
      When the expression is fully evaluated the 'eval' goroutine will
      write a special message to 'continueRequest' signaling that the
      expression evaluation is terminated which will cause Continue to
      return to the user.
      
      Updates #119
      c30a333f
    • 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
  25. 03 5月, 2019 1 次提交
    • A
      proc/test: fix flakyness of TestCallConcurrent (#1543) · 71a7fe04
      Alessandro Arzilli 提交于
      Remove the breakpoint set in TestCallConcurrent so that it doesn't
      interfere with the call injection protocol.
      The fact that it can is a bug but that bug is better addressed after
      PRs #1503 and #1504 are merged, this keeps tests happy in the meantime.
      
      Fixes #1542
      71a7fe04
  26. 26 4月, 2019 1 次提交
    • A
      proc/native: fix target program crash caused by call injection (linux) (#1538) · 0b3c7d80
      Alessandro Arzilli 提交于
      RestoreRegisters on linux would also restore FS_BASE and GS_BASE, if
      the target goroutine migrated to a different thread during the call
      injection this would result in two threads of the target process
      pointing to the same TLS area which would greatly confuse the target
      runtime, leading to fatal panics with nonsensical stack traces.
      
      Other backends are unaffected:
      
      - native/windows doesn't store the TLS in the same CONTEXT struct as
        the other register values.
      - native/darwin doesn't support function calls (and wouldn't store the
        TLS value in the same struct)
      - gdbserial/rr doesn't support function calls (because it's a
        recording)
      - gsdbserial/lldb extracts the value of TLS by executing code in the
        target process.
      0b3c7d80
  27. 28 3月, 2019 2 次提交
    • A
      proc,debugger,terminal: read goroutine ancestors · 98265315
      aarzilli 提交于
      Add options to the stack command to read the goroutine ancestors.
      Ancestor tracking was added to Go 1.12 with CL:
      https://go-review.googlesource.com/c/go/+/70993/
      
      Implements #1491
      98265315
    • A
      Miscellaneous logging improvements (#1525) · 48f1f51e
      Alessandro Arzilli 提交于
      * *: use loglevel to control what gets logged instead of output redirection
      
      This stops logrus from doing all the formatting just to discard it
      immediately afterwards.
      
      * logflags: replace default formatter of logrus
      
      The default formatter of logrus emits logs in two different formats
      depending on whether or not the output is going to a terminal. The
      output format for non-terminals is indented to be machine readable, but
      we mostly read logs ourselves and the excessive quoting makes that
      format unreadable.
      When outputting to terminals it uses ANSI escape codes unconditionally,
      without checking whether the terminal it is connected to actually
      supports colors.
      
      This commit replaces the default formatter with a much simpler
      formatter that always uses a more readable format, doesn't use colors
      and places the key-value pairs at the beginning of the line (which is a
      better match for how we use them).
      
      * cmd/dlv: add command line options to redirect logs
      
      Adds two options, --log-to-file and --log-to-fd, to redirect logs to a
      file or to a file descriptor.
      
      When one of those two options is specified the "API server listening
      at:" message will also be redirected to the specified file/file
      descriptor.
      This allows clients that want to use the "API server listening at:"
      message to do so even if they want to redirect the target's stdout to
      another file or device.
      
      Implements #1179, #1523
      48f1f51e