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> 

llvm-svn: 244716
This commit is contained in:
Jason Molenda 2015-08-12 03:27:33 +00:00
parent 993b2864da
commit 6acc86c3f5
6 changed files with 51 additions and 1 deletions

View File

@ -569,7 +569,7 @@ cputype: is a number that is the mach-o CPU type that is being debugged (base 10
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 represents the current OS version (10.8.2)
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"

View File

@ -1936,6 +1936,12 @@ DNBResolveExecutablePath (const char *path, char *resolved_path, size_t resolved
return false;
}
bool
DNBGetOSVersionNumbers (uint64_t *major, uint64_t *minor, uint64_t *patch)
{
return MachProcess::GetOSVersionNumbers (major, minor, patch);
}
void
DNBInitialize()

View File

@ -168,5 +168,6 @@ nub_bool_t DNBGetRegisterInfoByName (const char *reg_name, DNBRegist
//----------------------------------------------------------------------
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

View File

@ -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);

View File

@ -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_t idx)
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.

View File

@ -4628,6 +4628,21 @@ RNBRemote::HandlePacket_qHostInfo (const char *p)
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__)