[Lldb-commits] [lldb] r216564 - NativeThreadLinux: remove translation of some Linux signals to gdb signals.

Todd Fiala tfiala at google.com
Thu Aug 28 07:23:12 PDT 2014


Hey Jim or Greg,

When I did the initial llgs work, I parroted what debugserver was doing
with regards to translating some signals into some GDB-compatibility
constants for SIGSEGV, SIGILL and SIGFPE.  (These translated from local
signal numbers to some fixed signal numbers in the 0x90-0x9f range).

Linux wasn't handling these translations back on the lldb side - i.e. the
UnixSignals that we use on Linux (LinuxSignals) were not translating these
into anything meaningful.

Since UnixSignals essentially handles both the remote and client side, and
since it is a non-goal for us to support llgs with gdb (i.e. gdb client <=>
llgs), I'm not aware of why I would need to do this translation on the
Linux side.

Am I missing anything?

The alternative to the fix I did above would be to add those non-standard
signal numbers (the 0x90-0x9f) to LinuxSignals and set them up correctly.
 I'm just thinking that is confusing if there isn't a good reason for it.
 I figure the debugserver code may have evolved from some mixed-software
backwards compatibility reasons, perhaps.

Thanks for any insight!  Ultimately I'm looking for validation or
refutation of the approach I took.

-Todd


On Wed, Aug 27, 2014 at 10:11 AM, Todd Fiala <todd.fiala at gmail.com> wrote:

> Author: tfiala
> Date: Wed Aug 27 12:11:56 2014
> New Revision: 216564
>
> URL: http://llvm.org/viewvc/llvm-project?rev=216564&view=rev
> Log:
> NativeThreadLinux: remove translation of some Linux signals to gdb signals.
>
> I copied this originally based on what debugserver was doing.  This
> appears to
> be incorrect and unncessary for Linux.  The LinuxSignals on the lldb side
> don't look for these and therefore they get handled incorrectly.
>
> Leaving the hook in place since I think darwin will continue to need to
> translate those signal numbers.
>
> Modified:
>     lldb/trunk/source/Plugins/Process/Linux/NativeThreadLinux.cpp
>
> Modified: lldb/trunk/source/Plugins/Process/Linux/NativeThreadLinux.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/NativeThreadLinux.cpp?rev=216564&r1=216563&r2=216564&view=diff
>
> ==============================================================================
> --- lldb/trunk/source/Plugins/Process/Linux/NativeThreadLinux.cpp
> (original)
> +++ lldb/trunk/source/Plugins/Process/Linux/NativeThreadLinux.cpp Wed Aug
> 27 12:11:56 2014
> @@ -96,7 +96,6 @@ NativeThreadLinux::GetStopReason (Thread
>      case eStateRunning:
>      case eStateStepping:
>      case eStateDetached:
> -    default:
>          if (log)
>          {
>              log->Printf ("NativeThreadLinux::%s tid %" PRIu64 " in state
> %s cannot answer stop reason",
> @@ -324,39 +323,28 @@ NativeThreadLinux::MaybeLogStateChange (
>      log->Printf ("NativeThreadLinux: thread (pid=%" PRIu64 ", tid=%"
> PRIu64 ") changing from state %s to %s", pid, GetID (), StateAsCString
> (old_state), StateAsCString (new_state));
>  }
>
> -static
> -uint32_t MaybeTranslateHostSignoToGdbSigno (uint32_t host_signo)
> -{
> -    switch (host_signo)
> -    {
> -        case SIGSEGV: return eGdbSignalBadAccess;
> -        case SIGILL:  return eGdbSignalBadInstruction;
> -        case SIGFPE:  return eGdbSignalArithmetic;
> -        // NOTE: debugserver sends SIGTRAP through unmodified.  Do the
> same here.
> -        // case SIGTRAP: return eGdbSignalBreakpoint;
> -
> -        // Nothing for eGdbSignalSoftware (0x95).
> -        // Nothing for eGdbSignalEmulation (0x94).
> -
> -        default:
> -            // No translations.
> -            return host_signo;
> -    }
> -}
> -
>  uint32_t
>  NativeThreadLinux::TranslateStopInfoToGdbSignal (const ThreadStopInfo
> &stop_info) const
>  {
>      switch (stop_info.reason)
>      {
>          case eStopReasonSignal:
> -            return MaybeTranslateHostSignoToGdbSigno
> (stop_info.details.signal.signo);
> -            break;
> +            // No translation.
> +            return stop_info.details.signal.signo;
>
>          case eStopReasonException:
> -            // FIXME verify how we handle exception type.
> -            return MaybeTranslateHostSignoToGdbSigno
> (static_cast<uint32_t> (stop_info.details.exception.type));
> -            break;
> +            {
> +                Log *log (GetLogIfAllCategoriesSet (LIBLLDB_LOG_THREAD));
> +                // FIXME I think the eStopReasonException is a xnu/Mach
> exception, which we
> +                // shouldn't see on Linux.
> +                // No translation.
> +                if (log)
> +                    log->Printf ("NativeThreadLinux::%s saw an exception
> stop type (signo %"
> +                                 PRIu64 "), not expecting to see
> exceptions on Linux",
> +                                 __FUNCTION__,
> +                                 stop_info.details.exception.type);
> +                return static_cast<uint32_t>
> (stop_info.details.exception.type);
> +            }
>
>          default:
>              assert (0 && "unexpected stop_info.reason found");
>
>
> _______________________________________________
> lldb-commits mailing list
> lldb-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits
>



-- 
Todd Fiala | Software Engineer | tfiala at google.com | 650-943-3180
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20140828/62659f98/attachment.html>


More information about the lldb-commits mailing list