Author: jmolenda Date: Tue Aug 11 22:27:33 2015 New Revision: 244716 URL: http://llvm.org/viewvc/llvm-project?rev=244716&view=rev Log: Have debugserver send the OS version string plus major, minor, and patchlevel in the qHostInfo reply. Document that qHostInfo may report major/minor/patch separately / in addition to the version: combination.
<rdar://problem/22125465> Modified: lldb/trunk/docs/lldb-gdb-remote.txt lldb/trunk/tools/debugserver/source/DNB.cpp lldb/trunk/tools/debugserver/source/DNB.h lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.h lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.mm lldb/trunk/tools/debugserver/source/RNBRemote.cpp Modified: lldb/trunk/docs/lldb-gdb-remote.txt URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/docs/lldb-gdb-remote.txt?rev=244716&r1=244715&r2=244716&view=diff ============================================================================== --- lldb/trunk/docs/lldb-gdb-remote.txt (original) +++ lldb/trunk/docs/lldb-gdb-remote.txt Tue Aug 11 22:27:33 2015 @@ -569,7 +569,7 @@ cputype: is a number that is the mach-o cpusubtype: is a number that is the mach-o CPU subtype type that is being debugged (base 10) triple: a string for the target triple (x86_64-apple-macosx) that can be used to specify arch + vendor + os in one entry vendor: a string for the vendor (apple), not needed if "triple" is specified -ostype: a string for the OS being debugged (darwin, linux, freebsd), not needed if "triple" is specified +ostype: a string for the OS being debugged (macosx, linux, freebsd, ios, watchos), not needed if "triple" is specified endian: is one of "little", "big", or "pdp" ptrsize: an unsigned number that represents how big pointers are in bytes on the debug target hostname: the hostname of the host that is running the GDB server if available @@ -579,6 +579,9 @@ os_version: a version string that repres watchpoint_exceptions_received: one of "before" or "after" to specify if a watchpoint is triggered before or after the pc when it stops default_packet_timeout: an unsigned number that specifies the default timeout in seconds distribution_id: optional. For linux, specifies distribution id (e.g. ubuntu, fedora, etc.) +osmajor: optional, specifies the major version number of the OS (e.g. for Mac OS X 10.11.2, it would be 10) +osminor: optional, specifies the minor version number of the OS (e.g. for Mac OS X 10.11.2, it would be 11) +ospatch: optional, specifies the patch level number of the OS (e.g. for Mac OS X 10.11.2, it would be 2) //---------------------------------------------------------------------- // "qGDBServerVersion" Modified: lldb/trunk/tools/debugserver/source/DNB.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/DNB.cpp?rev=244716&r1=244715&r2=244716&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/source/DNB.cpp (original) +++ lldb/trunk/tools/debugserver/source/DNB.cpp Tue Aug 11 22:27:33 2015 @@ -1936,6 +1936,12 @@ DNBResolveExecutablePath (const char *pa return false; } +bool +DNBGetOSVersionNumbers (uint64_t *major, uint64_t *minor, uint64_t *patch) +{ + return MachProcess::GetOSVersionNumbers (major, minor, patch); +} + void DNBInitialize() Modified: lldb/trunk/tools/debugserver/source/DNB.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/DNB.h?rev=244716&r1=244715&r2=244716&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/source/DNB.h (original) +++ lldb/trunk/tools/debugserver/source/DNB.h Tue Aug 11 22:27:33 2015 @@ -168,5 +168,6 @@ nub_bool_t DNBGetRegisterInfoByName //---------------------------------------------------------------------- const char * DNBStateAsString (nub_state_t state); nub_bool_t DNBResolveExecutablePath (const char *path, char *resolved_path, size_t resolved_path_size); +bool DNBGetOSVersionNumbers (uint64_t *major, uint64_t *minor, uint64_t *patch); #endif Modified: lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.h?rev=244716&r1=244715&r2=244716&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.h (original) +++ lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.h Tue Aug 11 22:27:33 2015 @@ -80,6 +80,7 @@ public: static const void * PrepareForAttach (const char *path, nub_launch_flavor_t launch_flavor, bool waitfor, DNBError &err_str); static void CleanupAfterAttach (const void *attach_token, bool success, DNBError &err_str); static nub_process_t CheckForProcess (const void *attach_token); + static bool GetOSVersionNumbers (uint64_t *major, uint64_t *minor, uint64_t *patch); #ifdef WITH_BKS pid_t BKSLaunchForDebug (const char *app_bundle_path, char const *argv[], char const *envp[], bool no_stdio, bool disable_aslr, const char *event_data, DNBError &launch_err); pid_t BKSForkChildForPTraceDebugging (const char *path, char const *argv[], char const *envp[], bool no_stdio, bool disable_aslr, const char *event_data, DNBError &launch_err); Modified: lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.mm URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.mm?rev=244716&r1=244715&r2=244716&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.mm (original) +++ lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.mm Tue Aug 11 22:27:33 2015 @@ -31,6 +31,8 @@ #include <algorithm> #include <map> +#import <Foundation/Foundation.h> + #include "DNBDataRef.h" #include "DNBLog.h" #include "DNBThreadResumeActions.h" @@ -2020,6 +2022,28 @@ MachProcess::GetGenealogyImageInfo (size return m_activities.GetProcessExecutableInfosAtIndex (idx); } +bool +MachProcess::GetOSVersionNumbers (uint64_t *major, uint64_t *minor, uint64_t *patch) +{ + bool success = false; + + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + + NSOperatingSystemVersion vers = [[NSProcessInfo processInfo] operatingSystemVersion]; + if (major) + *major = vers.majorVersion; + if (minor) + *minor = vers.minorVersion; + if (patch) + *patch = vers.patchVersion; + + success = true; + + [pool drain]; + + return success; +} + // Do the process specific setup for attach. If this returns NULL, then there's no // platform specific stuff to be done to wait for the attach. If you get non-null, // pass that token to the CheckForProcess method, and then to CleanupAfterAttach. Modified: lldb/trunk/tools/debugserver/source/RNBRemote.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/RNBRemote.cpp?rev=244716&r1=244715&r2=244716&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/source/RNBRemote.cpp (original) +++ lldb/trunk/tools/debugserver/source/RNBRemote.cpp Tue Aug 11 22:27:33 2015 @@ -4628,6 +4628,21 @@ RNBRemote::HandlePacket_qHostInfo (const strm << "vendor:apple;"; + uint64_t major, minor, patch; + if (DNBGetOSVersionNumbers (&major, &minor, &patch)) + { + strm << "osmajor:" << major << ";"; + strm << "osminor:" << minor << ";"; + strm << "ospatch:" << patch << ";"; + + strm << "version:" << major << "." << minor; + if (patch != 0) + { + strm << "." << patch; + } + strm << ";"; + } + #if defined (__LITTLE_ENDIAN__) strm << "endian:little;"; #elif defined (__BIG_ENDIAN__) _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits