From gclayton at apple.com Mon Mar 21 13:35:40 2011 From: gclayton at apple.com (Greg Clayton) Date: Mon, 21 Mar 2011 18:35:40 -0000 Subject: [Lldb-commits] [lldb] r128006 - /lldb/trunk/lldb.xcodeproj/project.pbxproj Message-ID: <20110321183540.BAF6A2A6C12D@llvm.org> Author: gclayton Date: Mon Mar 21 13:35:40 2011 New Revision: 128006 URL: http://llvm.org/viewvc/llvm-project?rev=128006&view=rev Log: Fixed a warning with gcc 4.2 when the Xcode project falls back to the system compiler when clang isn't around to do the compiling. Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=128006&r1=128005&r2=128006&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Mon Mar 21 13:35:40 2011 @@ -3293,6 +3293,7 @@ COPY_PHASE_STRIP = NO; EXECUTABLE_EXTENSION = a; GCC_ENABLE_OBJC_GC = supported; + GCC_INLINES_ARE_PRIVATE_EXTERN = NO; GCC_PREPROCESSOR_DEFINITIONS = ( __STDC_CONSTANT_MACROS, __STDC_LIMIT_MACROS, @@ -3322,6 +3323,7 @@ DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; EXECUTABLE_EXTENSION = a; GCC_ENABLE_OBJC_GC = supported; + GCC_INLINES_ARE_PRIVATE_EXTERN = NO; GCC_PREPROCESSOR_DEFINITIONS = ( __STDC_CONSTANT_MACROS, __STDC_LIMIT_MACROS, @@ -3351,6 +3353,7 @@ DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; EXECUTABLE_EXTENSION = a; GCC_ENABLE_OBJC_GC = supported; + GCC_INLINES_ARE_PRIVATE_EXTERN = NO; GCC_PREPROCESSOR_DEFINITIONS = ( __STDC_CONSTANT_MACROS, __STDC_LIMIT_MACROS, @@ -3605,6 +3608,7 @@ 2689FFD713353D7A00698AC0 /* BuildAndIntegration */, ); defaultConfigurationIsVisible = 0; + defaultConfigurationName = BuildAndIntegration; }; 26F5C26E10F3D9C5009D5894 /* Build configuration list for PBXNativeTarget "lldb-tool" */ = { isa = XCConfigurationList; From gclayton at apple.com Mon Mar 21 13:46:11 2011 From: gclayton at apple.com (Greg Clayton) Date: Mon, 21 Mar 2011 18:46:11 -0000 Subject: [Lldb-commits] [lldb] r128012 - /lldb/trunk/lldb.xcodeproj/project.pbxproj Message-ID: <20110321184611.8E5AD2A6C12C@llvm.org> Author: gclayton Date: Mon Mar 21 13:46:11 2011 New Revision: 128012 URL: http://llvm.org/viewvc/llvm-project?rev=128012&view=rev Log: Move the building of llvm/clang and the swig wrappers into the lldb-core target. Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=128012&r1=128011&r2=128012&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Mon Mar 21 13:46:11 2011 @@ -2516,8 +2516,6 @@ isa = PBXNativeTarget; buildConfigurationList = 2668020B115FD0EE008E1FE4 /* Build configuration list for PBXNativeTarget "LLDB" */; buildPhases = ( - 26D5B06111B07468009A862E /* Build llvm and clang */, - 26D5B06311B074CF009A862E /* Build swig wrapper classes */, 26680202115FD0ED008E1FE4 /* Headers */, 26680203115FD0ED008E1FE4 /* Resources */, 26680204115FD0ED008E1FE4 /* Sources */, @@ -2541,6 +2539,8 @@ isa = PBXNativeTarget; buildConfigurationList = 2689FFD813353D7A00698AC0 /* Build configuration list for PBXNativeTarget "lldb-core" */; buildPhases = ( + 261EECA21337D399001D193C /* Build llvm and clang */, + 261EECA41337D4BB001D193C /* Build swig wrapper classes */, 2689FFC613353D7A00698AC0 /* Sources */, 2689FFC713353D7A00698AC0 /* Frameworks */, 2689FFC813353D7A00698AC0 /* Headers */, @@ -2639,7 +2639,7 @@ shellPath = /bin/sh; shellScript = "cd \"${TARGET_BUILD_DIR}/${PUBLIC_HEADERS_FOLDER_PATH}\"\nfor file in *.h\ndo\n\t/usr/bin/sed -i '' 's/\\(#include\\)[ ]*\"lldb\\/\\(API\\/\\)\\{0,1\\}\\(.*\\)\"/\\1 /1' \"$file\"\n\t/usr/bin/sed -i '' 's| Author: gclayton Date: Mon Mar 21 16:25:07 2011 New Revision: 128023 URL: http://llvm.org/viewvc/llvm-project?rev=128023&view=rev Log: Added real user/group id, effective user/group id, and parent process ID to the ProcessInfo. Modified: lldb/trunk/include/lldb/Target/Process.h lldb/trunk/source/Host/common/Host.cpp lldb/trunk/source/Host/macosx/Host.mm Modified: lldb/trunk/include/lldb/Target/Process.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Process.h?rev=128023&r1=128022&r2=128023&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/Process.h (original) +++ lldb/trunk/include/lldb/Target/Process.h Mon Mar 21 16:25:07 2011 @@ -228,6 +228,10 @@ public: ProcessInfo () : m_name (), + m_real_uid (UINT32_MAX), + m_real_gid (UINT32_MAX), + m_effective_uid (UINT32_MAX), + m_effective_gid (UINT32_MAX), m_arch(), m_pid (LLDB_INVALID_PROCESS_ID) { @@ -236,7 +240,11 @@ ProcessInfo (const char *name, const ArchSpec &arch, lldb::pid_t pid) : - m_name (name), + m_name (), + m_real_uid (UINT32_MAX), + m_real_gid (UINT32_MAX), + m_effective_uid (UINT32_MAX), + m_effective_gid (UINT32_MAX), m_arch (arch), m_pid (pid) { @@ -246,6 +254,10 @@ Clear () { m_name.clear(); + m_real_uid = UINT32_MAX; + m_real_gid = UINT32_MAX; + m_effective_uid = UINT32_MAX; + m_effective_gid = UINT32_MAX; m_arch.Clear(); m_pid = LLDB_INVALID_PROCESS_ID; } @@ -265,12 +277,60 @@ void SetName (const char *name) { - if (name) + if (name && name[0]) m_name.assign (name); else m_name.clear(); } + uint32_t + GetRealUserID() const + { + return m_real_uid; + } + + uint32_t + GetRealGroupID() const + { + return m_real_gid; + } + + uint32_t + GetEffectiveUserID() const + { + return m_effective_uid; + } + + uint32_t + GetEffectiveGroupID() const + { + return m_effective_gid; + } + + void + SetRealUserID (uint32_t uid) + { + m_real_uid = uid; + } + + void + SetRealGroupID (uint32_t gid) + { + m_real_gid = gid; + } + + void + SetEffectiveUserID (uint32_t uid) + { + m_effective_uid = uid; + } + + void + SetEffectiveGroupID (uint32_t gid) + { + m_effective_gid = gid; + } + ArchSpec & GetArchitecture () { @@ -295,10 +355,39 @@ m_pid = pid; } + bool + ProcessIDIsValid() const + { + return m_pid != LLDB_INVALID_PROCESS_ID; + } + + lldb::pid_t + GetParentProcessID () const + { + return m_parent_pid; + } + + void + SetParentProcessID (lldb::pid_t pid) + { + m_parent_pid = pid; + } + + bool + ParentProcessIDIsValid() const + { + return m_parent_pid != LLDB_INVALID_PROCESS_ID; + } + protected: std::string m_name; + uint32_t m_real_uid; + uint32_t m_real_gid; + uint32_t m_effective_uid; + uint32_t m_effective_gid; ArchSpec m_arch; - pid_t m_pid; + lldb::pid_t m_pid; + lldb::pid_t m_parent_pid; }; class ProcessInfoList Modified: lldb/trunk/source/Host/common/Host.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/Host.cpp?rev=128023&r1=128022&r2=128023&view=diff ============================================================================== --- lldb/trunk/source/Host/common/Host.cpp (original) +++ lldb/trunk/source/Host/common/Host.cpp Mon Mar 21 16:25:07 2011 @@ -1029,130 +1029,22 @@ return false; } -#if defined (__APPLE__) - -static bool -GetMacOSXProcessName (lldb::pid_t pid, - NameMatchType name_match_type, - const char *name_match, - ProcessInfo &proc_info) -{ - char process_name[MAXCOMLEN * 2 + 1]; - int name_len = ::proc_name(pid, process_name, MAXCOMLEN * 2); - if (name_len == 0) - return false; - - if (NameMatches(process_name, name_match_type, name_match)) - { - proc_info.SetName (process_name); - return true; - } - else - { - proc_info.SetName (NULL); - return false; - } -} - - -static bool -GetMacOSXProcessCPUType (lldb::pid_t pid, ProcessInfo &proc_info) -{ - // Make a new mib to stay thread safe - int mib[CTL_MAXNAME]={0,}; - size_t mib_len = CTL_MAXNAME; - if (::sysctlnametomib("sysctl.proc_cputype", mib, &mib_len)) - return false; - - mib[mib_len] = pid; - mib_len++; - - cpu_type_t cpu, sub; - size_t cpu_len = sizeof(cpu); - if (::sysctl (mib, mib_len, &cpu, &cpu_len, 0, 0) == 0) - { - switch (cpu) - { - case llvm::MachO::CPUTypeI386: sub = llvm::MachO::CPUSubType_I386_ALL; break; - case llvm::MachO::CPUTypeX86_64: sub = llvm::MachO::CPUSubType_X86_64_ALL; break; - default: break; - } - proc_info.GetArchitecture ().SetArchitecture (lldb::eArchTypeMachO, cpu, sub); - return true; - } - return false; -} - -#endif +#if !defined (__APPLE__) // see macosx/Host.mm uint32_t Host::FindProcessesByName (const char *name, NameMatchType name_match_type, ProcessInfoList &process_infos) { process_infos.Clear(); -#if defined (__APPLE__) - int num_pids; - int size_of_pids; - std::vector pid_list; - - size_of_pids = proc_listpids(PROC_ALL_PIDS, 0, NULL, 0); - if (size_of_pids == -1) - return 0; - - num_pids = size_of_pids/sizeof(int); - - pid_list.resize (size_of_pids); - size_of_pids = proc_listpids(PROC_ALL_PIDS, 0, &pid_list[0], size_of_pids); - if (size_of_pids == -1) - return 0; - - lldb::pid_t our_pid = getpid(); - - for (int i = 0; i < num_pids; i++) - { - struct proc_bsdinfo bsd_info; - int error = proc_pidinfo (pid_list[i], PROC_PIDTBSDINFO, (uint64_t) 0, &bsd_info, PROC_PIDTBSDINFO_SIZE); - if (error == 0) - continue; - - // Don't offer to attach to zombie processes, already traced or exiting - // processes, and of course, ourselves... It looks like passing the second arg of - // 0 to proc_listpids will exclude zombies anyway, but that's not documented so... - if (((bsd_info.pbi_flags & (PROC_FLAG_TRACED | PROC_FLAG_INEXIT)) != 0) - || (bsd_info.pbi_status == SZOMB) - || (bsd_info.pbi_pid == our_pid)) - continue; - - ProcessInfo process_info; - if (GetMacOSXProcessName (bsd_info.pbi_pid, name_match_type, name, process_info)) - { - process_info.SetProcessID (bsd_info.pbi_pid); - GetMacOSXProcessCPUType (bsd_info.pbi_pid, process_info); - process_infos.Append (process_info); - } - } -#endif - return process_infos.GetSize(); } bool Host::GetProcessInfo (lldb::pid_t pid, ProcessInfo &process_info) { -#if defined (__APPLE__) - - if (GetMacOSXProcessName (pid, eNameMatchIgnore, NULL, process_info)) - { - process_info.SetProcessID (pid); - if (GetMacOSXProcessCPUType (pid, process_info) == false) - process_info.GetArchitecture().Clear(); - return true; - } -#endif process_info.Clear(); return false; } -#if !defined (__APPLE__) // see macosx/Host.mm bool Host::OpenFileInExternalEditor (const FileSpec &file_spec, uint32_t line_no) { Modified: lldb/trunk/source/Host/macosx/Host.mm URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/macosx/Host.mm?rev=128023&r1=128022&r2=128023&view=diff ============================================================================== --- lldb/trunk/source/Host/macosx/Host.mm (original) +++ lldb/trunk/source/Host/macosx/Host.mm Mon Mar 21 16:25:07 2011 @@ -11,10 +11,13 @@ #include #include +#include #include +#include #include #include #include +#include #include #include @@ -25,6 +28,7 @@ #include "lldb/Core/Log.h" #include "lldb/Core/StreamFile.h" #include "lldb/Core/StreamString.h" +#include "lldb/Target/Process.h" #include "cfcpp/CFCBundle.h" #include "cfcpp/CFCMutableArray.h" @@ -32,6 +36,9 @@ #include "cfcpp/CFCReleaser.h" #include "cfcpp/CFCString.h" +#include "llvm/Support/Host.h" +#include "llvm/Support/MachO.h" + #include #include @@ -874,4 +881,208 @@ } +static bool +GetMacOSXProcessName (NameMatchType name_match_type, + const char *name_match, + ProcessInfo &process_info) +{ + if (process_info.ProcessIDIsValid()) + { + char process_name[MAXCOMLEN * 2 + 1]; + int name_len = ::proc_name(process_info.GetProcessID(), process_name, MAXCOMLEN * 2); + if (name_len == 0) + return false; + + if (NameMatches(process_name, name_match_type, name_match)) + { + process_info.SetName (process_name); + return true; + } + } + process_info.SetName (NULL); + return false; +} + + +static bool +GetMacOSXProcessCPUType (ProcessInfo &process_info) +{ + if (process_info.ProcessIDIsValid()) + { + // Make a new mib to stay thread safe + int mib[CTL_MAXNAME]={0,}; + size_t mib_len = CTL_MAXNAME; + if (::sysctlnametomib("sysctl.proc_cputype", mib, &mib_len)) + return false; + + mib[mib_len] = process_info.GetProcessID(); + mib_len++; + + cpu_type_t cpu, sub; + size_t cpu_len = sizeof(cpu); + if (::sysctl (mib, mib_len, &cpu, &cpu_len, 0, 0) == 0) + { + switch (cpu) + { + case llvm::MachO::CPUTypeI386: sub = llvm::MachO::CPUSubType_I386_ALL; break; + case llvm::MachO::CPUTypeX86_64: sub = llvm::MachO::CPUSubType_X86_64_ALL; break; + default: break; + } + process_info.GetArchitecture ().SetArchitecture (lldb::eArchTypeMachO, cpu, sub); + return true; + } + } + process_info.GetArchitecture().Clear(); + return false; +} + +// TODO: move this into the platform +static bool +GetGroupName (uint32_t gid, std::string &group_name) +{ + char group_buffer[PATH_MAX]; + size_t group_buffer_size = sizeof(group_buffer); + struct group group_info; + struct group *group_info_ptr = &group_info; + // User the real user ID here, not the effective user ID + if (::getgrgid_r (gid, + &group_info, + group_buffer, + group_buffer_size, + &group_info_ptr) == 0) + { + if (group_info_ptr) + { + group_name.assign (group_info_ptr->gr_name); + return true; + } + } + group_name.clear(); + return false; +} + +// TODO: move this into the platform +static bool +GetUserName (uint32_t uid, std::string &user_name) +{ + struct passwd user_info; + struct passwd *user_info_ptr = &user_info; + char user_buffer[PATH_MAX]; + size_t user_buffer_size = sizeof(user_buffer); + if (::getpwuid_r (uid, + &user_info, + user_buffer, + user_buffer_size, + &user_info_ptr) == 0) + { + if (user_info_ptr) + { + user_name.assign (user_info_ptr->pw_name); + return true; + } + } + user_name.clear(); + return false; +} + + +static bool +GetMacOSXProcessUserAndGroup (ProcessInfo &process_info) +{ + if (process_info.ProcessIDIsValid()) + { + int mib[4]; + mib[0] = CTL_KERN; + mib[1] = KERN_PROC; + mib[2] = KERN_PROC_PID; + mib[3] = process_info.GetProcessID(); + struct kinfo_proc proc_kinfo; + size_t proc_kinfo_size = sizeof(struct kinfo_proc); + + if (::sysctl (mib, 4, &proc_kinfo, &proc_kinfo_size, NULL, 0) == 0) + { + if (proc_kinfo_size > 0) + { + process_info.SetParentProcessID (proc_kinfo.kp_eproc.e_ppid); + process_info.SetRealUserID (proc_kinfo.kp_eproc.e_pcred.p_ruid); + process_info.SetRealGroupID (proc_kinfo.kp_eproc.e_pcred.p_rgid); + process_info.SetEffectiveUserID (proc_kinfo.kp_eproc.e_ucred.cr_uid); + if (proc_kinfo.kp_eproc.e_ucred.cr_ngroups > 0) + process_info.SetEffectiveGroupID (proc_kinfo.kp_eproc.e_ucred.cr_groups[0]); + else + process_info.SetEffectiveGroupID (UINT32_MAX); + return true; + } + } + } + process_info.SetParentProcessID (LLDB_INVALID_PROCESS_ID); + process_info.SetRealUserID (UINT32_MAX); + process_info.SetRealGroupID (UINT32_MAX); + process_info.SetEffectiveUserID (UINT32_MAX); + process_info.SetEffectiveGroupID (UINT32_MAX); + return false; +} + + +uint32_t +Host::FindProcessesByName (const char *name, NameMatchType name_match_type, ProcessInfoList &process_infos) +{ + int num_pids; + int size_of_pids; + std::vector pid_list; + + size_of_pids = proc_listpids(PROC_ALL_PIDS, 0, NULL, 0); + if (size_of_pids == -1) + return 0; + + num_pids = size_of_pids/sizeof(int); + + pid_list.resize (size_of_pids); + size_of_pids = proc_listpids(PROC_ALL_PIDS, 0, &pid_list[0], size_of_pids); + if (size_of_pids == -1) + return 0; + + lldb::pid_t our_pid = getpid(); + + for (int i = 0; i < num_pids; i++) + { + struct proc_bsdinfo bsd_info; + int error = proc_pidinfo (pid_list[i], PROC_PIDTBSDINFO, (uint64_t) 0, &bsd_info, PROC_PIDTBSDINFO_SIZE); + if (error == 0) + continue; + + // Don't offer to attach to zombie processes, already traced or exiting + // processes, and of course, ourselves... It looks like passing the second arg of + // 0 to proc_listpids will exclude zombies anyway, but that's not documented so... + if (((bsd_info.pbi_flags & (PROC_FLAG_TRACED | PROC_FLAG_INEXIT)) != 0) + || (bsd_info.pbi_status == SZOMB) + || (bsd_info.pbi_pid == our_pid)) + continue; + + ProcessInfo process_info; + process_info.SetProcessID (bsd_info.pbi_pid); + if (GetMacOSXProcessName (name_match_type, name, process_info)) + { + GetMacOSXProcessCPUType (process_info); + GetMacOSXProcessUserAndGroup (process_info); + process_infos.Append (process_info); + } + } + return process_infos.GetSize(); +} + +bool +Host::GetProcessInfo (lldb::pid_t pid, ProcessInfo &process_info) +{ + process_info.SetProcessID(pid); + if (GetMacOSXProcessName (eNameMatchIgnore, NULL, process_info)) + { + GetMacOSXProcessCPUType (process_info); + GetMacOSXProcessUserAndGroup (process_info); + return true; + } + process_info.Clear(); + return false; +} + From wilsons at start.ca Mon Mar 21 16:45:00 2011 From: wilsons at start.ca (Stephen Wilson) Date: Mon, 21 Mar 2011 17:45:00 -0400 Subject: [Lldb-commits] [lldb] r128023 - in /lldb/trunk: include/lldb/Target/Process.h source/Host/common/Host.cpp source/Host/macosx/Host.mm In-Reply-To: <20110321212507.F109F2A6C12C@llvm.org> References: <20110321212507.F109F2A6C12C@llvm.org> Message-ID: <20110321214500.GA16951@fibrous.localdomain> On Mon, Mar 21, 2011 at 09:25:07PM -0000, Greg Clayton wrote: > Author: gclayton > Date: Mon Mar 21 16:25:07 2011 > New Revision: 128023 > > URL: http://llvm.org/viewvc/llvm-project?rev=128023&view=rev > Log: > Added real user/group id, effective user/group id, and parent > process ID to the ProcessInfo. > > > Modified: > lldb/trunk/include/lldb/Target/Process.h > lldb/trunk/source/Host/common/Host.cpp > lldb/trunk/source/Host/macosx/Host.mm Hi Greg, I was just looking at some of this Host stuff too. I need to add some more linux specific code (GetOSVersion) and it does not make sense to put that under common/. I can start moving some of the other linux specific code out of the way too. Any objections to creating a Host/linux subdirectory? -- steve From johnny.chen at apple.com Mon Mar 21 18:01:34 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Mon, 21 Mar 2011 23:01:34 -0000 Subject: [Lldb-commits] [lldb] r128034 - /lldb/trunk/utils/test/llvm-mc-shell.py Message-ID: <20110321230134.52C462A6C12C@llvm.org> Author: johnny Date: Mon Mar 21 18:01:34 2011 New Revision: 128034 URL: http://llvm.org/viewvc/llvm-project?rev=128034&view=rev Log: Fix a typo in the message string. Modified: lldb/trunk/utils/test/llvm-mc-shell.py Modified: lldb/trunk/utils/test/llvm-mc-shell.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/utils/test/llvm-mc-shell.py?rev=128034&r1=128033&r2=128034&view=diff ============================================================================== --- lldb/trunk/utils/test/llvm-mc-shell.py (original) +++ lldb/trunk/utils/test/llvm-mc-shell.py Mon Mar 21 18:01:34 2011 @@ -29,7 +29,7 @@ def llvm_mc_loop(mc, mc_options): contents = [] fname = 'mc-input.txt' - sys.stdout.write("Enter your input to llvm-mc. A line starting with 'END' terminates the cuurent batch of input.\n") + sys.stdout.write("Enter your input to llvm-mc. A line starting with 'END' terminates the current batch of input.\n") sys.stdout.write("Enter 'quit' or Ctrl-D to quit the program.\n") while True: sys.stdout.write("> ") From johnny.chen at apple.com Mon Mar 21 18:44:44 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Mon, 21 Mar 2011 23:44:44 -0000 Subject: [Lldb-commits] [lldb] r128040 - in /lldb/trunk/utils/test: README-disasm disasm.py Message-ID: <20110321234444.BB7592A6C12C@llvm.org> Author: johnny Date: Mon Mar 21 18:44:44 2011 New Revision: 128040 URL: http://llvm.org/viewvc/llvm-project?rev=128040&view=rev Log: Add options to allow for specifying an option string when spawning gdb and for executing command(s) right after starting up gdb. Update the README file to show an example of using these to pass '-arch armv7' to gdb and to execute gdb command to set shared library path substitutions before loading iOS4.3 sdk's /usr/lib/libSystem.B.dylib and disassembling the 'printf' function. Modified: lldb/trunk/utils/test/README-disasm lldb/trunk/utils/test/disasm.py Modified: lldb/trunk/utils/test/README-disasm URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/utils/test/README-disasm?rev=128040&r1=128039&r2=128040&view=diff ============================================================================== --- lldb/trunk/utils/test/README-disasm (original) +++ lldb/trunk/utils/test/README-disasm Mon Mar 21 18:44:44 2011 @@ -9,521 +9,398 @@ See the following for a sample session using this command: -da0603a-dhcp191:9131529 johnny$ /Volumes/data/lldb/svn/trunk/utils/test/disasm.py -m /Volumes/data/lldb/llvm/Debug+Asserts/bin/llvm-mc -e MessageComposer.app/MessageComposer -f main --options='-triple=arm-apple-darwin -debug-only=arm-disassembler' -executable: MessageComposer.app/MessageComposer -function: main +[16:26:57] johnny:/Volumes/data/Radar/9131529 $ /Volumes/data/lldb/svn/trunk/utils/test/disasm.py -C 'set shlib-path-substitutions /usr /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk/usr /System /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk/System /Library /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk/Library' -O '-arch armv7' -m /Volumes/data/lldb/llvm/Debug+Asserts/bin/llvm-mc -e /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk/usr/lib/libSystem.B.dylib -f printf --options='-triple=thumb-apple-darwin -debug-only=arm-disassembler' +gdb commands: ['set shlib-path-substitutions /usr /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk/usr /System /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk/System /Library /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk/Library'] +gdb options: -arch armv7 +executable: /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk/usr/lib/libSystem.B.dylib +function: printf llvm-mc: /Volumes/data/lldb/llvm/Debug+Asserts/bin/llvm-mc -llvm-mc options: -triple=arm-apple-darwin -debug-only=arm-disassembler +llvm-mc options: -triple=thumb-apple-darwin -debug-only=arm-disassembler GNU gdb 6.3.50-20050815 (Apple version gdb-1518) (Sat Feb 12 02:56:02 UTC 2011) Copyright 2004 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions. There is absolutely no warranty for GDB. Type "show warranty" for details. -This GDB was configured as "--host=x86_64-apple-darwin --target=arm-apple-darwin"... -warning: Unable to read symbols from "dyld" (prefix __dyld_) (not yet mapped into memory). - -warning: Unable to read symbols from "Foundation" (not yet mapped into memory). - -warning: Unable to read symbols for /System/Library/Frameworks/UIKit.framework/UIKit (file not found). - -warning: Unable to read symbols from "UIKit" (not yet mapped into memory). - -warning: Unable to read symbols for /System/Library/Frameworks/CoreGraphics.framework/CoreGraphics (file not found). - -warning: Unable to read symbols from "CoreGraphics" (not yet mapped into memory). - -warning: Unable to read symbols from "MessageUI" (not yet mapped into memory). - -warning: Unable to read symbols from "libSystem.B.dylib" (not yet mapped into memory). - -warning: Unable to read symbols from "libobjc.A.dylib" (not yet mapped into memory). - -warning: Unable to read symbols from "CoreFoundation" (not yet mapped into memory). - -warning: Could not find object file "/Volumes/Data/HD2/Data/work/tests/iphone-tests/MessageComposer/build/MessageComposer.build/Debug-iphoneos/MessageComposer.build/Objects-normal/armv6/main.o" - no debug information available for "/Volumes/Data/HD2/Data/work/tests/iphone-tests/MessageComposer/main.m". - - -warning: Could not find object file "/Volumes/Data/HD2/Data/work/tests/iphone-tests/MessageComposer/build/MessageComposer.build/Debug-iphoneos/MessageComposer.build/Objects-normal/armv6/MessageComposerAppDelegate.o" - no debug information available for "/Volumes/Data/HD2/Data/work/tests/iphone-tests/MessageComposer/Classes/MessageComposerAppDelegate.m". - - -warning: Could not find object file "/Volumes/Data/HD2/Data/work/tests/iphone-tests/MessageComposer/build/MessageComposer.build/Debug-iphoneos/MessageComposer.build/Objects-normal/armv6/MessageComposerViewController.o" - no debug information available for "/Volumes/Data/HD2/Data/work/tests/iphone-tests/MessageComposer/Classes/MessageComposerViewController.m". - - -(gdb) disassemble main -Dump of assembler code for function main: -0x00002180 : push {r7, lr} -0x00002184 : add r7, sp, #0 ; 0x0 -0x00002188 : sub sp, sp, #16 ; 0x10 -0x0000218c : str r0, [sp, #4] -0x00002190 : str r1, [sp] -0x00002194 : ldr r3, [pc, #144] ; 0x222c -0x00002198 : add r3, pc, r3 -0x0000219c : ldr r3, [r3] -0x000021a0 : mov r2, r3 -0x000021a4 : ldr r3, [pc, #132] ; 0x2230 -0x000021a8 : add r3, pc, r3 -0x000021ac : ldr r3, [r3] -0x000021b0 : mov r0, r2 -0x000021b4 : mov r1, r3 -0x000021b8 : bl 0x3ff4 -0x000021bc : mov r3, r0 -0x000021c0 : mov r2, r3 -0x000021c4 : ldr r3, [pc, #104] ; 0x2234 -0x000021c8 : add r3, pc, r3 -0x000021cc : ldr r3, [r3] -0x000021d0 : mov r0, r2 -0x000021d4 : mov r1, r3 -0x000021d8 : bl 0x3ff4 -0x000021dc : mov r3, r0 -0x000021e0 : str r3, [sp, #8] -0x000021e4 : ldr r0, [sp, #4] -0x000021e8 : ldr r1, [sp] -0x000021ec : mov r2, #0 ; 0x0 -0x000021f0 : mov r3, #0 ; 0x0 -0x000021f4 : bl 0x3fec -0x000021f8 : mov r3, r0 -0x000021fc : str r3, [sp, #12] -0x00002200 : ldr r2, [sp, #8] -0x00002204 : ldr r3, [pc, #44] ; 0x2238 -0x00002208 : add r3, pc, r3 -0x0000220c : ldr r3, [r3] -0x00002210 : mov r0, r2 -0x00002214 : mov r1, r3 -0x00002218 : bl 0x3ff4 -0x0000221c : ldr r3, [sp, #12] -0x00002220 : mov r0, r3 -0x00002224 : sub sp, r7, #0 ; 0x0 -0x00002228 : pop {r7, pc} -0x0000222c : strdeq r2, [r0], -r8 -0x00002230 : andeq r2, r0, r12, ror r4 -0x00002234 : andeq r2, r0, r8, asr r4 -0x00002238 : andeq r2, r0, r4, lsl r4 +This GDB was configured as "--host=x86_64-apple-darwin --target=arm-apple-darwin". +: push {r0, r1, r2, r3} +0x0704cdd2 : push {r4, r5, r7, lr} +0x0704cdd4 : add r7, sp, #8 +0x0704cdd6 : sub sp, #4 +0x0704cdd8 : add r3, sp, #20 +0x0704cdda : ldr.w r5, [r3], #4 +0x0704cdde : str r3, [sp, #0] +0x0704cde0 : ldr r3, [pc, #52] (0x704ce18 ) +0x0704cde2 : add r3, pc +0x0704cde4 : ldr r0, [r3, #0] +0x0704cde6 : ldr r4, [r0, #0] +0x0704cde8 : ldr r0, [pc, #48] (0x704ce1c ) +0x0704cdea : add r0, pc +0x0704cdec : ldr r0, [r0, #0] +0x0704cdee : ldr r0, [r0, #0] +0x0704cdf0 : blx 0x707ba30 +0x0704cdf4 : cbnz r0, 0x704cdfe +0x0704cdf6 : ldr r1, [pc, #40] (0x704ce20 ) +0x0704cdf8 : add r1, pc +0x0704cdfa : ldr r1, [r1, #0] +0x0704cdfc : b.n 0x704ce00 +0x0704cdfe : mov r1, r0 +0x0704ce00 : mov r0, r4 +0x0704ce02 : mov r2, r5 +0x0704ce04 : ldr r3, [sp, #0] +0x0704ce06 : bl 0x704ad44 +0x0704ce0a : sub.w sp, r7, #8 ; 0x8 +0x0704ce0e : ldmia.w sp!, {r4, r5, r7, lr} +0x0704ce12 : add sp, #16 +0x0704ce14 : bx lr +0x0704ce16 : nop +0x0704ce18 : movs r3, #142 +0x0704ce1a : lsls r5, r0, #0 +0x0704ce1c : adds r1, #122 +0x0704ce1e : lsls r5, r0, #0 +0x0704ce20 : adds r1, #104 +0x0704ce22 : lsls r5, r0, #0 End of assembler dump. -(gdb) x /4b 0x00002180 -0x2180
: 0x80 0x40 0x2d 0xe9 -(gdb) x /4b 0x00002184 -0x2184 : 0x00 0x70 0x8d 0xe2 -(gdb) x /4b 0x00002188 -0x2188 : 0x10 0xd0 0x4d 0xe2 -(gdb) x /4b 0x0000218c -0x218c : 0x04 0x00 0x8d 0xe5 -(gdb) x /4b 0x00002190 -0x2190 : 0x00 0x10 0x8d 0xe5 -(gdb) x /4b 0x00002194 -0x2194 : 0x90 0x30 0x9f 0xe5 -(gdb) x /4b 0x00002198 -0x2198 : 0x03 0x30 0x8f 0xe0 -(gdb) x /4b 0x0000219c -0x219c : 0x00 0x30 0x93 0xe5 -(gdb) x /4b 0x000021a0 -0x21a0 : 0x03 0x20 0xa0 0xe1 -(gdb) x /4b 0x000021a4 -0x21a4 : 0x84 0x30 0x9f 0xe5 -(gdb) x /4b 0x000021a8 -0x21a8 : 0x03 0x30 0x8f 0xe0 -(gdb) x /4b 0x000021ac -0x21ac : 0x00 0x30 0x93 0xe5 -(gdb) x /4b 0x000021b0 -0x21b0 : 0x02 0x00 0xa0 0xe1 -(gdb) x /4b 0x000021b4 -0x21b4 : 0x03 0x10 0xa0 0xe1 -(gdb) x /4b 0x000021b8 -0x21b8 : 0x8d 0x07 0x00 0xeb -(gdb) x /4b 0x000021bc -0x21bc : 0x00 0x30 0xa0 0xe1 -(gdb) x /4b 0x000021c0 -0x21c0 : 0x03 0x20 0xa0 0xe1 -(gdb) x /4b 0x000021c4 -0x21c4 : 0x68 0x30 0x9f 0xe5 -(gdb) x /4b 0x000021c8 -0x21c8 : 0x03 0x30 0x8f 0xe0 -(gdb) x /4b 0x000021cc -0x21cc : 0x00 0x30 0x93 0xe5 -(gdb) x /4b 0x000021d0 -0x21d0 : 0x02 0x00 0xa0 0xe1 -(gdb) x /4b 0x000021d4 -0x21d4 : 0x03 0x10 0xa0 0xe1 -(gdb) x /4b 0x000021d8 -0x21d8 : 0x85 0x07 0x00 0xeb -(gdb) x /4b 0x000021dc -0x21dc : 0x00 0x30 0xa0 0xe1 -(gdb) x /4b 0x000021e0 -0x21e0 : 0x08 0x30 0x8d 0xe5 -(gdb) x /4b 0x000021e4 -0x21e4 : 0x04 0x00 0x9d 0xe5 -(gdb) x /4b 0x000021e8 -0x21e8 : 0x00 0x10 0x9d 0xe5 -(gdb) x /4b 0x000021ec -0x21ec : 0x00 0x20 0xa0 0xe3 -(gdb) x /4b 0x000021f0 -0x21f0 : 0x00 0x30 0xa0 0xe3 -(gdb) x /4b 0x000021f4 -0x21f4 : 0x7c 0x07 0x00 0xeb -(gdb) x /4b 0x000021f8 -0x21f8 : 0x00 0x30 0xa0 0xe1 -(gdb) x /4b 0x000021fc -0x21fc : 0x0c 0x30 0x8d 0xe5 -(gdb) x /4b 0x00002200 -0x2200 : 0x08 0x20 0x9d 0xe5 -(gdb) x /4b 0x00002204 -0x2204 : 0x2c 0x30 0x9f 0xe5 -(gdb) x /4b 0x00002208 -0x2208 : 0x03 0x30 0x8f 0xe0 -(gdb) x /4b 0x0000220c -0x220c : 0x00 0x30 0x93 0xe5 -(gdb) x /4b 0x00002210 -0x2210 : 0x02 0x00 0xa0 0xe1 -(gdb) x /4b 0x00002214 -0x2214 : 0x03 0x10 0xa0 0xe1 -(gdb) x /4b 0x00002218 -0x2218 : 0x75 0x07 0x00 0xeb -(gdb) x /4b 0x0000221c -0x221c : 0x0c 0x30 0x9d 0xe5 -(gdb) x /4b 0x00002220 -0x2220 : 0x03 0x00 0xa0 0xe1 -(gdb) x /4b 0x00002224 -0x2224 : 0x00 0xd0 0x47 0xe2 -(gdb) x /4b 0x00002228 -0x2228 : 0x80 0x80 0xbd 0xe8 -(gdb) x /4b 0x0000222c -0x222c : 0xf8 0x24 0x00 0x00 -(gdb) x /4b 0x00002230 -0x2230 : 0x7c 0x24 0x00 0x00 -(gdb) x /4b 0x00002234 -0x2234 : 0x58 0x24 0x00 0x00 -(gdb) x /4b 0x00002238 -0x2238 : 0x14 0x24 0x00 0x00 +(gdb) x /2b 0x0704cdd0 +0x704cdd0 : 0x0f 0xb4 +(gdb) x /2b 0x0704cdd2 +0x704cdd2 : 0xb0 0xb5 +(gdb) x /2b 0x0704cdd4 +0x704cdd4 : 0x02 0xaf +(gdb) x /2b 0x0704cdd6 +0x704cdd6 : 0x81 0xb0 +(gdb) x /2b 0x0704cdd8 +0x704cdd8 : 0x05 0xab +(gdb) x /4b 0x0704cdda +0x704cdda : 0x53 0xf8 0x04 0x5b +(gdb) x /2b 0x0704cdde +0x704cdde : 0x00 0x93 +(gdb) x /2b 0x0704cde0 +0x704cde0 : 0x0d 0x4b +(gdb) x /2b 0x0704cde2 +0x704cde2 : 0x7b 0x44 +(gdb) x /2b 0x0704cde4 +0x704cde4 : 0x18 0x68 +(gdb) x /2b 0x0704cde6 +0x704cde6 : 0x04 0x68 +(gdb) x /2b 0x0704cde8 +0x704cde8 : 0x0c 0x48 +(gdb) x /2b 0x0704cdea +0x704cdea : 0x78 0x44 +(gdb) x /2b 0x0704cdec +0x704cdec : 0x00 0x68 +(gdb) x /2b 0x0704cdee +0x704cdee : 0x00 0x68 +(gdb) x /4b 0x0704cdf0 +0x704cdf0 : 0x2e 0xf0 0x1e 0xee +(gdb) x /2b 0x0704cdf4 +0x704cdf4 : 0x18 0xb9 +(gdb) x /2b 0x0704cdf6 +0x704cdf6 : 0x0a 0x49 +(gdb) x /2b 0x0704cdf8 +0x704cdf8 : 0x79 0x44 +(gdb) x /2b 0x0704cdfa +0x704cdfa : 0x09 0x68 +(gdb) x /2b 0x0704cdfc +0x704cdfc : 0x00 0xe0 +(gdb) x /2b 0x0704cdfe +0x704cdfe : 0x01 0x46 +(gdb) x /2b 0x0704ce00 +0x704ce00 : 0x20 0x46 +(gdb) x /2b 0x0704ce02 +0x704ce02 : 0x2a 0x46 +(gdb) x /2b 0x0704ce04 +0x704ce04 : 0x00 0x9b +(gdb) x /4b 0x0704ce06 +0x704ce06 : 0xfd 0xf7 0x9d 0xff +(gdb) x /4b 0x0704ce0a +0x704ce0a : 0xa7 0xf1 0x08 0x0d +(gdb) x /4b 0x0704ce0e +0x704ce0e : 0xbd 0xe8 0xb0 0x40 +(gdb) x /2b 0x0704ce12 +0x704ce12 : 0x04 0xb0 +(gdb) x /2b 0x0704ce14 +0x704ce14 : 0x70 0x47 +(gdb) x /2b 0x0704ce16 +0x704ce16 : 0x00 0xbf +(gdb) x /2b 0x0704ce18 +0x704ce18 : 0x8e 0x23 +(gdb) x /2b 0x0704ce1a +0x704ce1a : 0x05 0x00 +(gdb) x /2b 0x0704ce1c +0x704ce1c : 0x7a 0x31 +(gdb) x /2b 0x0704ce1e +0x704ce1e : 0x05 0x00 +(gdb) x /2b 0x0704ce20 +0x704ce20 : 0x68 0x31 +(gdb) x /2b 0x0704ce22 +0x704ce22 : 0x05 0x00 (gdb) quit -Executing command: /Volumes/data/lldb/llvm/Debug+Asserts/bin/llvm-mc -disassemble -triple=arm-apple-darwin -debug-only=arm-disassembler disasm-input.txt -Opcode=345 Name=STMDB_UPD Format=ARM_FORMAT_LDSTMULFRM(10) - 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 -------------------------------------------------------------------------------------------------- -| 1: 1: 1: 0| 1: 0: 0: 1| 0: 0: 1: 0| 1: 1: 0: 1| 0: 1: 0: 0| 0: 0: 0: 0| 1: 0: 0: 0| 0: 0: 0: 0| -------------------------------------------------------------------------------------------------- - - push {r7, lr} -Opcode=23 Name=ADDri Format=ARM_FORMAT_DPFRM(4) - 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 -------------------------------------------------------------------------------------------------- -| 1: 1: 1: 0| 0: 0: 1: 0| 1: 0: 0: 0| 1: 1: 0: 1| 0: 1: 1: 1| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| -------------------------------------------------------------------------------------------------- - - add r7, sp, #0 -Opcode=374 Name=SUBri Format=ARM_FORMAT_DPFRM(4) - 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 -------------------------------------------------------------------------------------------------- -| 1: 1: 1: 0| 0: 0: 1: 0| 0: 1: 0: 0| 1: 1: 0: 1| 1: 1: 0: 1| 0: 0: 0: 0| 0: 0: 0: 1| 0: 0: 0: 0| -------------------------------------------------------------------------------------------------- - - sub sp, sp, #16 -Opcode=369 Name=STRi12 Format=ARM_FORMAT_STFRM(7) - 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 -------------------------------------------------------------------------------------------------- -| 1: 1: 1: 0| 0: 1: 0: 1| 1: 0: 0: 0| 1: 1: 0: 1| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 1: 0: 0| -------------------------------------------------------------------------------------------------- - - str r0, [sp, #4] -Opcode=369 Name=STRi12 Format=ARM_FORMAT_STFRM(7) - 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 -------------------------------------------------------------------------------------------------- -| 1: 1: 1: 0| 0: 1: 0: 1| 1: 0: 0: 0| 1: 1: 0: 1| 0: 0: 0: 1| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| -------------------------------------------------------------------------------------------------- - - str r1, [sp] -Opcode=165 Name=LDRcp Format=ARM_FORMAT_LDFRM(6) - 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 -------------------------------------------------------------------------------------------------- -| 1: 1: 1: 0| 0: 1: 0: 1| 1: 0: 0: 1| 1: 1: 1: 1| 0: 0: 1: 1| 0: 0: 0: 0| 1: 0: 0: 1| 0: 0: 0: 0| -------------------------------------------------------------------------------------------------- - - ldr r3, [pc, #144] -Opcode=24 Name=ADDrr Format=ARM_FORMAT_DPFRM(4) - 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 -------------------------------------------------------------------------------------------------- -| 1: 1: 1: 0| 0: 0: 0: 0| 1: 0: 0: 0| 1: 1: 1: 1| 0: 0: 1: 1| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 1: 1| -------------------------------------------------------------------------------------------------- - - add r3, pc, r3 -Opcode=166 Name=LDRi12 Format=ARM_FORMAT_LDFRM(6) - 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 -------------------------------------------------------------------------------------------------- -| 1: 1: 1: 0| 0: 1: 0: 1| 1: 0: 0: 1| 0: 0: 1: 1| 0: 0: 1: 1| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| -------------------------------------------------------------------------------------------------- - - ldr r3, [r3] -Opcode=193 Name=MOVr Format=ARM_FORMAT_DPFRM(4) - 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 -------------------------------------------------------------------------------------------------- -| 1: 1: 1: 0| 0: 0: 0: 1| 1: 0: 1: 0| 0: 0: 0: 0| 0: 0: 1: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 1: 1| -------------------------------------------------------------------------------------------------- - - mov r2, r3 -Opcode=165 Name=LDRcp Format=ARM_FORMAT_LDFRM(6) - 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 -------------------------------------------------------------------------------------------------- -| 1: 1: 1: 0| 0: 1: 0: 1| 1: 0: 0: 1| 1: 1: 1: 1| 0: 0: 1: 1| 0: 0: 0: 0| 1: 0: 0: 0| 0: 1: 0: 0| -------------------------------------------------------------------------------------------------- - - ldr r3, [pc, #132] -Opcode=24 Name=ADDrr Format=ARM_FORMAT_DPFRM(4) +Executing command: /Volumes/data/lldb/llvm/Debug+Asserts/bin/llvm-mc -disassemble -triple=thumb-apple-darwin -debug-only=arm-disassembler disasm-input.txt +Opcode=2305 Name=tPUSH Format=ARM_FORMAT_THUMBFRM(25) 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 ------------------------------------------------------------------------------------------------- -| 1: 1: 1: 0| 0: 0: 0: 0| 1: 0: 0: 0| 1: 1: 1: 1| 0: 0: 1: 1| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 1: 1| +| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 1: 0: 1: 1| 0: 1: 0: 0| 0: 0: 0: 0| 1: 1: 1: 1| ------------------------------------------------------------------------------------------------- - add r3, pc, r3 -Opcode=166 Name=LDRi12 Format=ARM_FORMAT_LDFRM(6) + push {r0, r1, r2, r3} +Opcode=2305 Name=tPUSH Format=ARM_FORMAT_THUMBFRM(25) 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 ------------------------------------------------------------------------------------------------- -| 1: 1: 1: 0| 0: 1: 0: 1| 1: 0: 0: 1| 0: 0: 1: 1| 0: 0: 1: 1| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| +| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 1: 0: 1: 1| 0: 1: 0: 1| 1: 0: 1: 1| 0: 0: 0: 0| ------------------------------------------------------------------------------------------------- - ldr r3, [r3] -Opcode=193 Name=MOVr Format=ARM_FORMAT_DPFRM(4) + push {r4, r5, r7, lr} +Opcode=2228 Name=tADDrSPi Format=ARM_FORMAT_THUMBFRM(25) 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 ------------------------------------------------------------------------------------------------- -| 1: 1: 1: 0| 0: 0: 0: 1| 1: 0: 1: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 1: 0| +| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 1: 0: 1: 0| 1: 1: 1: 1| 0: 0: 0: 0| 0: 0: 1: 0| ------------------------------------------------------------------------------------------------- - mov r0, r2 -Opcode=193 Name=MOVr Format=ARM_FORMAT_DPFRM(4) + add r7, sp, #8 +Opcode=2328 Name=tSUBspi Format=ARM_FORMAT_THUMBFRM(25) 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 ------------------------------------------------------------------------------------------------- -| 1: 1: 1: 0| 0: 0: 0: 1| 1: 0: 1: 0| 0: 0: 0: 0| 0: 0: 0: 1| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 1: 1| +| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 1: 0: 1: 1| 0: 0: 0: 0| 1: 0: 0: 0| 0: 0: 0: 1| ------------------------------------------------------------------------------------------------- - mov r1, r3 -Opcode=66 Name=BL Format=ARM_FORMAT_BRFRM(2) + sub sp, #4 +Opcode=2228 Name=tADDrSPi Format=ARM_FORMAT_THUMBFRM(25) 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 ------------------------------------------------------------------------------------------------- -| 1: 1: 1: 0| 1: 0: 1: 1| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 1: 1: 1| 1: 0: 0: 0| 1: 1: 0: 1| +| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 1: 0: 1: 0| 1: 0: 1: 1| 0: 0: 0: 0| 0: 1: 0: 1| ------------------------------------------------------------------------------------------------- - bl #7732 -Opcode=193 Name=MOVr Format=ARM_FORMAT_DPFRM(4) + add r3, sp, #20 +Opcode=1963 Name=t2LDR_POST Format=ARM_FORMAT_THUMBFRM(25) 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 ------------------------------------------------------------------------------------------------- -| 1: 1: 1: 0| 0: 0: 0: 1| 1: 0: 1: 0| 0: 0: 0: 0| 0: 0: 1: 1| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| +| 1: 1: 1: 1| 1: 0: 0: 0| 0: 1: 0: 1| 0: 0: 1: 1| 0: 1: 0: 1| 1: 0: 1: 1| 0: 0: 0: 0| 0: 1: 0: 0| ------------------------------------------------------------------------------------------------- - mov r3, r0 -Opcode=193 Name=MOVr Format=ARM_FORMAT_DPFRM(4) + ldr r5, [r3], #4 +Opcode=2324 Name=tSTRspi Format=ARM_FORMAT_THUMBFRM(25) 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 ------------------------------------------------------------------------------------------------- -| 1: 1: 1: 0| 0: 0: 0: 1| 1: 0: 1: 0| 0: 0: 0: 0| 0: 0: 1: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 1: 1| +| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 1: 0: 0: 1| 0: 0: 1: 1| 0: 0: 0: 0| 0: 0: 0: 0| ------------------------------------------------------------------------------------------------- - mov r2, r3 -Opcode=165 Name=LDRcp Format=ARM_FORMAT_LDFRM(6) + str r3, [sp] +Opcode=2275 Name=tLDRpci Format=ARM_FORMAT_THUMBFRM(25) 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 ------------------------------------------------------------------------------------------------- -| 1: 1: 1: 0| 0: 1: 0: 1| 1: 0: 0: 1| 1: 1: 1: 1| 0: 0: 1: 1| 0: 0: 0: 0| 0: 1: 1: 0| 1: 0: 0: 0| +| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 1: 0: 0| 1: 0: 1: 1| 0: 0: 0: 0| 1: 1: 0: 1| ------------------------------------------------------------------------------------------------- - ldr r3, [pc, #104] -Opcode=24 Name=ADDrr Format=ARM_FORMAT_DPFRM(4) + ldr.n r3, #52 +Opcode=2223 Name=tADDhirr Format=ARM_FORMAT_THUMBFRM(25) 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 ------------------------------------------------------------------------------------------------- -| 1: 1: 1: 0| 0: 0: 0: 0| 1: 0: 0: 0| 1: 1: 1: 1| 0: 0: 1: 1| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 1: 1| +| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 1: 0: 0| 0: 1: 0: 0| 0: 1: 1: 1| 1: 0: 1: 1| ------------------------------------------------------------------------------------------------- - add r3, pc, r3 -Opcode=166 Name=LDRi12 Format=ARM_FORMAT_LDFRM(6) + add r3, pc +Opcode=2274 Name=tLDRi Format=ARM_FORMAT_THUMBFRM(25) 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 ------------------------------------------------------------------------------------------------- -| 1: 1: 1: 0| 0: 1: 0: 1| 1: 0: 0: 1| 0: 0: 1: 1| 0: 0: 1: 1| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| +| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 1: 1: 0| 1: 0: 0: 0| 0: 0: 0: 1| 1: 0: 0: 0| ------------------------------------------------------------------------------------------------- - ldr r3, [r3] -Opcode=193 Name=MOVr Format=ARM_FORMAT_DPFRM(4) + ldr r0, [r3] +Opcode=2274 Name=tLDRi Format=ARM_FORMAT_THUMBFRM(25) 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 ------------------------------------------------------------------------------------------------- -| 1: 1: 1: 0| 0: 0: 0: 1| 1: 0: 1: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 1: 0| +| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 1: 1: 0| 1: 0: 0: 0| 0: 0: 0: 0| 0: 1: 0: 0| ------------------------------------------------------------------------------------------------- - mov r0, r2 -Opcode=193 Name=MOVr Format=ARM_FORMAT_DPFRM(4) + ldr r4, [r0] +Opcode=2275 Name=tLDRpci Format=ARM_FORMAT_THUMBFRM(25) 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 ------------------------------------------------------------------------------------------------- -| 1: 1: 1: 0| 0: 0: 0: 1| 1: 0: 1: 0| 0: 0: 0: 0| 0: 0: 0: 1| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 1: 1| +| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 1: 0: 0| 1: 0: 0: 0| 0: 0: 0: 0| 1: 1: 0: 0| ------------------------------------------------------------------------------------------------- - mov r1, r3 -Opcode=66 Name=BL Format=ARM_FORMAT_BRFRM(2) + ldr.n r0, #48 +Opcode=2223 Name=tADDhirr Format=ARM_FORMAT_THUMBFRM(25) 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 ------------------------------------------------------------------------------------------------- -| 1: 1: 1: 0| 1: 0: 1: 1| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 1: 1: 1| 1: 0: 0: 0| 0: 1: 0: 1| +| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 1: 0: 0| 0: 1: 0: 0| 0: 1: 1: 1| 1: 0: 0: 0| ------------------------------------------------------------------------------------------------- - bl #7700 -Opcode=193 Name=MOVr Format=ARM_FORMAT_DPFRM(4) + add r0, pc +Opcode=2274 Name=tLDRi Format=ARM_FORMAT_THUMBFRM(25) 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 ------------------------------------------------------------------------------------------------- -| 1: 1: 1: 0| 0: 0: 0: 1| 1: 0: 1: 0| 0: 0: 0: 0| 0: 0: 1: 1| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| +| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 1: 1: 0| 1: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| ------------------------------------------------------------------------------------------------- - mov r3, r0 -Opcode=369 Name=STRi12 Format=ARM_FORMAT_STFRM(7) + ldr r0, [r0] +Opcode=2274 Name=tLDRi Format=ARM_FORMAT_THUMBFRM(25) 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 ------------------------------------------------------------------------------------------------- -| 1: 1: 1: 0| 0: 1: 0: 1| 1: 0: 0: 0| 1: 1: 0: 1| 0: 0: 1: 1| 0: 0: 0: 0| 0: 0: 0: 0| 1: 0: 0: 0| +| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 1: 1: 0| 1: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| ------------------------------------------------------------------------------------------------- - str r3, [sp, #8] -Opcode=166 Name=LDRi12 Format=ARM_FORMAT_LDFRM(6) + ldr r0, [r0] +Opcode=2243 Name=tBLXi_r9 Format=ARM_FORMAT_THUMBFRM(25) 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 ------------------------------------------------------------------------------------------------- -| 1: 1: 1: 0| 0: 1: 0: 1| 1: 0: 0: 1| 1: 1: 0: 1| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 1: 0: 0| +| 1: 1: 1: 1| 0: 0: 0: 0| 0: 0: 1: 0| 1: 1: 1: 0| 1: 1: 1: 0| 1: 1: 1: 0| 0: 0: 0: 1| 1: 1: 1: 0| ------------------------------------------------------------------------------------------------- - ldr r0, [sp, #4] -Opcode=166 Name=LDRi12 Format=ARM_FORMAT_LDFRM(6) + blx #191548 +Opcode=2255 Name=tCBNZ Format=ARM_FORMAT_THUMBFRM(25) 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 ------------------------------------------------------------------------------------------------- -| 1: 1: 1: 0| 0: 1: 0: 1| 1: 0: 0: 1| 1: 1: 0: 1| 0: 0: 0: 1| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| +| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 1: 0: 1: 1| 1: 0: 0: 1| 0: 0: 0: 1| 1: 0: 0: 0| ------------------------------------------------------------------------------------------------- - ldr r1, [sp] -Opcode=189 Name=MOVi Format=ARM_FORMAT_DPFRM(4) + cbnz r0, #6 +Opcode=2275 Name=tLDRpci Format=ARM_FORMAT_THUMBFRM(25) 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 ------------------------------------------------------------------------------------------------- -| 1: 1: 1: 0| 0: 0: 1: 1| 1: 0: 1: 0| 0: 0: 0: 0| 0: 0: 1: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| +| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 1: 0: 0| 1: 0: 0: 1| 0: 0: 0: 0| 1: 0: 1: 0| ------------------------------------------------------------------------------------------------- - mov r2, #0 -Opcode=189 Name=MOVi Format=ARM_FORMAT_DPFRM(4) + ldr.n r1, #40 +Opcode=2223 Name=tADDhirr Format=ARM_FORMAT_THUMBFRM(25) 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 ------------------------------------------------------------------------------------------------- -| 1: 1: 1: 0| 0: 0: 1: 1| 1: 0: 1: 0| 0: 0: 0: 0| 0: 0: 1: 1| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| +| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 1: 0: 0| 0: 1: 0: 0| 0: 1: 1: 1| 1: 0: 0: 1| ------------------------------------------------------------------------------------------------- - mov r3, #0 -Opcode=66 Name=BL Format=ARM_FORMAT_BRFRM(2) + add r1, pc +Opcode=2274 Name=tLDRi Format=ARM_FORMAT_THUMBFRM(25) 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 ------------------------------------------------------------------------------------------------- -| 1: 1: 1: 0| 1: 0: 1: 1| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 1: 1: 1| 0: 1: 1: 1| 1: 1: 0: 0| +| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 1: 1: 0| 1: 0: 0: 0| 0: 0: 0: 0| 1: 0: 0: 1| ------------------------------------------------------------------------------------------------- - bl #7664 -Opcode=193 Name=MOVr Format=ARM_FORMAT_DPFRM(4) + ldr r1, [r1] +Opcode=2238 Name=tB Format=ARM_FORMAT_THUMBFRM(25) 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 ------------------------------------------------------------------------------------------------- -| 1: 1: 1: 0| 0: 0: 0: 1| 1: 0: 1: 0| 0: 0: 0: 0| 0: 0: 1: 1| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| +| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 1: 1: 1: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| ------------------------------------------------------------------------------------------------- - mov r3, r0 -Opcode=369 Name=STRi12 Format=ARM_FORMAT_STFRM(7) + b #0 +Opcode=2294 Name=tMOVr Format=ARM_FORMAT_THUMBFRM(25) 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 ------------------------------------------------------------------------------------------------- -| 1: 1: 1: 0| 0: 1: 0: 1| 1: 0: 0: 0| 1: 1: 0: 1| 0: 0: 1: 1| 0: 0: 0: 0| 0: 0: 0: 0| 1: 1: 0: 0| +| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 1: 0: 0| 0: 1: 1: 0| 0: 0: 0: 0| 0: 0: 0: 1| ------------------------------------------------------------------------------------------------- - str r3, [sp, #12] -Opcode=166 Name=LDRi12 Format=ARM_FORMAT_LDFRM(6) + mov r1, r0 +Opcode=2294 Name=tMOVr Format=ARM_FORMAT_THUMBFRM(25) 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 ------------------------------------------------------------------------------------------------- -| 1: 1: 1: 0| 0: 1: 0: 1| 1: 0: 0: 1| 1: 1: 0: 1| 0: 0: 1: 0| 0: 0: 0: 0| 0: 0: 0: 0| 1: 0: 0: 0| +| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 1: 0: 0| 0: 1: 1: 0| 0: 0: 1: 0| 0: 0: 0: 0| ------------------------------------------------------------------------------------------------- - ldr r2, [sp, #8] -Opcode=165 Name=LDRcp Format=ARM_FORMAT_LDFRM(6) + mov r0, r4 +Opcode=2294 Name=tMOVr Format=ARM_FORMAT_THUMBFRM(25) 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 ------------------------------------------------------------------------------------------------- -| 1: 1: 1: 0| 0: 1: 0: 1| 1: 0: 0: 1| 1: 1: 1: 1| 0: 0: 1: 1| 0: 0: 0: 0| 0: 0: 1: 0| 1: 1: 0: 0| +| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 1: 0: 0| 0: 1: 1: 0| 0: 0: 1: 0| 1: 0: 1: 0| ------------------------------------------------------------------------------------------------- - ldr r3, [pc, #44] -Opcode=24 Name=ADDrr Format=ARM_FORMAT_DPFRM(4) + mov r2, r5 +Opcode=2278 Name=tLDRspi Format=ARM_FORMAT_THUMBFRM(25) 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 ------------------------------------------------------------------------------------------------- -| 1: 1: 1: 0| 0: 0: 0: 0| 1: 0: 0: 0| 1: 1: 1: 1| 0: 0: 1: 1| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 1: 1| +| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 1: 0: 0: 1| 1: 0: 1: 1| 0: 0: 0: 0| 0: 0: 0: 0| ------------------------------------------------------------------------------------------------- - add r3, pc, r3 -Opcode=166 Name=LDRi12 Format=ARM_FORMAT_LDFRM(6) + ldr r3, [sp] +Opcode=2246 Name=tBLr9 Format=ARM_FORMAT_THUMBFRM(25) 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 ------------------------------------------------------------------------------------------------- -| 1: 1: 1: 0| 0: 1: 0: 1| 1: 0: 0: 1| 0: 0: 1: 1| 0: 0: 1: 1| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| +| 1: 1: 1: 1| 0: 1: 1: 1| 1: 1: 1: 1| 1: 1: 0: 1| 1: 1: 1: 1| 1: 1: 1: 1| 1: 0: 0: 1| 1: 1: 0: 1| ------------------------------------------------------------------------------------------------- - ldr r3, [r3] -Opcode=193 Name=MOVr Format=ARM_FORMAT_DPFRM(4) + bl #-8390 +Opcode=2153 Name=t2SUBri Format=ARM_FORMAT_THUMBFRM(25) 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 ------------------------------------------------------------------------------------------------- -| 1: 1: 1: 0| 0: 0: 0: 1| 1: 0: 1: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 1: 0| +| 1: 1: 1: 1| 0: 0: 0: 1| 1: 0: 1: 0| 0: 1: 1: 1| 0: 0: 0: 0| 1: 1: 0: 1| 0: 0: 0: 0| 1: 0: 0: 0| ------------------------------------------------------------------------------------------------- - mov r0, r2 -Opcode=193 Name=MOVr Format=ARM_FORMAT_DPFRM(4) + sub.w sp, r7, #8 +Opcode=1926 Name=t2LDMIA_UPD Format=ARM_FORMAT_THUMBFRM(25) 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 ------------------------------------------------------------------------------------------------- -| 1: 1: 1: 0| 0: 0: 0: 1| 1: 0: 1: 0| 0: 0: 0: 0| 0: 0: 0: 1| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 1: 1| +| 1: 1: 1: 0| 1: 0: 0: 0| 1: 0: 1: 1| 1: 1: 0: 1| 0: 1: 0: 0| 0: 0: 0: 0| 1: 0: 1: 1| 0: 0: 0: 0| ------------------------------------------------------------------------------------------------- - mov r1, r3 -Opcode=66 Name=BL Format=ARM_FORMAT_BRFRM(2) + pop.w {r4, r5, r7, lr} +Opcode=2230 Name=tADDspi Format=ARM_FORMAT_THUMBFRM(25) 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 ------------------------------------------------------------------------------------------------- -| 1: 1: 1: 0| 1: 0: 1: 1| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 1: 1: 1| 0: 1: 1: 1| 0: 1: 0: 1| +| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 1: 0: 1: 1| 0: 0: 0: 0| 0: 0: 0: 0| 0: 1: 0: 0| ------------------------------------------------------------------------------------------------- - bl #7636 -Opcode=166 Name=LDRi12 Format=ARM_FORMAT_LDFRM(6) + add sp, #16 +Opcode=2250 Name=tBX_RET Format=ARM_FORMAT_THUMBFRM(25) 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 ------------------------------------------------------------------------------------------------- -| 1: 1: 1: 0| 0: 1: 0: 1| 1: 0: 0: 1| 1: 1: 0: 1| 0: 0: 1: 1| 0: 0: 0: 0| 0: 0: 0: 0| 1: 1: 0: 0| +| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 1: 0: 0| 0: 1: 1: 1| 0: 1: 1: 1| 0: 0: 0: 0| ------------------------------------------------------------------------------------------------- - ldr r3, [sp, #12] -Opcode=193 Name=MOVr Format=ARM_FORMAT_DPFRM(4) + bx lr +Opcode=2300 Name=tNOP Format=ARM_FORMAT_THUMBFRM(25) 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 ------------------------------------------------------------------------------------------------- -| 1: 1: 1: 0| 0: 0: 0: 1| 1: 0: 1: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 1: 1| +| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 1: 0: 1: 1| 1: 1: 1: 1| 0: 0: 0: 0| 0: 0: 0: 0| ------------------------------------------------------------------------------------------------- - mov r0, r3 -Opcode=374 Name=SUBri Format=ARM_FORMAT_DPFRM(4) + nop +Opcode=2293 Name=tMOVi8 Format=ARM_FORMAT_THUMBFRM(25) 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 ------------------------------------------------------------------------------------------------- -| 1: 1: 1: 0| 0: 0: 1: 0| 0: 1: 0: 0| 0: 1: 1: 1| 1: 1: 0: 1| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| +| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 1: 0| 0: 0: 1: 1| 1: 0: 0: 0| 1: 1: 1: 0| ------------------------------------------------------------------------------------------------- - sub sp, r7, #0 -Opcode=135 Name=LDMIA_UPD Format=ARM_FORMAT_LDSTMULFRM(10) + movs r3, #142 +Opcode=2290 Name=tMOVSr Format=ARM_FORMAT_THUMBFRM(25) 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 ------------------------------------------------------------------------------------------------- -| 1: 1: 1: 0| 1: 0: 0: 0| 1: 0: 1: 1| 1: 1: 0: 1| 1: 0: 0: 0| 0: 0: 0: 0| 1: 0: 0: 0| 0: 0: 0: 0| +| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 1: 0: 1| ------------------------------------------------------------------------------------------------- - pop {r7, pc} -Opcode=356 Name=STRD_POST Format=ARM_FORMAT_STMISCFRM(9) + movs r5, r0 +Opcode=2225 Name=tADDi8 Format=ARM_FORMAT_THUMBFRM(25) 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 ------------------------------------------------------------------------------------------------- -| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 1: 0| 0: 1: 0: 0| 1: 1: 1: 1| 1: 0: 0: 0| +| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 1: 1| 0: 0: 0: 1| 0: 1: 1: 1| 1: 0: 1: 0| ------------------------------------------------------------------------------------------------- - strdeq r2, r3, [r0], -r8 -Opcode=31 Name=ANDrs Format=ARM_FORMAT_DPSOREGFRM(5) + adds r1, #122 +Opcode=2290 Name=tMOVSr Format=ARM_FORMAT_THUMBFRM(25) 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 ------------------------------------------------------------------------------------------------- -| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 1: 0| 0: 1: 0: 0| 0: 1: 1: 1| 1: 1: 0: 0| +| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 1: 0: 1| ------------------------------------------------------------------------------------------------- - andeq r2, r0, r12, ror r4 -Opcode=31 Name=ANDrs Format=ARM_FORMAT_DPSOREGFRM(5) + movs r5, r0 +Opcode=2225 Name=tADDi8 Format=ARM_FORMAT_THUMBFRM(25) 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 ------------------------------------------------------------------------------------------------- -| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 1: 0| 0: 1: 0: 0| 0: 1: 0: 1| 1: 0: 0: 0| +| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 1: 1| 0: 0: 0: 1| 0: 1: 1: 0| 1: 0: 0: 0| ------------------------------------------------------------------------------------------------- - andeq r2, r0, r8, asr r4 -Opcode=31 Name=ANDrs Format=ARM_FORMAT_DPSOREGFRM(5) + adds r1, #104 +Opcode=2290 Name=tMOVSr Format=ARM_FORMAT_THUMBFRM(25) 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 ------------------------------------------------------------------------------------------------- -| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 1: 0| 0: 1: 0: 0| 0: 0: 0: 1| 0: 1: 0: 0| +| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 1: 0: 1| ------------------------------------------------------------------------------------------------- - andeq r2, r0, r4, lsl r4 -da0603a-dhcp191:9131529 johnny$ + movs r5, r0 +[16:28:00] johnny:/Volumes/data/Radar/9131529 $ Modified: lldb/trunk/utils/test/disasm.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/utils/test/disasm.py?rev=128040&r1=128039&r2=128040&view=diff ============================================================================== --- lldb/trunk/utils/test/disasm.py (original) +++ lldb/trunk/utils/test/disasm.py Mon Mar 21 18:44:44 2011 @@ -27,16 +27,26 @@ return exe_file return None -def do_llvm_mc_disassembly(exe, func, mc, mc_options = None): +def do_llvm_mc_disassembly(gdb_commands, gdb_options, exe, func, mc, mc_options): from cStringIO import StringIO import pexpect gdb_prompt = "\r\n\(gdb\) " - gdb = pexpect.spawn('gdb %s' % exe) + gdb = pexpect.spawn(('gdb %s' % gdb_options) if gdb_options else 'gdb') # Turn on logging for what gdb sends back. gdb.logfile_read = sys.stdout + gdb.expect(gdb_prompt) + + # See if there any extra command(s) to execute before we issue the file command. + for cmd in gdb_commands: + gdb.sendline(cmd) + gdb.expect(gdb_prompt) + # Now issue the file command. + gdb.sendline('file %s' % exe) gdb.expect(gdb_prompt) + + # Send the disassemble command. gdb.sendline('disassemble %s' % func) gdb.expect(gdb_prompt) @@ -123,6 +133,14 @@ Usage: %prog [options] """) + parser.add_option('-C', '--gdb-command', + type='string', action='append', metavar='COMMAND', + default=[], dest='gdb_commands', + help='Command(s) gdb executes after starting up (can be empty)') + parser.add_option('-O', '--gdb-options', + type='string', action='store', + dest='gdb_options', + help="""The options passed to 'gdb' command if specified.""") parser.add_option('-e', '--executable', type='string', action='store', dest='executable', @@ -140,10 +158,13 @@ parser.add_option('-o', '--options', type='string', action='store', dest='llvm_mc_options', - help="""The extra options passed to 'llvm-mc -disassemble' command if specified.""") + help="""The options passed to 'llvm-mc -disassemble' command if specified.""") opts, args = parser.parse_args() + gdb_commands = opts.gdb_commands + gdb_options = opts.gdb_options + if not opts.executable: parser.print_help() sys.exit(1) @@ -164,12 +185,14 @@ llvm_mc_options = opts.llvm_mc_options # We have parsed the options. + print "gdb commands:", gdb_commands + print "gdb options:", gdb_options print "executable:", executable print "function:", function print "llvm-mc:", llvm_mc print "llvm-mc options:", llvm_mc_options - do_llvm_mc_disassembly(executable, function, llvm_mc, llvm_mc_options) + do_llvm_mc_disassembly(gdb_commands, gdb_options, executable, function, llvm_mc, llvm_mc_options) if __name__ == '__main__': main() From gclayton at apple.com Mon Mar 21 20:14:58 2011 From: gclayton at apple.com (Greg Clayton) Date: Tue, 22 Mar 2011 01:14:58 -0000 Subject: [Lldb-commits] [lldb] r128053 - in /lldb/trunk: include/lldb/API/ include/lldb/Interpreter/ lldb.xcodeproj/ scripts/ source/ source/API/ source/Interpreter/ test/abbreviation_tests/ tools/debugserver/source/ Message-ID: <20110322011458.D0F6B2A6C12C@llvm.org> Author: gclayton Date: Mon Mar 21 20:14:58 2011 New Revision: 128053 URL: http://llvm.org/viewvc/llvm-project?rev=128053&view=rev Log: Abtracted the innards of lldb-core away from the SB interface. There was some overlap in the SWIG integration which has now been fixed by introducing callbacks for initializing SWIG for each language (python only right now). There was also a breakpoint command callback that called into SWIG which has been abtracted into a callback to avoid cross over as well. Added a new binary: lldb-platform This will be the start of the remote platform that will use as much of the Host functionality to do its job so it should just work on all platforms. It is pretty hollowed out for now, but soon it will implement a platform using the GDB remote packets as the transport. Modified: lldb/trunk/include/lldb/API/SBBreakpointLocation.h lldb/trunk/include/lldb/API/SBCommandInterpreter.h lldb/trunk/include/lldb/API/SBFrame.h lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h lldb/trunk/include/lldb/Interpreter/ScriptInterpreterPython.h lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/scripts/lldb.swig lldb/trunk/source/API/SBCommandInterpreter.cpp lldb/trunk/source/API/SBDebugger.cpp lldb/trunk/source/Interpreter/ScriptInterpreter.cpp lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp lldb/trunk/source/lldb.cpp lldb/trunk/test/abbreviation_tests/TestAbbreviations.py lldb/trunk/tools/debugserver/source/RNBRemote.cpp Modified: lldb/trunk/include/lldb/API/SBBreakpointLocation.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBBreakpointLocation.h?rev=128053&r1=128052&r2=128053&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBBreakpointLocation.h (original) +++ lldb/trunk/include/lldb/API/SBBreakpointLocation.h Mon Mar 21 20:14:58 2011 @@ -87,11 +87,11 @@ SBBreakpoint GetBreakpoint (); + SBBreakpointLocation (const lldb::BreakpointLocationSP &break_loc_sp); + private: friend class SBBreakpoint; friend class lldb_private::ScriptInterpreterPython; - - SBBreakpointLocation (const lldb::BreakpointLocationSP &break_loc_sp); void SetLocation (const lldb::BreakpointLocationSP &break_loc_sp); Modified: lldb/trunk/include/lldb/API/SBCommandInterpreter.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBCommandInterpreter.h?rev=128053&r1=128052&r2=128053&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBCommandInterpreter.h (original) +++ lldb/trunk/include/lldb/API/SBCommandInterpreter.h Mon Mar 21 20:14:58 2011 @@ -101,7 +101,9 @@ SBCommandInterpreter (lldb_private::CommandInterpreter *interpreter_ptr = NULL); // Access using SBDebugger::GetCommandInterpreter(); - + static void + InitializeSWIG (); + lldb_private::CommandInterpreter *m_opaque_ptr; }; Modified: lldb/trunk/include/lldb/API/SBFrame.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBFrame.h?rev=128053&r1=128052&r2=128053&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBFrame.h (original) +++ lldb/trunk/include/lldb/API/SBFrame.h Mon Mar 21 20:14:58 2011 @@ -130,6 +130,8 @@ bool GetDescription (lldb::SBStream &description); + SBFrame (const lldb::StackFrameSP &lldb_object_sp); + protected: friend class SBValue; @@ -152,8 +154,6 @@ #endif - SBFrame (const lldb::StackFrameSP &lldb_object_sp); - void SetFrame (const lldb::StackFrameSP &lldb_object_sp); Modified: lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h?rev=128053&r1=128052&r2=128053&view=diff ============================================================================== --- lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h (original) +++ lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h Mon Mar 21 20:14:58 2011 @@ -20,6 +20,12 @@ { public: + typedef void (*SWIGInitCallback) (void); + + typedef bool (*SWIGBreakpointCallbackFunction) (const char *python_function_name, + const char *session_dictionary_name, + const lldb::StackFrameSP& frame_sp, + const lldb::BreakpointLocationSP &bp_loc_sp); typedef enum { eCharPtr, @@ -97,10 +103,11 @@ LanguageToString (lldb::ScriptLanguage language); static void - Initialize (); + InitializeInterpreter (SWIGInitCallback python_swig_init_callback, + SWIGBreakpointCallbackFunction python_swig_breakpoint_callback); static void - Terminate (); + TerminateInterpreter (); virtual void ResetOutputFileHandle (FILE *new_fh) { } //By default, do nothing. Modified: lldb/trunk/include/lldb/Interpreter/ScriptInterpreterPython.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/ScriptInterpreterPython.h?rev=128053&r1=128052&r2=128053&view=diff ============================================================================== --- lldb/trunk/include/lldb/Interpreter/ScriptInterpreterPython.h (original) +++ lldb/trunk/include/lldb/Interpreter/ScriptInterpreterPython.h Mon Mar 21 20:14:58 2011 @@ -84,10 +84,11 @@ RunEmbeddedPythonInterpreter (lldb::thread_arg_t baton); static void - Initialize (); - + InitializePrivate (); + static void - Terminate (); + InitializeInterpreter (SWIGInitCallback python_swig_init_callback, + SWIGBreakpointCallbackFunction python_swig_breakpoint_callback); protected: Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=128053&r1=128052&r2=128053&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Mon Mar 21 20:14:58 2011 @@ -7,20 +7,12 @@ objects = { /* Begin PBXBuildFile section */ - 260C6EA113011578005E16B0 /* File.h in Headers */ = {isa = PBXBuildFile; fileRef = 260C6EA013011578005E16B0 /* File.h */; }; 260C876A10F538E700BB2B04 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 260C876910F538E700BB2B04 /* Foundation.framework */; }; 261744781168585B005ADD65 /* SBType.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 261744771168585B005ADD65 /* SBType.cpp */; }; 2617447A11685869005ADD65 /* SBType.h in Headers */ = {isa = PBXBuildFile; fileRef = 2617447911685869005ADD65 /* SBType.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 2618EE661315B29C001D6D71 /* GDBRemoteCommunication.h in Headers */ = {isa = PBXBuildFile; fileRef = 2618EE5C1315B29C001D6D71 /* GDBRemoteCommunication.h */; }; - 2618EE681315B29C001D6D71 /* GDBRemoteRegisterContext.h in Headers */ = {isa = PBXBuildFile; fileRef = 2618EE5E1315B29C001D6D71 /* GDBRemoteRegisterContext.h */; }; - 2618EE6A1315B29C001D6D71 /* ProcessGDBRemote.h in Headers */ = {isa = PBXBuildFile; fileRef = 2618EE601315B29C001D6D71 /* ProcessGDBRemote.h */; }; - 2618EE6C1315B29C001D6D71 /* ProcessGDBRemoteLog.h in Headers */ = {isa = PBXBuildFile; fileRef = 2618EE621315B29C001D6D71 /* ProcessGDBRemoteLog.h */; }; - 2618EE6E1315B29C001D6D71 /* ThreadGDBRemote.h in Headers */ = {isa = PBXBuildFile; fileRef = 2618EE641315B29C001D6D71 /* ThreadGDBRemote.h */; }; 262CFC7711A4510000946C6C /* debugserver in Resources */ = {isa = PBXBuildFile; fileRef = 26CE05A0115C31E50022F371 /* debugserver */; }; - 2635DA87127D0D0400675BC1 /* SharingPtr.h in Headers */ = {isa = PBXBuildFile; fileRef = 261B5A5311C3F2AD00AABD0A /* SharingPtr.h */; settings = {ATTRIBUTES = (Public, ); }; }; 26368A3C126B697600E8659F /* darwin-debug.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26368A3B126B697600E8659F /* darwin-debug.cpp */; }; 26368AF7126B960500E8659F /* darwin-debug in Resources */ = {isa = PBXBuildFile; fileRef = 26579F68126A25920007C5CB /* darwin-debug */; }; - 264A43BC1320B3B4005B4096 /* Platform.h in Headers */ = {isa = PBXBuildFile; fileRef = 264A43BB1320B3B4005B4096 /* Platform.h */; }; 265ABF6310F42EE900531910 /* DebugSymbols.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 265ABF6210F42EE900531910 /* DebugSymbols.framework */; }; 2668020E115FD12C008E1FE4 /* lldb-defines.h in Headers */ = {isa = PBXBuildFile; fileRef = 26BC7C2510F1B3BC00F91463 /* lldb-defines.h */; settings = {ATTRIBUTES = (Public, ); }; }; 2668020F115FD12C008E1FE4 /* lldb-enumerations.h in Headers */ = {isa = PBXBuildFile; fileRef = 26BC7C2610F1B3BC00F91463 /* lldb-enumerations.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -64,10 +56,6 @@ 26680336116005EF008E1FE4 /* SBBreakpointLocation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AF16CC7114086A1007A7B3F /* SBBreakpointLocation.cpp */; }; 26680337116005F1008E1FE4 /* SBBreakpoint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AF16A9C11402D5B007A7B3F /* SBBreakpoint.cpp */; }; 2668035C11601108008E1FE4 /* LLDB.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 26680207115FD0ED008E1FE4 /* LLDB.framework */; }; - 266A42D8128E40040090CF7C /* ClangNamespaceDecl.h in Headers */ = {isa = PBXBuildFile; fileRef = 266A42D7128E40040090CF7C /* ClangNamespaceDecl.h */; }; - 266F5CBC12FC846200DFCE33 /* Config.h in Headers */ = {isa = PBXBuildFile; fileRef = 266F5CBB12FC846200DFCE33 /* Config.h */; }; - 2675F7011332BE690067997B /* PlatformRemoteiOS.h in Headers */ = {isa = PBXBuildFile; fileRef = 2675F6FF1332BE690067997B /* PlatformRemoteiOS.h */; }; - 26879CE61333F5750012C1F8 /* CommandObjectPlatform.h in Headers */ = {isa = PBXBuildFile; fileRef = 26879CE51333F5750012C1F8 /* CommandObjectPlatform.h */; }; 2689000013353DB600698AC0 /* BreakpointResolverAddress.h in Headers */ = {isa = PBXBuildFile; fileRef = 26D0DD5010FE554D00271C65 /* BreakpointResolverAddress.h */; }; 2689000113353DB600698AC0 /* BreakpointResolverAddress.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26D0DD5310FE555900271C65 /* BreakpointResolverAddress.cpp */; }; 2689000213353DB600698AC0 /* BreakpointResolverFileLine.h in Headers */ = {isa = PBXBuildFile; fileRef = 26D0DD5110FE554D00271C65 /* BreakpointResolverFileLine.h */; }; @@ -194,7 +182,6 @@ 2689007B13353E1A00698AC0 /* CFCString.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7EF810F1B8AD00F91463 /* CFCString.cpp */; }; 2689007C13353E1A00698AC0 /* Symbols.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2689B0B5113EE47E00A4AEDB /* Symbols.cpp */; }; 2689007D13353E2200698AC0 /* Args.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E6C10F1B85900F91463 /* Args.cpp */; }; - 2689007E13353E2200698AC0 /* LLDBWrapPython.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26A4EEB511682AAC007A372A /* LLDBWrapPython.cpp */; }; 2689007F13353E2200698AC0 /* CommandCompletions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C09CB74116BD98B00C7A725 /* CommandCompletions.cpp */; }; 2689008013353E2200698AC0 /* CommandInterpreter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7F0810F1B8DD00F91463 /* CommandInterpreter.cpp */; }; 2689008113353E2200698AC0 /* CommandObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7F0910F1B8DD00F91463 /* CommandObject.cpp */; }; @@ -365,19 +352,22 @@ 2689FFFD13353DB600698AC0 /* BreakpointOptions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E1110F1B83100F91463 /* BreakpointOptions.cpp */; }; 2689FFFE13353DB600698AC0 /* BreakpointResolver.h in Headers */ = {isa = PBXBuildFile; fileRef = 26BC7CF610F1B71400F91463 /* BreakpointResolver.h */; }; 2689FFFF13353DB600698AC0 /* BreakpointResolver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E1210F1B83100F91463 /* BreakpointResolver.cpp */; }; - 268A68401321B53B000E3FB8 /* DynamicLoaderStatic.h in Headers */ = {isa = PBXBuildFile; fileRef = 268A683E1321B53B000E3FB8 /* DynamicLoaderStatic.h */; }; - 268DA872130095D000C9483A /* Terminal.h in Headers */ = {isa = PBXBuildFile; fileRef = 268DA871130095D000C9483A /* Terminal.h */; }; 268F9D53123AA15200B91E9B /* SBSymbolContextList.h in Headers */ = {isa = PBXBuildFile; fileRef = 268F9D52123AA15200B91E9B /* SBSymbolContextList.h */; settings = {ATTRIBUTES = (Public, ); }; }; 268F9D55123AA16600B91E9B /* SBSymbolContextList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 268F9D54123AA16600B91E9B /* SBSymbolContextList.cpp */; }; + 26B1FA1413380E61002886E2 /* LLDBWrapPython.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26A4EEB511682AAC007A372A /* LLDBWrapPython.cpp */; }; + 26B1FCB813381071002886E2 /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 26F5C39010F3FA26009D5894 /* CoreFoundation.framework */; }; + 26B1FCB913381071002886E2 /* DebugSymbols.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 265ABF6210F42EE900531910 /* DebugSymbols.framework */; }; + 26B1FCBA13381071002886E2 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 260C876910F538E700BB2B04 /* Foundation.framework */; }; + 26B1FCBB13381071002886E2 /* libpython.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 26F5C32410F3DF23009D5894 /* libpython.dylib */; }; + 26B1FCBC13381071002886E2 /* libobjc.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 26F5C37410F3F61B009D5894 /* libobjc.dylib */; }; + 26B1FCBD13381071002886E2 /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C74CB6212288704006A8171 /* Carbon.framework */; }; + 26B1FCC21338115F002886E2 /* Host.mm in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7EE810F1B88F00F91463 /* Host.mm */; }; 26B42B1F1187A92B0079C8C8 /* lldb-include.h in Headers */ = {isa = PBXBuildFile; fileRef = 26B42B1E1187A92B0079C8C8 /* lldb-include.h */; settings = {ATTRIBUTES = (Public, ); }; }; 26B42C4D1187ABA50079C8C8 /* LLDB.h in Headers */ = {isa = PBXBuildFile; fileRef = 26B42C4C1187ABA50079C8C8 /* LLDB.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 26C557811325781D008FD8FE /* PlatformMacOSX.h in Headers */ = {isa = PBXBuildFile; fileRef = 26C5577C132575AD008FD8FE /* PlatformMacOSX.h */; }; 26C72C94124322890068DC16 /* SBStream.h in Headers */ = {isa = PBXBuildFile; fileRef = 26C72C93124322890068DC16 /* SBStream.h */; settings = {ATTRIBUTES = (Public, ); }; }; 26C72C961243229A0068DC16 /* SBStream.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26C72C951243229A0068DC16 /* SBStream.cpp */; }; - 26D5B0C211B07550009A862E /* Host.mm in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7EE810F1B88F00F91463 /* Host.mm */; }; - 26D5B10011B07550009A862E /* ProcessControl-mig.defs in Sources */ = {isa = PBXBuildFile; fileRef = 260C89A110F57C5600BB2B04 /* ProcessControl-mig.defs */; settings = {ATTRIBUTES = (Client, Server, ); }; }; - 26D9FDC712F784E60003F2EE /* EmulateInstruction.h in Headers */ = {isa = PBXBuildFile; fileRef = 26D9FDC612F784E60003F2EE /* EmulateInstruction.h */; }; - 26D9FDCF12F7853F0003F2EE /* EmulateInstructionARM.h in Headers */ = {isa = PBXBuildFile; fileRef = 26D9FDCD12F7853F0003F2EE /* EmulateInstructionARM.h */; }; + 26DC6A171337FE8000FF7998 /* liblldb-core.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 2689FFCA13353D7A00698AC0 /* liblldb-core.a */; }; + 26DC6A1D1337FECA00FF7998 /* lldb-platform.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26DC6A1C1337FECA00FF7998 /* lldb-platform.cpp */; }; 26DE1E6B11616C2E00A093E2 /* lldb-forward-rtti.h in Headers */ = {isa = PBXBuildFile; fileRef = 26DE1E6911616C2E00A093E2 /* lldb-forward-rtti.h */; settings = {ATTRIBUTES = (Public, ); }; }; 26DE1E6C11616C2E00A093E2 /* lldb-forward.h in Headers */ = {isa = PBXBuildFile; fileRef = 26DE1E6A11616C2E00A093E2 /* lldb-forward.h */; settings = {ATTRIBUTES = (Public, ); }; }; 26DE204111618AB900A093E2 /* SBSymbolContext.h in Headers */ = {isa = PBXBuildFile; fileRef = 26DE204011618AB900A093E2 /* SBSymbolContext.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -396,7 +386,6 @@ 26DE20611161902700A093E2 /* SBBlock.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26DE20601161902600A093E2 /* SBBlock.cpp */; }; 26DE20631161904200A093E2 /* SBLineEntry.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26DE20621161904200A093E2 /* SBLineEntry.cpp */; }; 26DE20651161904E00A093E2 /* SBSymbol.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26DE20641161904E00A093E2 /* SBSymbol.cpp */; }; - 26E6902F129C6BD500DDECD9 /* ClangExternalASTSourceCallbacks.h in Headers */ = {isa = PBXBuildFile; fileRef = 26E6902E129C6BD500DDECD9 /* ClangExternalASTSourceCallbacks.h */; }; 26F5C27710F3D9E4009D5894 /* Driver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26F5C27310F3D9E4009D5894 /* Driver.cpp */; }; 26F5C27810F3D9E4009D5894 /* IOChannel.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26F5C27510F3D9E4009D5894 /* IOChannel.cpp */; }; 26F5C32510F3DF23009D5894 /* libpython.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 26F5C32410F3DF23009D5894 /* libpython.dylib */; }; @@ -404,13 +393,7 @@ 26F5C32D10F3DFDD009D5894 /* libtermcap.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 26F5C32B10F3DFDD009D5894 /* libtermcap.dylib */; }; 26F5C37510F3F61B009D5894 /* libobjc.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 26F5C37410F3F61B009D5894 /* libobjc.dylib */; }; 26F5C39110F3FA26009D5894 /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 26F5C39010F3FA26009D5894 /* CoreFoundation.framework */; }; - 26FA4316130103F400E71120 /* FileSpec.h in Headers */ = {isa = PBXBuildFile; fileRef = 26FA4315130103F400E71120 /* FileSpec.h */; }; - 4C61978D12823D4300FAFFCC /* AppleObjCRuntime.h in Headers */ = {isa = PBXBuildFile; fileRef = 4C61978912823D4300FAFFCC /* AppleObjCRuntime.h */; }; - 4C61978F12823D4300FAFFCC /* AppleObjCRuntimeV1.h in Headers */ = {isa = PBXBuildFile; fileRef = 4C61978B12823D4300FAFFCC /* AppleObjCRuntimeV1.h */; }; - 4C626534130F1B0A00C889F6 /* StreamTee.h in Headers */ = {isa = PBXBuildFile; fileRef = 4C626533130F1B0A00C889F6 /* StreamTee.h */; }; 4C74CB6312288704006A8171 /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C74CB6212288704006A8171 /* Carbon.framework */; }; - 4C7CF7E41295E10E00B4FBB5 /* ThreadPlanCallUserExpression.h in Headers */ = {isa = PBXBuildFile; fileRef = 4C7CF7E31295E10E00B4FBB5 /* ThreadPlanCallUserExpression.h */; }; - 4CC2A14D128C7409001531C4 /* ThreadPlanTracer.h in Headers */ = {isa = PBXBuildFile; fileRef = 4CC2A14C128C7409001531C4 /* ThreadPlanTracer.h */; }; 9A19A6AF1163BBB200E0D453 /* SBValue.h in Headers */ = {isa = PBXBuildFile; fileRef = 9A19A6A51163BB7E00E0D453 /* SBValue.h */; settings = {ATTRIBUTES = (Public, ); }; }; 9A19A6B01163BBB300E0D453 /* SBValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A19A6AD1163BB9800E0D453 /* SBValue.cpp */; }; 9A357583116CFDEE00E8ED2F /* SBValueList.h in Headers */ = {isa = PBXBuildFile; fileRef = 9A357582116CFDEE00E8ED2F /* SBValueList.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -426,9 +409,6 @@ 9AC70390117675270086C050 /* SBInstructionList.h in Headers */ = {isa = PBXBuildFile; fileRef = 9AC7038F117675270086C050 /* SBInstructionList.h */; settings = {ATTRIBUTES = (Public, ); }; }; 9AC703AF117675410086C050 /* SBInstruction.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AC703AE117675410086C050 /* SBInstruction.cpp */; }; 9AC703B1117675490086C050 /* SBInstructionList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AC703B0117675490086C050 /* SBInstructionList.cpp */; }; - B23DD25012EDFAC1000C3894 /* ARMUtils.h in Headers */ = {isa = PBXBuildFile; fileRef = B23DD24F12EDFAC1000C3894 /* ARMUtils.h */; }; - B287E63F12EFAE2C00C9BEFE /* ARMDefines.h in Headers */ = {isa = PBXBuildFile; fileRef = B287E63E12EFAE2C00C9BEFE /* ARMDefines.h */; }; - B2D3033712EFA5C500F84EB3 /* InstructionUtils.h in Headers */ = {isa = PBXBuildFile; fileRef = B2D3033612EFA5C500F84EB3 /* InstructionUtils.h */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -474,6 +454,20 @@ remoteGlobalIDString = 26CE0593115C31C20022F371; remoteInfo = "lldb-debugserver"; }; + 26DC6A151337FE7300FF7998 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 08FB7793FE84155DC02AAC07 /* Project object */; + proxyType = 1; + remoteGlobalIDString = 2689FFC913353D7A00698AC0; + remoteInfo = "lldb-core"; + }; + 26DC6A201338008100FF7998 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 08FB7793FE84155DC02AAC07 /* Project object */; + proxyType = 1; + remoteGlobalIDString = 26DC6A0F1337FE6900FF7998; + remoteInfo = "lldb-platform"; + }; /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ @@ -950,6 +944,8 @@ 26D9FDCC12F7853F0003F2EE /* EmulateInstructionARM.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = EmulateInstructionARM.cpp; path = Instruction/ARM/EmulateInstructionARM.cpp; sourceTree = ""; }; 26D9FDCD12F7853F0003F2EE /* EmulateInstructionARM.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = EmulateInstructionARM.h; path = Instruction/ARM/EmulateInstructionARM.h; sourceTree = ""; }; 26DAFD9711529BC7005A394E /* ExecutionContextScope.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ExecutionContextScope.h; path = include/lldb/Target/ExecutionContextScope.h; sourceTree = ""; }; + 26DC6A101337FE6900FF7998 /* lldb-platform */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = "lldb-platform"; sourceTree = BUILT_PRODUCTS_DIR; }; + 26DC6A1C1337FECA00FF7998 /* lldb-platform.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = "lldb-platform.cpp"; path = "tools/lldb-platform/lldb-platform.cpp"; sourceTree = ""; }; 26DE1E6911616C2E00A093E2 /* lldb-forward-rtti.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "lldb-forward-rtti.h"; path = "include/lldb/lldb-forward-rtti.h"; sourceTree = ""; }; 26DE1E6A11616C2E00A093E2 /* lldb-forward.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "lldb-forward.h"; path = "include/lldb/lldb-forward.h"; sourceTree = ""; }; 26DE204011618AB900A093E2 /* SBSymbolContext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SBSymbolContext.h; path = include/lldb/API/SBSymbolContext.h; sourceTree = ""; }; @@ -1200,6 +1196,20 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 26DC6A0E1337FE6900FF7998 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 26DC6A171337FE8000FF7998 /* liblldb-core.a in Frameworks */, + 26B1FCB813381071002886E2 /* CoreFoundation.framework in Frameworks */, + 26B1FCB913381071002886E2 /* DebugSymbols.framework in Frameworks */, + 26B1FCBA13381071002886E2 /* Foundation.framework in Frameworks */, + 26B1FCBB13381071002886E2 /* libpython.dylib in Frameworks */, + 26B1FCBC13381071002886E2 /* libobjc.dylib in Frameworks */, + 26B1FCBD13381071002886E2 /* Carbon.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; 26F5C26810F3D9A4009D5894 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; @@ -1261,6 +1271,7 @@ 26F5C26A10F3D9A4009D5894 /* lldb */, 26680207115FD0ED008E1FE4 /* LLDB.framework */, 26579F68126A25920007C5CB /* darwin-debug */, + 26DC6A101337FE6900FF7998 /* lldb-platform */, ); name = Products; sourceTree = ""; @@ -2238,12 +2249,21 @@ name = ARM; sourceTree = ""; }; + 26DC6A1B1337FEA400FF7998 /* lldb-platform */ = { + isa = PBXGroup; + children = ( + 26DC6A1C1337FECA00FF7998 /* lldb-platform.cpp */, + ); + name = "lldb-platform"; + sourceTree = ""; + }; 26F5C22410F3D950009D5894 /* Tools */ = { isa = PBXGroup; children = ( 26579F55126A255E0007C5CB /* darwin-debug */, 265E9BE0115C2B8500D0DCCB /* debugserver */, 26F5C22510F3D956009D5894 /* Driver */, + 26DC6A1B1337FEA400FF7998 /* lldb-platform */, ); name = Tools; sourceTree = ""; @@ -2438,33 +2458,6 @@ 2617447A11685869005ADD65 /* SBType.h in Headers */, 9A19A6AF1163BBB200E0D453 /* SBValue.h in Headers */, 9A357583116CFDEE00E8ED2F /* SBValueList.h in Headers */, - 2635DA87127D0D0400675BC1 /* SharingPtr.h in Headers */, - 4C61978D12823D4300FAFFCC /* AppleObjCRuntime.h in Headers */, - 4C61978F12823D4300FAFFCC /* AppleObjCRuntimeV1.h in Headers */, - 4CC2A14D128C7409001531C4 /* ThreadPlanTracer.h in Headers */, - 266A42D8128E40040090CF7C /* ClangNamespaceDecl.h in Headers */, - 26E6902F129C6BD500DDECD9 /* ClangExternalASTSourceCallbacks.h in Headers */, - 4C7CF7E41295E10E00B4FBB5 /* ThreadPlanCallUserExpression.h in Headers */, - B23DD25012EDFAC1000C3894 /* ARMUtils.h in Headers */, - B2D3033712EFA5C500F84EB3 /* InstructionUtils.h in Headers */, - B287E63F12EFAE2C00C9BEFE /* ARMDefines.h in Headers */, - 26D9FDC712F784E60003F2EE /* EmulateInstruction.h in Headers */, - 26D9FDCF12F7853F0003F2EE /* EmulateInstructionARM.h in Headers */, - 266F5CBC12FC846200DFCE33 /* Config.h in Headers */, - 268DA872130095D000C9483A /* Terminal.h in Headers */, - 26FA4316130103F400E71120 /* FileSpec.h in Headers */, - 260C6EA113011578005E16B0 /* File.h in Headers */, - 4C626534130F1B0A00C889F6 /* StreamTee.h in Headers */, - 2618EE661315B29C001D6D71 /* GDBRemoteCommunication.h in Headers */, - 2618EE681315B29C001D6D71 /* GDBRemoteRegisterContext.h in Headers */, - 2618EE6A1315B29C001D6D71 /* ProcessGDBRemote.h in Headers */, - 2618EE6C1315B29C001D6D71 /* ProcessGDBRemoteLog.h in Headers */, - 2618EE6E1315B29C001D6D71 /* ThreadGDBRemote.h in Headers */, - 264A43BC1320B3B4005B4096 /* Platform.h in Headers */, - 268A68401321B53B000E3FB8 /* DynamicLoaderStatic.h in Headers */, - 26C557811325781D008FD8FE /* PlatformMacOSX.h in Headers */, - 2675F7011332BE690067997B /* PlatformRemoteiOS.h in Headers */, - 26879CE61333F5750012C1F8 /* CommandObjectPlatform.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -2516,6 +2509,7 @@ isa = PBXNativeTarget; buildConfigurationList = 2668020B115FD0EE008E1FE4 /* Build configuration list for PBXNativeTarget "LLDB" */; buildPhases = ( + 26DC6A5813380D4300FF7998 /* Build swig wrapper classes */, 26680202115FD0ED008E1FE4 /* Headers */, 26680203115FD0ED008E1FE4 /* Resources */, 26680204115FD0ED008E1FE4 /* Sources */, @@ -2540,7 +2534,6 @@ buildConfigurationList = 2689FFD813353D7A00698AC0 /* Build configuration list for PBXNativeTarget "lldb-core" */; buildPhases = ( 261EECA21337D399001D193C /* Build llvm and clang */, - 261EECA41337D4BB001D193C /* Build swig wrapper classes */, 2689FFC613353D7A00698AC0 /* Sources */, 2689FFC713353D7A00698AC0 /* Frameworks */, 2689FFC813353D7A00698AC0 /* Headers */, @@ -2554,6 +2547,23 @@ productReference = 2689FFCA13353D7A00698AC0 /* liblldb-core.a */; productType = "com.apple.product-type.library.dynamic"; }; + 26DC6A0F1337FE6900FF7998 /* lldb-platform */ = { + isa = PBXNativeTarget; + buildConfigurationList = 26DC6A1A1337FE8B00FF7998 /* Build configuration list for PBXNativeTarget "lldb-platform" */; + buildPhases = ( + 26DC6A0D1337FE6900FF7998 /* Sources */, + 26DC6A0E1337FE6900FF7998 /* Frameworks */, + ); + buildRules = ( + ); + dependencies = ( + 26DC6A161337FE7300FF7998 /* PBXTargetDependency */, + ); + name = "lldb-platform"; + productName = "lldb-platform"; + productReference = 26DC6A101337FE6900FF7998 /* lldb-platform */; + productType = "com.apple.product-type.tool"; + }; 26F5C26910F3D9A4009D5894 /* lldb-tool */ = { isa = PBXNativeTarget; buildConfigurationList = 26F5C26E10F3D9C5009D5894 /* Build configuration list for PBXNativeTarget "lldb-tool" */; @@ -2566,6 +2576,7 @@ dependencies = ( 26CE0610115C438C0022F371 /* PBXTargetDependency */, 266803621160110D008E1FE4 /* PBXTargetDependency */, + 26DC6A211338008100FF7998 /* PBXTargetDependency */, ); name = "lldb-tool"; productName = lldb; @@ -2598,6 +2609,7 @@ 26680206115FD0ED008E1FE4 /* LLDB */, 26579F67126A25920007C5CB /* darwin-debug */, 2689FFC913353D7A00698AC0 /* lldb-core */, + 26DC6A0F1337FE6900FF7998 /* lldb-platform */, ); }; /* End PBXProject section */ @@ -2657,7 +2669,7 @@ shellPath = /bin/sh; shellScript = "perl $SRCROOT/scripts/build-llvm.pl"; }; - 261EECA41337D4BB001D193C /* Build swig wrapper classes */ = { + 26DC6A5813380D4300FF7998 /* Build swig wrapper classes */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( @@ -2706,8 +2718,6 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 26D5B0C211B07550009A862E /* Host.mm in Sources */, - 26D5B10011B07550009A862E /* ProcessControl-mig.defs in Sources */, 26680324116005D9008E1FE4 /* SBThread.cpp in Sources */, 26680326116005DB008E1FE4 /* SBTarget.cpp in Sources */, 26680327116005DC008E1FE4 /* SBSourceManager.cpp in Sources */, @@ -2742,6 +2752,7 @@ 9AA69DB1118A024600D753A0 /* SBInputReader.cpp in Sources */, 268F9D55123AA16600B91E9B /* SBSymbolContextList.cpp in Sources */, 26C72C961243229A0068DC16 /* SBStream.cpp in Sources */, + 26B1FA1413380E61002886E2 /* LLDBWrapPython.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -2877,7 +2888,6 @@ 2689007B13353E1A00698AC0 /* CFCString.cpp in Sources */, 2689007C13353E1A00698AC0 /* Symbols.cpp in Sources */, 2689007D13353E2200698AC0 /* Args.cpp in Sources */, - 2689007E13353E2200698AC0 /* LLDBWrapPython.cpp in Sources */, 2689007F13353E2200698AC0 /* CommandCompletions.cpp in Sources */, 2689008013353E2200698AC0 /* CommandInterpreter.cpp in Sources */, 2689008113353E2200698AC0 /* CommandObject.cpp in Sources */, @@ -3027,6 +3037,15 @@ 2689011113353E8200698AC0 /* StringExtractor.cpp in Sources */, 2689011213353E8200698AC0 /* StringExtractorGDBRemote.cpp in Sources */, 2689011313353E8200698AC0 /* PseudoTerminal.cpp in Sources */, + 26B1FCC21338115F002886E2 /* Host.mm in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 26DC6A0D1337FE6900FF7998 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 26DC6A1D1337FECA00FF7998 /* lldb-platform.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -3068,6 +3087,16 @@ name = "lldb-debugserver"; targetProxy = 26CE060F115C438C0022F371 /* PBXContainerItemProxy */; }; + 26DC6A161337FE7300FF7998 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 2689FFC913353D7A00698AC0 /* lldb-core */; + targetProxy = 26DC6A151337FE7300FF7998 /* PBXContainerItemProxy */; + }; + 26DC6A211338008100FF7998 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 26DC6A0F1337FE6900FF7998 /* lldb-platform */; + targetProxy = 26DC6A201338008100FF7998 /* PBXContainerItemProxy */; + }; /* End PBXTargetDependency section */ /* Begin XCBuildConfiguration section */ @@ -3211,7 +3240,7 @@ "$(LLVM_BUILD_DIR)", ); LLVM_BUILD_DIR = "$(SRCROOT)/llvm"; - LLVM_CONFIGURATION = "Debug+Asserts"; + LLVM_CONFIGURATION = Release; OTHER_CFLAGS = "-Wparentheses"; OTHER_CPLUSPLUSFLAGS = ( "-fno-rtti", @@ -3219,7 +3248,6 @@ "$(OTHER_CFLAGS)", ); OTHER_LDFLAGS = ( - "-lllvmclang", "-framework", Foundation, "-framework", @@ -3264,7 +3292,7 @@ "$(LLVM_BUILD_DIR)", ); LLVM_BUILD_DIR = "$(SRCROOT)/llvm"; - LLVM_CONFIGURATION = "Debug+Asserts"; + LLVM_CONFIGURATION = Release; OTHER_CFLAGS = "-Wparentheses"; OTHER_CPLUSPLUSFLAGS = ( "-fno-rtti", @@ -3272,7 +3300,6 @@ "$(OTHER_CFLAGS)", ); OTHER_LDFLAGS = ( - "-lllvmclang", "-framework", Foundation, "-framework", @@ -3291,6 +3318,8 @@ buildSettings = { ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; COPY_PHASE_STRIP = NO; + CURRENT_PROJECT_VERSION = 46; + DYLIB_CURRENT_VERSION = 46; EXECUTABLE_EXTENSION = a; GCC_ENABLE_OBJC_GC = supported; GCC_INLINES_ARE_PRIVATE_EXTERN = NO; @@ -3299,7 +3328,11 @@ __STDC_LIMIT_MACROS, LLDB_CONFIGURATION_DEBUG, ); - LD_DYLIB_INSTALL_NAME = "$(DYLIB_INSTALL_NAME_BASE:standardizepath)/lldb-core.a"; + LD_DYLIB_INSTALL_NAME = "/Developer/Library/PrivateFrameworks/LLDB.framework/Resources/lldb-core.a"; + LIBRARY_SEARCH_PATHS = ( + "$(inherited)", + "$(LLVM_BUILD_DIR)", + ); LLVM_BUILD_DIR = "$(SRCROOT)/llvm"; LLVM_CONFIGURATION = Release; MACH_O_TYPE = staticlib; @@ -3310,10 +3343,12 @@ "-Wglobal-constructors", "$(OTHER_CFLAGS)", ); + OTHER_LDFLAGS = "-lllvmclang"; PRODUCT_NAME = "lib$(TARGET_NAME)"; SDKROOT = macosx; STANDARD_C_PLUS_PLUS_LIBRARY_TYPE = static; USER_HEADER_SEARCH_PATHS = "$(SRCROOT)/source $(SRCROOT)/source/Plugins/Process/Utility $(SRCROOT)/include $(SRCROOT)/source/Host/macosx/cfcpp $(SRCROOT)/llvm/include $(SRCROOT)/llvm/tools/clang/include $(LLVM_BUILD_DIR)/llvm/include $(LLVM_BUILD_DIR)/llvm/tools/clang/include"; + VERSIONING_SYSTEM = "apple-generic"; }; name = Debug; }; @@ -3322,7 +3357,9 @@ buildSettings = { ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; COPY_PHASE_STRIP = YES; + CURRENT_PROJECT_VERSION = 46; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + DYLIB_CURRENT_VERSION = 46; EXECUTABLE_EXTENSION = a; GCC_ENABLE_OBJC_GC = supported; GCC_INLINES_ARE_PRIVATE_EXTERN = NO; @@ -3331,7 +3368,12 @@ __STDC_LIMIT_MACROS, LLDB_CONFIGURATION_RELEASE, ); - LD_DYLIB_INSTALL_NAME = "$(DYLIB_INSTALL_NAME_BASE:standardizepath)/lldb-core.a"; + LD_DYLIB_INSTALL_NAME = "/Developer/Library/PrivateFrameworks/LLDB.framework/Resources/lldb-core.a"; + LIBRARY_SEARCH_PATHS = ( + "$(inherited)", + "$(LLVM_BUILD_DIR)", + ); + LLVM_BUILD_DIR = "$(SRCROOT)/llvm"; LLVM_CONFIGURATION = Release; MACH_O_TYPE = staticlib; MACOSX_DEPLOYMENT_TARGET = 10.6; @@ -3341,10 +3383,12 @@ "-Wglobal-constructors", "$(OTHER_CFLAGS)", ); + OTHER_LDFLAGS = "-lllvmclang"; PRODUCT_NAME = "lib$(TARGET_NAME)"; SDKROOT = macosx; STANDARD_C_PLUS_PLUS_LIBRARY_TYPE = static; USER_HEADER_SEARCH_PATHS = "$(SRCROOT)/source $(SRCROOT)/source/Plugins/Process/Utility $(SRCROOT)/include $(SRCROOT)/source/Host/macosx/cfcpp $(SRCROOT)/llvm/include $(SRCROOT)/llvm/tools/clang/include $(LLVM_BUILD_DIR)/llvm/include $(LLVM_BUILD_DIR)/llvm/tools/clang/include"; + VERSIONING_SYSTEM = "apple-generic"; }; name = Release; }; @@ -3353,7 +3397,9 @@ buildSettings = { ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; COPY_PHASE_STRIP = YES; + CURRENT_PROJECT_VERSION = 46; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + DYLIB_CURRENT_VERSION = 46; EXECUTABLE_EXTENSION = a; GCC_ENABLE_OBJC_GC = supported; GCC_INLINES_ARE_PRIVATE_EXTERN = NO; @@ -3362,7 +3408,12 @@ __STDC_LIMIT_MACROS, LLDB_CONFIGURATION_BUILD_AND_INTEGRATION, ); - LD_DYLIB_INSTALL_NAME = "$(DYLIB_INSTALL_NAME_BASE:standardizepath)/lldb-core.a"; + LD_DYLIB_INSTALL_NAME = "/Developer/Library/PrivateFrameworks/LLDB.framework/Resources/lldb-core.a"; + LIBRARY_SEARCH_PATHS = ( + "$(inherited)", + "$(LLVM_BUILD_DIR)", + ); + LLVM_BUILD_DIR = "$(DERIVED_FILE_DIR)/llvm.build"; LLVM_CONFIGURATION = Release; MACH_O_TYPE = staticlib; MACOSX_DEPLOYMENT_TARGET = 10.6; @@ -3372,10 +3423,12 @@ "-Wglobal-constructors", "$(OTHER_CFLAGS)", ); + OTHER_LDFLAGS = "-lllvmclang"; PRODUCT_NAME = "lib$(TARGET_NAME)"; SDKROOT = macosx; STANDARD_C_PLUS_PLUS_LIBRARY_TYPE = static; USER_HEADER_SEARCH_PATHS = "$(SRCROOT)/source $(SRCROOT)/source/Plugins/Process/Utility $(SRCROOT)/include $(SRCROOT)/source/Host/macosx/cfcpp $(SRCROOT)/llvm/include $(SRCROOT)/llvm/tools/clang/include $(LLVM_BUILD_DIR)/llvm/include $(LLVM_BUILD_DIR)/llvm/tools/clang/include"; + VERSIONING_SYSTEM = "apple-generic"; }; name = BuildAndIntegration; }; @@ -3475,7 +3528,7 @@ "$(LLVM_BUILD_DIR)", ); LLVM_BUILD_DIR = "$(DERIVED_FILE_DIR)/llvm.build"; - LLVM_CONFIGURATION = "Debug+Asserts"; + LLVM_CONFIGURATION = Release; OTHER_CFLAGS = "-Wparentheses"; OTHER_CPLUSPLUSFLAGS = ( "-fno-rtti", @@ -3483,7 +3536,6 @@ "$(OTHER_CFLAGS)", ); OTHER_LDFLAGS = ( - "-lllvmclang", "-framework", Foundation, "-framework", @@ -3497,6 +3549,78 @@ }; name = BuildAndIntegration; }; + 26DC6A121337FE6A00FF7998 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + COPY_PHASE_STRIP = NO; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "\"$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks\"", + ); + GCC_DYNAMIC_NO_PIC = NO; + GCC_ENABLE_CPP_RTTI = NO; + GCC_MODEL_TUNING = G5; + GCC_OPTIMIZATION_LEVEL = 0; + INSTALL_PATH = /usr/local/bin; + OTHER_LDFLAGS = ( + "-framework", + Foundation, + "-framework", + AppKit, + ); + PREBINDING = NO; + PRODUCT_NAME = "lldb-platform"; + USER_HEADER_SEARCH_PATHS = "$(SRCROOT)/include $(SRCROOT)/llvm/include $(SRCROOT)/llvm/tools/clang/include $(LLVM_BUILD_DIR)/llvm/include $(LLVM_BUILD_DIR)/llvm/tools/clang/include $(SRCROOT)/source/Plugins/Process/gdb-remote $(SRCROOT)/source"; + }; + name = Debug; + }; + 26DC6A131337FE6A00FF7998 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + COPY_PHASE_STRIP = YES; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "\"$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks\"", + ); + GCC_ENABLE_CPP_RTTI = NO; + GCC_MODEL_TUNING = G5; + INSTALL_PATH = /usr/local/bin; + OTHER_LDFLAGS = ( + "-framework", + Foundation, + "-framework", + AppKit, + ); + PREBINDING = NO; + PRODUCT_NAME = "lldb-platform"; + USER_HEADER_SEARCH_PATHS = "$(SRCROOT)/include $(SRCROOT)/llvm/include $(SRCROOT)/llvm/tools/clang/include $(LLVM_BUILD_DIR)/llvm/include $(LLVM_BUILD_DIR)/llvm/tools/clang/include $(SRCROOT)/source/Plugins/Process/gdb-remote $(SRCROOT)/source"; + ZERO_LINK = NO; + }; + name = Release; + }; + 26DC6A141337FE6A00FF7998 /* BuildAndIntegration */ = { + isa = XCBuildConfiguration; + buildSettings = { + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "\"$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks\"", + ); + GCC_ENABLE_CPP_RTTI = NO; + GCC_MODEL_TUNING = G5; + INSTALL_PATH = /usr/local/bin; + OTHER_LDFLAGS = ( + "-framework", + Foundation, + "-framework", + AppKit, + ); + PREBINDING = NO; + PRODUCT_NAME = "lldb-platform"; + USER_HEADER_SEARCH_PATHS = "$(SRCROOT)/include $(SRCROOT)/llvm/include $(SRCROOT)/llvm/tools/clang/include $(LLVM_BUILD_DIR)/llvm/include $(LLVM_BUILD_DIR)/llvm/tools/clang/include $(SRCROOT)/source/Plugins/Process/gdb-remote $(SRCROOT)/source"; + }; + name = BuildAndIntegration; + }; 26F5C26C10F3D9A5009D5894 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { @@ -3614,6 +3738,16 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = BuildAndIntegration; }; + 26DC6A1A1337FE8B00FF7998 /* Build configuration list for PBXNativeTarget "lldb-platform" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 26DC6A121337FE6A00FF7998 /* Debug */, + 26DC6A131337FE6A00FF7998 /* Release */, + 26DC6A141337FE6A00FF7998 /* BuildAndIntegration */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = BuildAndIntegration; + }; 26F5C26E10F3D9C5009D5894 /* Build configuration list for PBXNativeTarget "lldb-tool" */ = { isa = XCConfigurationList; buildConfigurations = ( Modified: lldb/trunk/scripts/lldb.swig URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/lldb.swig?rev=128053&r1=128052&r2=128053&view=diff ============================================================================== --- lldb/trunk/scripts/lldb.swig (original) +++ lldb/trunk/scripts/lldb.swig Mon Mar 21 20:14:58 2011 @@ -205,14 +205,17 @@ // and is used when a script command is attached to a breakpoint for execution. SWIGEXPORT bool -LLDBSWIGPythonBreakpointCallbackFunction +LLDBSwigPythonBreakpointCallbackFunction ( const char *python_function_name, const char *session_dictionary_name, - lldb::SBFrame& sb_frame, - lldb::SBBreakpointLocation& sb_bp_loc + const lldb::StackFrameSP& frame_sp, + const lldb::BreakpointLocationSP& bp_loc_sp ) { + lldb::SBFrame sb_frame (frame_sp); + lldb::SBBreakpointLocation sb_bp_loc(bp_loc_sp); + bool stop_at_breakpoint = true; PyObject *Frame_PyObj = SWIG_NewPointerObj((void *) &sb_frame, SWIGTYPE_p_lldb__SBFrame, 0); PyObject *Bp_Loc_PyObj = SWIG_NewPointerObj ((void *) &sb_bp_loc, SWIGTYPE_p_lldb__SBBreakpointLocation, 0); Modified: lldb/trunk/source/API/SBCommandInterpreter.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBCommandInterpreter.cpp?rev=128053&r1=128052&r2=128053&view=diff ============================================================================== --- lldb/trunk/source/API/SBCommandInterpreter.cpp (original) +++ lldb/trunk/source/API/SBCommandInterpreter.cpp Mon Mar 21 20:14:58 2011 @@ -305,4 +305,25 @@ } +extern "C" bool +LLDBSwigPythonBreakpointCallbackFunction +( + const char *python_function_name, + const char *session_dictionary_name, + const lldb::StackFrameSP& sb_frame, + const lldb::BreakpointLocationSP& sb_bp_loc +); +extern "C" void init_lldb(void); + +void +SBCommandInterpreter::InitializeSWIG () +{ + static bool g_initialized = false; + if (!g_initialized) + { + g_initialized = true; + ScriptInterpreter::InitializeInterpreter (init_lldb, + LLDBSwigPythonBreakpointCallbackFunction); + } +} Modified: lldb/trunk/source/API/SBDebugger.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBDebugger.cpp?rev=128053&r1=128052&r2=128053&view=diff ============================================================================== --- lldb/trunk/source/API/SBDebugger.cpp (original) +++ lldb/trunk/source/API/SBDebugger.cpp Mon Mar 21 20:14:58 2011 @@ -42,6 +42,8 @@ if (log) log->Printf ("SBDebugger::Initialize ()"); + SBCommandInterpreter::InitializeSWIG (); + Debugger::Initialize(); } Modified: lldb/trunk/source/Interpreter/ScriptInterpreter.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/ScriptInterpreter.cpp?rev=128053&r1=128052&r2=128053&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/ScriptInterpreter.cpp (original) +++ lldb/trunk/source/Interpreter/ScriptInterpreter.cpp Mon Mar 21 20:14:58 2011 @@ -91,14 +91,16 @@ } void -ScriptInterpreter::Initialize () +ScriptInterpreter::InitializeInterpreter (SWIGInitCallback python_swig_init_callback, + SWIGBreakpointCallbackFunction python_swig_breakpoint_callback) { -// ScriptInterpreterPython::Initialize (); + ScriptInterpreterPython::InitializeInterpreter (python_swig_init_callback, + python_swig_breakpoint_callback); } void -ScriptInterpreter::Terminate () +ScriptInterpreter::TerminateInterpreter () { -// ScriptInterpreterPython::Terminate (); + ScriptInterpreterPython::TerminateInterpreter (); } Modified: lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp?rev=128053&r1=128052&r2=128053&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp (original) +++ lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp Mon Mar 21 20:14:58 2011 @@ -28,22 +28,13 @@ #include "lldb/Interpreter/CommandReturnObject.h" #include "lldb/Target/Thread.h" -// This function is in the C++ output file generated by SWIG after it is -// run on all of the headers in "lldb/API/SB*.h" -extern "C" void init_lldb (void); - -extern "C" bool -LLDBSWIGPythonBreakpointCallbackFunction -( - const char *python_function_name, - const char *session_dictionary_name, - lldb::SBFrame& sb_frame, - lldb::SBBreakpointLocation& sb_bp_loc -); - using namespace lldb; using namespace lldb_private; + +static ScriptInterpreter::SWIGInitCallback g_swig_init_callback = NULL; +static ScriptInterpreter::SWIGBreakpointCallbackFunction g_swig_breakpoint_callback = NULL; + const char embedded_interpreter_string[] = "import readline\n\ import code\n\ @@ -212,7 +203,7 @@ if (!g_initialized) { g_initialized = true; - ScriptInterpreterPython::Initialize (); + ScriptInterpreterPython::InitializePrivate (); } bool safe_to_run = false; @@ -1288,38 +1279,40 @@ && python_function_name[0] != '\0') { Thread *thread = context->exe_ctx.thread; - const StackFrameSP stop_frame_sp = thread->GetStackFrameSPForStackFramePtr (context->exe_ctx.frame); + const StackFrameSP stop_frame_sp (thread->GetStackFrameSPForStackFramePtr (context->exe_ctx.frame)); BreakpointSP breakpoint_sp = target->GetBreakpointByID (break_id); - const BreakpointLocationSP bp_loc_sp = breakpoint_sp->FindLocationByID (break_loc_id); - - SBFrame sb_frame (stop_frame_sp); - SBBreakpointLocation sb_bp_loc (bp_loc_sp); - - if (sb_bp_loc.IsValid() || sb_frame.IsValid()) + if (breakpoint_sp) { - bool ret_val = true; - FILE *tmp_fh = (python_interpreter->m_dbg_stdout ? python_interpreter->m_dbg_stdout : stdout); - if (CurrentThreadHasPythonLock()) - { - python_interpreter->EnterSession (); - ret_val = LLDBSWIGPythonBreakpointCallbackFunction(python_function_name, - python_interpreter->m_dictionary_name.c_str(), - sb_frame, sb_bp_loc); - python_interpreter->LeaveSession (); - } - else + const BreakpointLocationSP bp_loc_sp (breakpoint_sp->FindLocationByID (break_loc_id)); + + if (stop_frame_sp && bp_loc_sp) { - while (!GetPythonLock (1)) - fprintf (tmp_fh, - "Python interpreter locked on another thread; waiting to acquire lock...\n"); - python_interpreter->EnterSession (); - ret_val = LLDBSWIGPythonBreakpointCallbackFunction(python_function_name, - python_interpreter->m_dictionary_name.c_str(), - sb_frame, sb_bp_loc); - python_interpreter->LeaveSession (); - ReleasePythonLock (); + bool ret_val = true; + FILE *tmp_fh = (python_interpreter->m_dbg_stdout ? python_interpreter->m_dbg_stdout : stdout); + if (CurrentThreadHasPythonLock()) + { + python_interpreter->EnterSession (); + ret_val = g_swig_breakpoint_callback (python_function_name, + python_interpreter->m_dictionary_name.c_str(), + stop_frame_sp, + bp_loc_sp); + python_interpreter->LeaveSession (); + } + else + { + while (!GetPythonLock (1)) + fprintf (tmp_fh, + "Python interpreter locked on another thread; waiting to acquire lock...\n"); + python_interpreter->EnterSession (); + ret_val = g_swig_breakpoint_callback (python_function_name, + python_interpreter->m_dictionary_name.c_str(), + stop_frame_sp, + bp_loc_sp); + python_interpreter->LeaveSession (); + ReleasePythonLock (); + } + return ret_val; } - return ret_val; } } // We currently always true so we stop in case anything goes wrong when @@ -1447,7 +1440,15 @@ void -ScriptInterpreterPython::Initialize () +ScriptInterpreterPython::InitializeInterpreter (SWIGInitCallback python_swig_init_callback, + SWIGBreakpointCallbackFunction python_swig_breakpoint_callback) +{ + g_swig_init_callback = python_swig_init_callback; + g_swig_breakpoint_callback = python_swig_breakpoint_callback; +} + +void +ScriptInterpreterPython::InitializePrivate () { Timer scoped_timer (__PRETTY_FUNCTION__, __PRETTY_FUNCTION__); @@ -1506,9 +1507,9 @@ } - // This function is in the C++ output file generated by SWIG after it is - // run on all of the headers in "lldb/API/SB*.h" - init_lldb (); + // Initialize SWIG after setting up python + assert (g_swig_init_callback != NULL); + g_swig_init_callback (); // Update the path python uses to search for modules to include the current directory. @@ -1536,20 +1537,20 @@ stdin_tty_state.Restore(); } -void -ScriptInterpreterPython::Terminate () -{ - // We are intentionally NOT calling Py_Finalize here (this would be the logical place to call it). Calling - // Py_Finalize here causes test suite runs to seg fault: The test suite runs in Python. It registers - // SBDebugger::Terminate to be called 'at_exit'. When the test suite Python harness finishes up, it calls - // Py_Finalize, which calls all the 'at_exit' registered functions. SBDebugger::Terminate calls Debugger::Terminate, - // which calls lldb::Terminate, which calls ScriptInterpreter::Terminate, which calls - // ScriptInterpreterPython::Terminate. So if we call Py_Finalize here, we end up with Py_Finalize being called from - // within Py_Finalize, which results in a seg fault. - // - // Since this function only gets called when lldb is shutting down and going away anyway, the fact that we don't - // actually call Py_Finalize should not cause any problems (everything should shut down/go away anyway when the - // process exits). - // -// Py_Finalize (); -} +//void +//ScriptInterpreterPython::Terminate () +//{ +// // We are intentionally NOT calling Py_Finalize here (this would be the logical place to call it). Calling +// // Py_Finalize here causes test suite runs to seg fault: The test suite runs in Python. It registers +// // SBDebugger::Terminate to be called 'at_exit'. When the test suite Python harness finishes up, it calls +// // Py_Finalize, which calls all the 'at_exit' registered functions. SBDebugger::Terminate calls Debugger::Terminate, +// // which calls lldb::Terminate, which calls ScriptInterpreter::Terminate, which calls +// // ScriptInterpreterPython::Terminate. So if we call Py_Finalize here, we end up with Py_Finalize being called from +// // within Py_Finalize, which results in a seg fault. +// // +// // Since this function only gets called when lldb is shutting down and going away anyway, the fact that we don't +// // actually call Py_Finalize should not cause any problems (everything should shut down/go away anyway when the +// // process exits). +// // +//// Py_Finalize (); +//} Modified: lldb/trunk/source/lldb.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/lldb.cpp?rev=128053&r1=128052&r2=128053&view=diff ============================================================================== --- lldb/trunk/source/lldb.cpp (original) +++ lldb/trunk/source/lldb.cpp Mon Mar 21 20:14:58 2011 @@ -17,7 +17,6 @@ #include "lldb/Core/Timer.h" #include "lldb/Host/Host.h" #include "lldb/Host/Mutex.h" -#include "lldb/Interpreter/ScriptInterpreter.h" #include "lldb/Target/Target.h" #include "lldb/Target/Thread.h" @@ -85,7 +84,6 @@ ArchDefaultUnwindPlan_x86_64::Initialize(); ArchDefaultUnwindPlan_i386::Initialize(); ArchVolatileRegs_x86::Initialize(); - ScriptInterpreter::Initialize (); #if defined (__APPLE__) ABIMacOSX_i386::Initialize(); @@ -142,7 +140,6 @@ ArchDefaultUnwindPlan_i386::Terminate(); ArchDefaultUnwindPlan_x86_64::Terminate(); ArchVolatileRegs_x86::Terminate(); - ScriptInterpreter::Terminate (); #if defined (__APPLE__) DynamicLoaderMacOSXDYLD::Terminate(); @@ -172,13 +169,13 @@ Log::Terminate(); } -extern "C" const double LLDBVersionNumber; +extern "C" const double liblldb_coreVersionNumber; const char * lldb_private::GetVersion () { static char g_version_string[32]; if (g_version_string[0] == '\0') - ::snprintf (g_version_string, sizeof(g_version_string), "LLDB-%g", LLDBVersionNumber); + ::snprintf (g_version_string, sizeof(g_version_string), "LLDB-%g", liblldb_coreVersionNumber); return g_version_string; } Modified: lldb/trunk/test/abbreviation_tests/TestAbbreviations.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/abbreviation_tests/TestAbbreviations.py?rev=128053&r1=128052&r2=128053&view=diff ============================================================================== --- lldb/trunk/test/abbreviation_tests/TestAbbreviations.py (original) +++ lldb/trunk/test/abbreviation_tests/TestAbbreviations.py Mon Mar 21 20:14:58 2011 @@ -47,7 +47,7 @@ self.expect("lo li", - startstr = "Logging categories for 'lldb':") + startstr = "Logging categories for ") self.runCmd("se se prompt Sycamore> ") self.expect("se sh prompt", Modified: lldb/trunk/tools/debugserver/source/RNBRemote.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/RNBRemote.cpp?rev=128053&r1=128052&r2=128053&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/source/RNBRemote.cpp (original) +++ lldb/trunk/tools/debugserver/source/RNBRemote.cpp Mon Mar 21 20:14:58 2011 @@ -3351,78 +3351,6 @@ strm << "ptrsize:" << std::dec << sizeof(void *) << ';'; return SendPacket (strm.str()); } -// -//struct ProcessInfo -//{ -// nub_process_t pid; -// std::string name; -// std::string user; -// std::string group; -// uint32_t cpu; // mach-o cpu type -// uint32_t sub; // mach-o cpu subtype -// -// void -// Clear() -// { -// pid = 0; -// name.clear(); -// user.clear(); -// group.clear(); -// cpu = 0; -// sub = 0; -// } -//}; -// -//static bool -//GetMacOSXProcessName (ProcessInfo &proc_info, -// const char *name_match) // can be NULL -//{ -// char process_name[MAXCOMLEN * 2 + 1]; -// int name_len = ::proc_name(proc_info.pid, process_name, MAXCOMLEN * 2); -// if (name_len == 0) -// return false; -// -// if (name_match == NULL || strcmp (name_match, process_name) == 0) -// { -// proc_info.name.assign (process_name, name_len); -// return true; -// } -// proc_info.name.clear(); -// return false; -//} -// -// -//static bool -//GetMacOSXProcessCPUType (ProcessInfo &proc_info) -//{ -// // Make a new mib to stay thread safe -// int mib[CTL_MAXNAME]={0,}; -// size_t mib_len = CTL_MAXNAME; -// if (::sysctlnametomib("sysctl.proc_cputype", mib, &mib_len)) -// return false; -// -// mib[mib_len] = proc_info.pid; -// mib_len++; -// -// cpu_type_t cpu = 0; -// cpu_type_t sub = 0; -// size_t cpu_len = sizeof(cpu); -// if (::sysctl (mib, mib_len, &cpu, &cpu_len, 0, 0) == 0) -// { -// switch (cpu) -// { -// case llvm::MachO::CPUTypeI386: sub = llvm::MachO::CPUSubType_I386_ALL; break; -// case llvm::MachO::CPUTypeX86_64: sub = llvm::MachO::CPUSubType_X86_64_ALL; break; -// default: break; -// } -// proc_info.cpu = cpu; -// proc_info.sub = sub; -// return true; -// } -// proc_info.cpu = 0; -// proc_info.sub = 0; -// return false; -//} rnb_err_t RNBRemote::HandlePacket_qProcessInfo (const char *p) From gclayton at apple.com Mon Mar 21 20:20:27 2011 From: gclayton at apple.com (Greg Clayton) Date: Mon, 21 Mar 2011 18:20:27 -0700 Subject: [Lldb-commits] [lldb] r128023 - in /lldb/trunk: include/lldb/Target/Process.h source/Host/common/Host.cpp source/Host/macosx/Host.mm In-Reply-To: <20110321214500.GA16951@fibrous.localdomain> References: <20110321212507.F109F2A6C12C@llvm.org> <20110321214500.GA16951@fibrous.localdomain> Message-ID: <3B030B8F-3B2E-446E-915D-92EB97CD75A5@apple.com> On Mar 21, 2011, at 2:45 PM, Stephen Wilson wrote: > On Mon, Mar 21, 2011 at 09:25:07PM -0000, Greg Clayton wrote: >> Author: gclayton >> Date: Mon Mar 21 16:25:07 2011 >> New Revision: 128023 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=128023&view=rev >> Log: >> Added real user/group id, effective user/group id, and parent >> process ID to the ProcessInfo. >> >> >> Modified: >> lldb/trunk/include/lldb/Target/Process.h >> lldb/trunk/source/Host/common/Host.cpp >> lldb/trunk/source/Host/macosx/Host.mm > > Hi Greg, > > I was just looking at some of this Host stuff too. I need to add some > more linux specific code (GetOSVersion) and it does not make sense to > put that under common/. I can start moving some of the other linux > specific code out of the way too. Any objections to creating a > Host/linux subdirectory? No please do. I have abtracted more of the MacOSX specific Host calls over into Host.mm so it should clean up the common file a bit. From gclayton at apple.com Mon Mar 21 20:34:45 2011 From: gclayton at apple.com (Greg Clayton) Date: Tue, 22 Mar 2011 01:34:45 -0000 Subject: [Lldb-commits] [lldb] r128061 - in /lldb/trunk/tools/lldb-platform: ./ lldb-platform.cpp Message-ID: <20110322013445.262152A6C12C@llvm.org> Author: gclayton Date: Mon Mar 21 20:34:44 2011 New Revision: 128061 URL: http://llvm.org/viewvc/llvm-project?rev=128061&view=rev Log: Added missing files. Added: lldb/trunk/tools/lldb-platform/ lldb/trunk/tools/lldb-platform/lldb-platform.cpp Added: lldb/trunk/tools/lldb-platform/lldb-platform.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-platform/lldb-platform.cpp?rev=128061&view=auto ============================================================================== --- lldb/trunk/tools/lldb-platform/lldb-platform.cpp (added) +++ lldb/trunk/tools/lldb-platform/lldb-platform.cpp Mon Mar 21 20:34:44 2011 @@ -0,0 +1,112 @@ +//===-- lldb-platform.cpp ---------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include +#include +#include +#include +#include +#include +#include + +#include "GDBRemoteCommunication.h" + +//---------------------------------------------------------------------- +// option descriptors for getopt_long() +//---------------------------------------------------------------------- + +int g_debug = 0; +int g_verbose = 0; + +static struct option g_long_options[] = +{ + { "debug", no_argument, &g_debug, 1 }, + { "verbose", no_argument, &g_verbose, 1 }, + { "log-file", required_argument, NULL, 'l' }, + { "log-flags", required_argument, NULL, 'f' }, + { NULL, 0, NULL, 0 } +}; + +//---------------------------------------------------------------------- +// Watch for signals +//---------------------------------------------------------------------- +int g_sigpipe_received = 0; +void +signal_handler(int signo) +{ + switch (signo) + { + case SIGPIPE: + g_sigpipe_received = 1; + break; + } +} + +//---------------------------------------------------------------------- +// main +//---------------------------------------------------------------------- +int +main (int argc, char *argv[]) +{ + signal (SIGPIPE, signal_handler); + int long_option_index = 0; + FILE* log_file = NULL; + uint32_t log_flags = 0; + char ch; + + while ((ch = getopt_long(argc, argv, "l:f:", g_long_options, &long_option_index)) != -1) + { +// DNBLogDebug("option: ch == %c (0x%2.2x) --%s%c%s\n", +// ch, (uint8_t)ch, +// g_long_options[long_option_index].name, +// g_long_options[long_option_index].has_arg ? '=' : ' ', +// optarg ? optarg : ""); + switch (ch) + { + case 0: // Any optional that auto set themselves will return 0 + break; + + case 'l': // Set Log File + if (optarg && optarg[0]) + { + if (strcasecmp(optarg, "stdout") == 0) + log_file = stdout; + else if (strcasecmp(optarg, "stderr") == 0) + log_file = stderr; + else + { + log_file = fopen(optarg, "w"); + if (log_file != NULL) + setlinebuf(log_file); + } + + if (log_file == NULL) + { + const char *errno_str = strerror(errno); + fprintf (stderr, "Failed to open log file '%s' for writing: errno = %i (%s)", optarg, errno, errno_str ? errno_str : "unknown error"); + } + } + break; + + case 'f': // Log Flags + if (optarg && optarg[0]) + log_flags = strtoul(optarg, NULL, 0); + break; + } + } + + // Skip any options we consumed with getopt_long + argc -= optind; + argv += optind; + + + GDBRemoteCommunication gdb_comm; + + return 0; +} From jingham at apple.com Mon Mar 21 20:47:27 2011 From: jingham at apple.com (Jim Ingham) Date: Tue, 22 Mar 2011 01:47:27 -0000 Subject: [Lldb-commits] [lldb] r128062 - /lldb/trunk/source/Target/Target.cpp Message-ID: <20110322014727.430D72A6C12C@llvm.org> Author: jingham Date: Mon Mar 21 20:47:27 2011 New Revision: 128062 URL: http://llvm.org/viewvc/llvm-project?rev=128062&view=rev Log: Tidy up the stop hook printing when only one thread matches, and there is only one hook. Modified: lldb/trunk/source/Target/Target.cpp Modified: lldb/trunk/source/Target/Target.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Target.cpp?rev=128062&r1=128061&r2=128062&view=diff ============================================================================== --- lldb/trunk/source/Target/Target.cpp (original) +++ lldb/trunk/source/Target/Target.cpp Mon Mar 21 20:47:27 2011 @@ -1085,6 +1085,19 @@ bool keep_going = true; bool hooks_ran = false; + bool print_hook_header; + bool print_thread_header; + + if (num_exe_ctx == 1) + print_thread_header = false; + else + print_thread_header = true; + + if (m_stop_hooks.size() == 1) + print_hook_header = false; + else + print_hook_header = true; + for (pos = m_stop_hooks.begin(); keep_going && pos != end; pos++) { // result.Clear(); @@ -1102,16 +1115,17 @@ { if (!hooks_ran) { - result.AppendMessage("\n** Stop Hooks **\n"); + result.AppendMessage("\n** Stop Hooks **"); hooks_ran = true; } - if (!any_thread_matched) + if (print_hook_header && !any_thread_matched) { result.AppendMessageWithFormat("\n- Hook %d\n", cur_hook_sp->GetID()); any_thread_matched = true; } - result.AppendMessageWithFormat("-- Thread %d\n", exc_ctx_with_reasons[i].thread->GetIndexID()); + if (print_thread_header) + result.AppendMessageWithFormat("-- Thread %d\n", exc_ctx_with_reasons[i].thread->GetIndexID()); bool stop_on_continue = true; bool stop_on_error = true; From jingham at apple.com Mon Mar 21 20:48:42 2011 From: jingham at apple.com (Jim Ingham) Date: Tue, 22 Mar 2011 01:48:42 -0000 Subject: [Lldb-commits] [lldb] r128063 - in /lldb/trunk: include/lldb/Core/Disassembler.h lldb.xcodeproj/project.pbxproj source/Commands/CommandObjectDisassemble.cpp source/Commands/CommandObjectDisassemble.h source/Core/Disassembler.cpp source/Expression/ClangExpressionParser.cpp source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp source/Plugins/Disassembler/llvm/DisassemblerLLVM.h source/Target/StackFrame.cpp source/Target/ThreadPlanTracer.cpp Message-ID: <20110322014842.C16082A6C12C@llvm.org> Author: jingham Date: Mon Mar 21 20:48:42 2011 New Revision: 128063 URL: http://llvm.org/viewvc/llvm-project?rev=128063&view=rev Log: Add the ability to disassemble "n" instructions from the current PC, or the first "n" instructions in a function. Also added a "-p" flag that disassembles from the current pc. Modified: lldb/trunk/include/lldb/Core/Disassembler.h lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/source/Commands/CommandObjectDisassemble.cpp lldb/trunk/source/Commands/CommandObjectDisassemble.h lldb/trunk/source/Core/Disassembler.cpp lldb/trunk/source/Expression/ClangExpressionParser.cpp lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.h lldb/trunk/source/Target/StackFrame.cpp lldb/trunk/source/Target/ThreadPlanTracer.cpp Modified: lldb/trunk/include/lldb/Core/Disassembler.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Disassembler.h?rev=128063&r1=128062&r2=128063&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/Disassembler.h (original) +++ lldb/trunk/include/lldb/Core/Disassembler.h Mon Mar 21 20:48:42 2011 @@ -111,6 +111,18 @@ const ArchSpec &arch, const ExecutionContext &exe_ctx, const AddressRange &range, + uint32_t num_instructions, + uint32_t num_mixed_context_lines, + bool show_bytes, + bool raw, + Stream &strm); + + static bool + Disassemble (Debugger &debugger, + const ArchSpec &arch, + const ExecutionContext &exe_ctx, + const Address &start, + uint32_t num_instructions, uint32_t num_mixed_context_lines, bool show_bytes, bool raw, @@ -121,6 +133,7 @@ const ArchSpec &arch, const ExecutionContext &exe_ctx, SymbolContextList &sc_list, + uint32_t num_instructions, uint32_t num_mixed_context_lines, bool show_bytes, bool raw, @@ -132,6 +145,7 @@ const ExecutionContext &exe_ctx, const ConstString &name, Module *module, + uint32_t num_instructions, uint32_t num_mixed_context_lines, bool show_bytes, bool raw, @@ -141,6 +155,7 @@ Disassemble (Debugger &debugger, const ArchSpec &arch, const ExecutionContext &exe_ctx, + uint32_t num_instructions, uint32_t num_mixed_context_lines, bool show_bytes, bool raw, @@ -154,16 +169,36 @@ typedef const char * (*SummaryCallback)(const Instruction& inst, ExecutionContext *exe_context, void *user_data); + static bool + PrintInstructions (Disassembler *disasm_ptr, + DataExtractor &data, + Debugger &debugger, + const ArchSpec &arch, + const ExecutionContext &exe_ctx, + const Address &start_addr, + uint32_t num_instructions, + uint32_t num_mixed_context_lines, + bool show_bytes, + bool raw, + Stream &strm); + size_t ParseInstructions (const ExecutionContext *exe_ctx, const AddressRange &range, DataExtractor& data); + size_t + ParseInstructions (const ExecutionContext *exe_ctx, + const Address &range, + uint32_t num_instructions, + DataExtractor& data); + virtual size_t DecodeInstructions (const Address &base_addr, const DataExtractor& data, uint32_t data_offset, - uint32_t num_instructions) = 0; + uint32_t num_instructions, + bool append) = 0; InstructionList & GetInstructionList (); Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=128063&r1=128062&r2=128063&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Mon Mar 21 20:48:42 2011 @@ -1231,11 +1231,11 @@ 08FB7794FE84155DC02AAC07 /* lldb */ = { isa = PBXGroup; children = ( - 2689FFCA13353D7A00698AC0 /* liblldb-core.a */, 26F5C32810F3DF7D009D5894 /* Libraries */, 08FB7795FE84155DC02AAC07 /* Source */, 26F5C22410F3D950009D5894 /* Tools */, 1AB674ADFE9D54B511CA2CBB /* Products */, + 2689FFCA13353D7A00698AC0 /* liblldb-core.a */, ); name = lldb; sourceTree = ""; Modified: lldb/trunk/source/Commands/CommandObjectDisassemble.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectDisassemble.cpp?rev=128063&r1=128062&r2=128063&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectDisassemble.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectDisassemble.cpp Mon Mar 21 20:48:42 2011 @@ -27,15 +27,19 @@ #include "lldb/Target/Target.h" #define DEFAULT_DISASM_BYTE_SIZE 32 +#define DEFAULT_DISASM_NUM_INS 4 using namespace lldb; using namespace lldb_private; CommandObjectDisassemble::CommandOptions::CommandOptions () : Options(), + num_lines_context(0), + num_instructions (0), m_func_name(), m_start_addr(), - m_end_addr () + m_end_addr (), + m_at_pc (false) { ResetOptionValues(); } @@ -51,14 +55,24 @@ char short_option = (char) m_getopt_table[option_idx].val; + bool success; + switch (short_option) { case 'm': show_mixed = true; break; + case 'x': + num_lines_context = Args::StringToUInt32(option_arg, 0, 0, &success); + if (!success) + error.SetErrorStringWithFormat ("Invalid num context lines string: \"%s\".\n", option_arg); + break; + case 'c': - num_lines_context = Args::StringToUInt32(option_arg, 0, 0); + num_instructions = Args::StringToUInt32(option_arg, 0, 0, &success); + if (!success) + error.SetErrorStringWithFormat ("Invalid num of instructions string: \"%s\".\n", option_arg); break; case 'b': @@ -66,26 +80,30 @@ break; case 's': - m_start_addr = Args::StringToUInt64(optarg, LLDB_INVALID_ADDRESS, 0); + m_start_addr = Args::StringToUInt64(option_arg, LLDB_INVALID_ADDRESS, 0); if (m_start_addr == LLDB_INVALID_ADDRESS) - m_start_addr = Args::StringToUInt64(optarg, LLDB_INVALID_ADDRESS, 16); + m_start_addr = Args::StringToUInt64(option_arg, LLDB_INVALID_ADDRESS, 16); if (m_start_addr == LLDB_INVALID_ADDRESS) - error.SetErrorStringWithFormat ("Invalid start address string '%s'.\n", optarg); + error.SetErrorStringWithFormat ("Invalid start address string '%s'.\n", option_arg); break; case 'e': - m_end_addr = Args::StringToUInt64(optarg, LLDB_INVALID_ADDRESS, 0); + m_end_addr = Args::StringToUInt64(option_arg, LLDB_INVALID_ADDRESS, 0); if (m_end_addr == LLDB_INVALID_ADDRESS) - m_end_addr = Args::StringToUInt64(optarg, LLDB_INVALID_ADDRESS, 16); + m_end_addr = Args::StringToUInt64(option_arg, LLDB_INVALID_ADDRESS, 16); if (m_end_addr == LLDB_INVALID_ADDRESS) - error.SetErrorStringWithFormat ("Invalid end address string '%s'.\n", optarg); + error.SetErrorStringWithFormat ("Invalid end address string '%s'.\n", option_arg); break; case 'n': m_func_name = option_arg; break; + case 'p': + m_at_pc = true; + break; + case 'r': raw = true; break; @@ -110,7 +128,9 @@ show_mixed = false; show_bytes = false; num_lines_context = 0; + num_instructions = 0; m_func_name.clear(); + m_at_pc = false; m_start_addr = LLDB_INVALID_ADDRESS; m_end_addr = LLDB_INVALID_ADDRESS; raw = false; @@ -126,16 +146,24 @@ CommandObjectDisassemble::CommandOptions::g_option_table[] = { { LLDB_OPT_SET_ALL, false, "bytes", 'b', no_argument, NULL, 0, eArgTypeNone, "Show opcode bytes when disassembling."}, -{ LLDB_OPT_SET_ALL, false, "context", 'c', required_argument, NULL, 0, eArgTypeNumLines, "Number of context lines of source to show."}, +{ LLDB_OPT_SET_ALL, false, "context", 'x', required_argument, NULL, 0, eArgTypeNumLines, "Number of context lines of source to show."}, { LLDB_OPT_SET_ALL, false, "mixed", 'm', no_argument, NULL, 0, eArgTypeNone, "Enable mixed source and assembly display."}, { LLDB_OPT_SET_ALL, false, "raw", 'r', no_argument, NULL, 0, eArgTypeNone, "Print raw disassembly with no symbol information."}, { LLDB_OPT_SET_1, true, "start-address", 's', required_argument, NULL, 0, eArgTypeStartAddress, "Address at which to start disassembling."}, { LLDB_OPT_SET_1, false, "end-address", 'e', required_argument, NULL, 0, eArgTypeEndAddress, "Address at which to end disassembling."}, -{ LLDB_OPT_SET_2, true, "name", 'n', required_argument, NULL, CommandCompletions::eSymbolCompletion, eArgTypeFunctionName, "Disassemble entire contents of the given function name."}, +{ LLDB_OPT_SET_2, true, "start-address", 's', required_argument, NULL, 0, eArgTypeStartAddress, "Address at which to start disassembling."}, +{ LLDB_OPT_SET_2, false, "instruction-count", 'c', required_argument, NULL, 0, eArgTypeNumLines, "Number of instructions to display."}, -{ LLDB_OPT_SET_3, true, "current-frame", 'f', no_argument, NULL, 0, eArgTypeNone, "Disassemble entire contents of the current frame's function."}, +{ LLDB_OPT_SET_3, true, "name", 'n', required_argument, NULL, CommandCompletions::eSymbolCompletion, eArgTypeFunctionName, "Disassemble entire contents of the given function name."}, +{ LLDB_OPT_SET_3, false, "instruction-count", 'c', required_argument, NULL, 0, eArgTypeNumLines, "Number of instructions to display."}, + +{ LLDB_OPT_SET_4, true, "current-frame", 'f', no_argument, NULL, 0, eArgTypeNone, "Disassemble from the start of the current frame's function."}, +{ LLDB_OPT_SET_4, false, "instruction-count", 'c', required_argument, NULL, 0, eArgTypeNumLines, "Number of instructions to display."}, + +{ LLDB_OPT_SET_5, true, "current-pc", 'p', no_argument, NULL, 0, eArgTypeNone, "Disassemble from the current pc."}, +{ LLDB_OPT_SET_5, false, "instruction-count", 'c', required_argument, NULL, 0, eArgTypeNumLines, "Number of instructions to display."}, { 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL } }; @@ -202,11 +230,12 @@ result.SetStatus (eReturnStatusFailed); return false; } - ExecutionContext exe_ctx(m_interpreter.GetDebugger().GetExecutionContext()); - + if (m_options.show_mixed && m_options.num_lines_context == 0) m_options.num_lines_context = 1; + ExecutionContext exe_ctx(m_interpreter.GetDebugger().GetExecutionContext()); + if (!m_options.m_func_name.empty()) { ConstString name(m_options.m_func_name.c_str()); @@ -216,6 +245,7 @@ exe_ctx, name, NULL, // Module * + m_options.num_instructions, m_options.show_mixed ? m_options.num_lines_context : 0, m_options.show_bytes, m_options.raw, @@ -231,62 +261,133 @@ } else { - AddressRange range; - if (m_options.m_start_addr != LLDB_INVALID_ADDRESS) + Address start_addr; + lldb::addr_t range_byte_size = DEFAULT_DISASM_BYTE_SIZE; + + if (m_options.m_at_pc) { - range.GetBaseAddress().SetOffset (m_options.m_start_addr); - if (m_options.m_end_addr != LLDB_INVALID_ADDRESS) + if (exe_ctx.frame == NULL) + { + result.AppendError ("Cannot disassemble around the current PC without a selected frame.\n"); + result.SetStatus (eReturnStatusFailed); + return false; + } + start_addr = exe_ctx.frame->GetFrameCodeAddress(); + if (m_options.num_instructions == 0) { - if (m_options.m_end_addr < m_options.m_start_addr) + // Disassembling at the PC always disassembles some number of instructions (not the whole function). + m_options.num_instructions = DEFAULT_DISASM_NUM_INS; + } + } + else + { + start_addr.SetOffset (m_options.m_start_addr); + if (start_addr.IsValid()) + { + if (m_options.m_end_addr != LLDB_INVALID_ADDRESS) { - result.AppendErrorWithFormat ("End address before start address.\n"); + if (m_options.m_end_addr < m_options.m_start_addr) + { + result.AppendErrorWithFormat ("End address before start address.\n"); + result.SetStatus (eReturnStatusFailed); + return false; + } + range_byte_size = m_options.m_end_addr - m_options.m_start_addr; + } + } + } + + if (m_options.num_instructions != 0) + { + if (!start_addr.IsValid()) + { + // The default action is to disassemble the current frame function. + if (exe_ctx.frame) + { + SymbolContext sc(exe_ctx.frame->GetSymbolContext(eSymbolContextFunction | eSymbolContextSymbol)); + if (sc.function) + start_addr = sc.function->GetAddressRange().GetBaseAddress(); + else if (sc.symbol && sc.symbol->GetAddressRangePtr()) + start_addr = sc.symbol->GetAddressRangePtr()->GetBaseAddress(); + else + start_addr = exe_ctx.frame->GetFrameCodeAddress(); + } + + if (!start_addr.IsValid()) + { + result.AppendError ("invalid frame"); result.SetStatus (eReturnStatusFailed); - return false; + return false; } - range.SetByteSize (m_options.m_end_addr - m_options.m_start_addr); + } + + if (Disassembler::Disassemble (m_interpreter.GetDebugger(), + arch, + exe_ctx, + start_addr, + m_options.num_instructions, + m_options.show_mixed ? m_options.num_lines_context : 0, + m_options.show_bytes, + m_options.raw, + result.GetOutputStream())) + { + result.SetStatus (eReturnStatusSuccessFinishResult); } else - range.SetByteSize (DEFAULT_DISASM_BYTE_SIZE); - } + { + result.AppendErrorWithFormat ("Failed to disassemble memory at 0x%8.8llx.\n", m_options.m_start_addr); + result.SetStatus (eReturnStatusFailed); + } + } else { - // The default action is to disassemble the current frame function. - if (exe_ctx.frame) + AddressRange range; + if (start_addr.IsValid()) { - SymbolContext sc(exe_ctx.frame->GetSymbolContext(eSymbolContextFunction | eSymbolContextSymbol)); - if (sc.function) - range = sc.function->GetAddressRange(); - else if (sc.symbol && sc.symbol->GetAddressRangePtr()) - range = *sc.symbol->GetAddressRangePtr(); + range.GetBaseAddress() = start_addr; + range.SetByteSize (range_byte_size); + } + else + { + // The default action is to disassemble the current frame function. + if (exe_ctx.frame) + { + SymbolContext sc(exe_ctx.frame->GetSymbolContext(eSymbolContextFunction | eSymbolContextSymbol)); + if (sc.function) + range = sc.function->GetAddressRange(); + else if (sc.symbol && sc.symbol->GetAddressRangePtr()) + range = *sc.symbol->GetAddressRangePtr(); + else + range.GetBaseAddress() = exe_ctx.frame->GetFrameCodeAddress(); + } else - range.GetBaseAddress() = exe_ctx.frame->GetFrameCodeAddress(); + { + result.AppendError ("invalid frame"); + result.SetStatus (eReturnStatusFailed); + return false; + } + } + if (range.GetByteSize() == 0) + range.SetByteSize(DEFAULT_DISASM_BYTE_SIZE); + + if (Disassembler::Disassemble (m_interpreter.GetDebugger(), + arch, + exe_ctx, + range, + m_options.num_instructions, + m_options.show_mixed ? m_options.num_lines_context : 0, + m_options.show_bytes, + m_options.raw, + result.GetOutputStream())) + { + result.SetStatus (eReturnStatusSuccessFinishResult); } else { - result.AppendError ("invalid frame"); - result.SetStatus (eReturnStatusFailed); - return false; + result.AppendErrorWithFormat ("Failed to disassemble memory at 0x%8.8llx.\n", m_options.m_start_addr); + result.SetStatus (eReturnStatusFailed); } } - if (range.GetByteSize() == 0) - range.SetByteSize(DEFAULT_DISASM_BYTE_SIZE); - - if (Disassembler::Disassemble (m_interpreter.GetDebugger(), - arch, - exe_ctx, - range, - m_options.show_mixed ? m_options.num_lines_context : 0, - m_options.show_bytes, - m_options.raw, - result.GetOutputStream())) - { - result.SetStatus (eReturnStatusSuccessFinishResult); - } - else - { - result.AppendErrorWithFormat ("Failed to disassemble memory at 0x%8.8llx.\n", m_options.m_start_addr); - result.SetStatus (eReturnStatusFailed); - } } return result.Succeeded(); Modified: lldb/trunk/source/Commands/CommandObjectDisassemble.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectDisassemble.h?rev=128063&r1=128062&r2=128063&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectDisassemble.h (original) +++ lldb/trunk/source/Commands/CommandObjectDisassemble.h Mon Mar 21 20:48:42 2011 @@ -47,10 +47,12 @@ bool show_mixed; // Show mixed source/assembly bool show_bytes; uint32_t num_lines_context; + uint32_t num_instructions; bool raw; std::string m_func_name; lldb::addr_t m_start_addr; lldb::addr_t m_end_addr; + bool m_at_pc; static lldb::OptionDefinition g_option_table[]; }; Modified: lldb/trunk/source/Core/Disassembler.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Disassembler.cpp?rev=128063&r1=128062&r2=128063&view=diff ============================================================================== --- lldb/trunk/source/Core/Disassembler.cpp (original) +++ lldb/trunk/source/Core/Disassembler.cpp Mon Mar 21 20:48:42 2011 @@ -61,6 +61,7 @@ const ArchSpec &arch, const ExecutionContext &exe_ctx, SymbolContextList &sc_list, + uint32_t num_instructions, uint32_t num_mixed_context_lines, bool show_bytes, bool raw, @@ -71,13 +72,15 @@ const size_t count = sc_list.GetSize(); SymbolContext sc; AddressRange range; + for (size_t i=0; iGetInstructionList().GetSize(); - uint32_t offset = 0; - SymbolContext sc; - SymbolContext prev_sc; - AddressRange sc_range; - if (num_mixed_context_lines) - strm.IndentMore (); - - - Address addr(range.GetBaseAddress()); - - // We extract the section to make sure we don't transition out - // of the current section when disassembling - const Section *addr_section = addr.GetSection(); - Module *range_module = range.GetBaseAddress().GetModule(); + return PrintInstructions (disasm_ap.get(), + data, + debugger, + arch, + exe_ctx, + disasm_range.GetBaseAddress(), + num_instructions, + num_mixed_context_lines, + show_bytes, + raw, + strm); + } + } + } + return false; +} + +bool +Disassembler::Disassemble +( + Debugger &debugger, + const ArchSpec &arch, + const ExecutionContext &exe_ctx, + const Address &start_address, + uint32_t num_instructions, + uint32_t num_mixed_context_lines, + bool show_bytes, + bool raw, + Stream &strm +) +{ + if (num_instructions > 0) + { + std::auto_ptr disasm_ap (Disassembler::FindPlugin(arch)); + Address addr = start_address; - for (size_t i=0; iGetInstructionList().GetInstructionAtIndex (i).get(); - if (inst) + if (exe_ctx.target->GetSectionLoadList().IsEmpty()) { - addr_t file_addr = addr.GetFileAddress(); - if (addr_section == NULL || addr_section->ContainsFileAddress (file_addr) == false) - { - if (range_module) - range_module->ResolveFileAddress (file_addr, addr); - else if (exe_ctx.target) - exe_ctx.target->GetImages().ResolveFileAddress (file_addr, addr); - - addr_section = addr.GetSection(); - } + exe_ctx.target->GetImages().ResolveFileAddress (addr.GetOffset(), addr); + } + else + { + exe_ctx.target->GetSectionLoadList().ResolveLoadAddress (addr.GetOffset(), addr); + } + } + } + + DataExtractor data; + size_t bytes_disassembled = disasm_ap->ParseInstructions (&exe_ctx, addr, num_instructions, data); + if (bytes_disassembled == 0) + { + return false; + } + else + { + return PrintInstructions (disasm_ap.get(), + data, + debugger, + arch, + exe_ctx, + addr, + num_instructions, + num_mixed_context_lines, + show_bytes, + raw, + strm); + } + } + } + return false; +} + +bool +Disassembler::PrintInstructions +( + Disassembler *disasm_ptr, + DataExtractor &data, + Debugger &debugger, + const ArchSpec &arch, + const ExecutionContext &exe_ctx, + const Address &start_addr, + uint32_t num_instructions, + uint32_t num_mixed_context_lines, + bool show_bytes, + bool raw, + Stream &strm +) +{ + // We got some things disassembled... + size_t num_instructions_found = disasm_ptr->GetInstructionList().GetSize(); + + if (num_instructions > 0 && num_instructions < num_instructions_found) + num_instructions_found = num_instructions; + + uint32_t offset = 0; + SymbolContext sc; + SymbolContext prev_sc; + AddressRange sc_range; + Address addr = start_addr; + + if (num_mixed_context_lines) + strm.IndentMore (); - prev_sc = sc; + // We extract the section to make sure we don't transition out + // of the current section when disassembling + const Section *addr_section = addr.GetSection(); + Module *range_module = addr.GetModule(); - if (addr_section) + for (size_t i=0; iGetInstructionList().GetInstructionAtIndex (i).get(); + if (inst) + { + addr_t file_addr = addr.GetFileAddress(); + if (addr_section == NULL || addr_section->ContainsFileAddress (file_addr) == false) + { + if (range_module) + range_module->ResolveFileAddress (file_addr, addr); + else if (exe_ctx.target) + exe_ctx.target->GetImages().ResolveFileAddress (file_addr, addr); + + addr_section = addr.GetSection(); + } + + prev_sc = sc; + + if (addr_section) + { + Module *module = addr_section->GetModule(); + uint32_t resolved_mask = module->ResolveSymbolContextForAddress(addr, eSymbolContextEverything, sc); + if (resolved_mask) + { + if (!(prev_sc.function == sc.function || prev_sc.symbol == sc.symbol)) + { + if (prev_sc.function || prev_sc.symbol) + strm.EOL(); + + strm << sc.module_sp->GetFileSpec().GetFilename(); + + if (sc.function) + strm << '`' << sc.function->GetMangled().GetName(); + else if (sc.symbol) + strm << '`' << sc.symbol->GetMangled().GetName(); + strm << ":\n"; + } + + if (num_mixed_context_lines && !sc_range.ContainsFileAddress (addr)) + { + sc.GetAddressRange (eSymbolContextEverything, sc_range); + + if (sc != prev_sc) { - Module *module = addr_section->GetModule(); - uint32_t resolved_mask = module->ResolveSymbolContextForAddress(addr, eSymbolContextEverything, sc); - if (resolved_mask) - { - if (!(prev_sc.function == sc.function || prev_sc.symbol == sc.symbol)) - { - if (prev_sc.function || prev_sc.symbol) - strm.EOL(); - - strm << sc.module_sp->GetFileSpec().GetFilename(); - - if (sc.function) - strm << '`' << sc.function->GetMangled().GetName(); - else if (sc.symbol) - strm << '`' << sc.symbol->GetMangled().GetName(); - strm << ":\n"; - } - - if (num_mixed_context_lines && !sc_range.ContainsFileAddress (addr)) - { - sc.GetAddressRange (eSymbolContextEverything, sc_range); - - if (sc != prev_sc) - { - if (offset != 0) - strm.EOL(); - - sc.DumpStopContext(&strm, process, addr, false, true, false); - strm.EOL(); - - if (sc.comp_unit && sc.line_entry.IsValid()) - { - debugger.GetSourceManager().DisplaySourceLinesWithLineNumbers (sc.line_entry.file, - sc.line_entry.line, - num_mixed_context_lines, - num_mixed_context_lines, - num_mixed_context_lines ? "->" : "", - &strm); - } - } - } - } - else + if (offset != 0) + strm.EOL(); + + sc.DumpStopContext(&strm, exe_ctx.process, addr, false, true, false); + strm.EOL(); + + if (sc.comp_unit && sc.line_entry.IsValid()) { - sc.Clear(); + debugger.GetSourceManager().DisplaySourceLinesWithLineNumbers (sc.line_entry.file, + sc.line_entry.line, + num_mixed_context_lines, + num_mixed_context_lines, + num_mixed_context_lines ? "->" : "", + &strm); } } - if (num_mixed_context_lines) - strm.IndentMore (); - strm.Indent(); - size_t inst_byte_size = inst->GetByteSize(); - inst->Dump(&strm, true, show_bytes ? &data : NULL, offset, &exe_ctx, raw); - strm.EOL(); - offset += inst_byte_size; - - addr.SetOffset (addr.GetOffset() + inst_byte_size); - - if (num_mixed_context_lines) - strm.IndentLess (); - } - else - { - break; } } - if (num_mixed_context_lines) - strm.IndentLess (); - + else + { + sc.Clear(); + } } + if (num_mixed_context_lines) + strm.IndentMore (); + strm.Indent(); + size_t inst_byte_size = inst->GetByteSize(); + inst->Dump(&strm, true, show_bytes ? &data : NULL, offset, &exe_ctx, raw); + strm.EOL(); + offset += inst_byte_size; + + addr.SetOffset (addr.GetOffset() + inst_byte_size); + + if (num_mixed_context_lines) + strm.IndentLess (); + } + else + { + break; } - return true; } - return false; + if (num_mixed_context_lines) + strm.IndentLess (); + + return true; } @@ -336,6 +435,7 @@ Debugger &debugger, const ArchSpec &arch, const ExecutionContext &exe_ctx, + uint32_t num_instructions, uint32_t num_mixed_context_lines, bool show_bytes, bool raw, @@ -363,7 +463,7 @@ range.SetByteSize (DEFAULT_DISASM_BYTE_SIZE); } - return Disassemble(debugger, arch, exe_ctx, range, num_mixed_context_lines, show_bytes, raw, strm); + return Disassemble(debugger, arch, exe_ctx, range, num_instructions, num_mixed_context_lines, show_bytes, raw, strm); } Instruction::Instruction(const Address &addr) : @@ -443,12 +543,78 @@ data.SetData(data_sp); data.SetByteOrder(target->GetArchitecture().GetByteOrder()); data.SetAddressByteSize(target->GetArchitecture().GetAddressByteSize()); - return DecodeInstructions (range.GetBaseAddress(), data, 0, UINT32_MAX); + return DecodeInstructions (range.GetBaseAddress(), data, 0, UINT32_MAX, false); } return 0; } +size_t +Disassembler::ParseInstructions +( + const ExecutionContext *exe_ctx, + const Address &start, + uint32_t num_instructions, + DataExtractor& data +) +{ + Address addr = start; + + if (num_instructions == 0) + return 0; + + Target *target = exe_ctx->target; + // We'll guess at a size for the buffer, if we don't get all the instructions we want we can just re-fill & reuse it. + const addr_t byte_size = num_instructions * 2; + addr_t data_offset = 0; + addr_t next_instruction_offset = 0; + size_t buffer_size = byte_size; + + uint32_t num_instructions_found = 0; + + if (target == NULL || byte_size == 0 || !start.IsValid()) + return 0; + + DataBufferHeap *heap_buffer = new DataBufferHeap (byte_size, '\0'); + DataBufferSP data_sp(heap_buffer); + + data.SetData(data_sp); + data.SetByteOrder(target->GetArchitecture().GetByteOrder()); + data.SetAddressByteSize(target->GetArchitecture().GetAddressByteSize()); + + Error error; + bool prefer_file_cache = true; + + m_instruction_list.Clear(); + + while (num_instructions_found < num_instructions) + { + if (buffer_size < data_offset + byte_size) + { + buffer_size = data_offset + byte_size; + heap_buffer->SetByteSize (buffer_size); + data.SetData(data_sp); // Resizing might have changed the backing store location, so we have to reset + // the DataBufferSP in the extractor so it changes to pointing at the right thing. + } + const size_t bytes_read = target->ReadMemory (addr, prefer_file_cache, heap_buffer->GetBytes() + data_offset, byte_size, error); + size_t num_bytes_read = 0; + if (bytes_read == 0) + break; + + num_bytes_read = DecodeInstructions (start, data, next_instruction_offset, num_instructions - num_instructions_found, true); + if (num_bytes_read == 0) + break; + num_instructions_found = m_instruction_list.GetSize(); + + // Prepare for the next round. + data_offset += bytes_read; + addr.Slide (bytes_read); + next_instruction_offset += num_bytes_read; + } + + return m_instruction_list.GetSize(); +} + //---------------------------------------------------------------------- // Disassembler copy constructor //---------------------------------------------------------------------- Modified: lldb/trunk/source/Expression/ClangExpressionParser.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionParser.cpp?rev=128063&r1=128062&r2=128063&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangExpressionParser.cpp (original) +++ lldb/trunk/source/Expression/ClangExpressionParser.cpp Mon Mar 21 20:48:42 2011 @@ -739,7 +739,7 @@ DataExtractor::TypeUInt8); } - disassembler->DecodeInstructions (Address (NULL, func_remote_addr), extractor, 0, UINT32_MAX); + disassembler->DecodeInstructions (Address (NULL, func_remote_addr), extractor, 0, UINT32_MAX, false); InstructionList &instruction_list = disassembler->GetInstructionList(); Modified: lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp?rev=128063&r1=128062&r2=128063&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp (original) +++ lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp Mon Mar 21 20:48:42 2011 @@ -404,7 +404,8 @@ const Address &base_addr, const DataExtractor& data, uint32_t data_offset, - uint32_t num_instructions + uint32_t num_instructions, + bool append ) { if (m_disassembler == NULL) @@ -412,7 +413,8 @@ size_t total_inst_byte_size = 0; - m_instruction_list.Clear(); + if (!append) + m_instruction_list.Clear(); while (data.ValidOffset(data_offset) && num_instructions) { Modified: lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.h?rev=128063&r1=128062&r2=128063&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.h (original) +++ lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.h Mon Mar 21 20:48:42 2011 @@ -78,7 +78,8 @@ DecodeInstructions (const lldb_private::Address &base_addr, const lldb_private::DataExtractor& data, uint32_t data_offset, - uint32_t num_instructions); + uint32_t num_instructions, + bool append); //------------------------------------------------------------------ // PluginInterface protocol Modified: lldb/trunk/source/Target/StackFrame.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/StackFrame.cpp?rev=128063&r1=128062&r2=128063&view=diff ============================================================================== --- lldb/trunk/source/Target/StackFrame.cpp (original) +++ lldb/trunk/source/Target/StackFrame.cpp Mon Mar 21 20:48:42 2011 @@ -260,6 +260,7 @@ target.GetArchitecture(), exe_ctx, 0, + 0, false, false, m_disassembly); Modified: lldb/trunk/source/Target/ThreadPlanTracer.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanTracer.cpp?rev=128063&r1=128062&r2=128063&view=diff ============================================================================== --- lldb/trunk/source/Target/ThreadPlanTracer.cpp (original) +++ lldb/trunk/source/Target/ThreadPlanTracer.cpp Mon Mar 21 20:48:42 2011 @@ -204,9 +204,9 @@ m_process.GetAddressByteSize()); if (addr_valid) - m_disassembler->DecodeInstructions (pc_addr, extractor, 0, 1); + m_disassembler->DecodeInstructions (pc_addr, extractor, 0, 1, false); else - m_disassembler->DecodeInstructions (Address (NULL, pc), extractor, 0, 1); + m_disassembler->DecodeInstructions (Address (NULL, pc), extractor, 0, 1, false); InstructionList &instruction_list = m_disassembler->GetInstructionList(); From jingham at apple.com Mon Mar 21 20:53:33 2011 From: jingham at apple.com (Jim Ingham) Date: Tue, 22 Mar 2011 01:53:33 -0000 Subject: [Lldb-commits] [lldb] r128064 - in /lldb/trunk/source/Commands: CommandObjectBreakpoint.cpp CommandObjectFile.cpp CommandObjectTarget.cpp Message-ID: <20110322015333.D5E9B2A6C12C@llvm.org> Author: jingham Date: Mon Mar 21 20:53:33 2011 New Revision: 128064 URL: http://llvm.org/viewvc/llvm-project?rev=128064&view=rev Log: Clean up a few places where SetOptionValue was using the global optarg, rather than the option_arg value that was passed in. Modified: lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp lldb/trunk/source/Commands/CommandObjectFile.cpp lldb/trunk/source/Commands/CommandObjectTarget.cpp Modified: lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp?rev=128064&r1=128063&r2=128064&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp Mon Mar 21 20:53:33 2011 @@ -142,12 +142,12 @@ switch (short_option) { case 'a': - m_load_addr = Args::StringToUInt64(optarg, LLDB_INVALID_ADDRESS, 0); + m_load_addr = Args::StringToUInt64(option_arg, LLDB_INVALID_ADDRESS, 0); if (m_load_addr == LLDB_INVALID_ADDRESS) - m_load_addr = Args::StringToUInt64(optarg, LLDB_INVALID_ADDRESS, 16); + m_load_addr = Args::StringToUInt64(option_arg, LLDB_INVALID_ADDRESS, 16); if (m_load_addr == LLDB_INVALID_ADDRESS) - error.SetErrorStringWithFormat ("Invalid address string '%s'.\n", optarg); + error.SetErrorStringWithFormat ("Invalid address string '%s'.\n", option_arg); break; case 'c': @@ -198,16 +198,16 @@ } case 'i': { - m_ignore_count = Args::StringToUInt32(optarg, UINT32_MAX, 0); + m_ignore_count = Args::StringToUInt32(option_arg, UINT32_MAX, 0); if (m_ignore_count == UINT32_MAX) - error.SetErrorStringWithFormat ("Invalid ignore count '%s'.\n", optarg); + error.SetErrorStringWithFormat ("Invalid ignore count '%s'.\n", option_arg); } break; case 't' : { - m_thread_id = Args::StringToUInt64(optarg, LLDB_INVALID_THREAD_ID, 0); + m_thread_id = Args::StringToUInt64(option_arg, LLDB_INVALID_THREAD_ID, 0); if (m_thread_id == LLDB_INVALID_THREAD_ID) - error.SetErrorStringWithFormat ("Invalid thread id string '%s'.\n", optarg); + error.SetErrorStringWithFormat ("Invalid thread id string '%s'.\n", option_arg); } break; case 'T': @@ -218,9 +218,9 @@ break; case 'x': { - m_thread_index = Args::StringToUInt32(optarg, UINT32_MAX, 0); + m_thread_index = Args::StringToUInt32(option_arg, UINT32_MAX, 0); if (m_thread_id == UINT32_MAX) - error.SetErrorStringWithFormat ("Invalid thread index string '%s'.\n", optarg); + error.SetErrorStringWithFormat ("Invalid thread index string '%s'.\n", option_arg); } break; @@ -1421,23 +1421,23 @@ break; case 'i': { - m_ignore_count = Args::StringToUInt32(optarg, UINT32_MAX, 0); + m_ignore_count = Args::StringToUInt32(option_arg, UINT32_MAX, 0); if (m_ignore_count == UINT32_MAX) - error.SetErrorStringWithFormat ("Invalid ignore count '%s'.\n", optarg); + error.SetErrorStringWithFormat ("Invalid ignore count '%s'.\n", option_arg); } break; case 't' : { - if (optarg[0] == '\0') + if (option_arg[0] == '\0') { m_thread_id = LLDB_INVALID_THREAD_ID; m_thread_id_passed = true; } else { - m_thread_id = Args::StringToUInt64(optarg, LLDB_INVALID_THREAD_ID, 0); + m_thread_id = Args::StringToUInt64(option_arg, LLDB_INVALID_THREAD_ID, 0); if (m_thread_id == LLDB_INVALID_THREAD_ID) - error.SetErrorStringWithFormat ("Invalid thread id string '%s'.\n", optarg); + error.SetErrorStringWithFormat ("Invalid thread id string '%s'.\n", option_arg); else m_thread_id_passed = true; } @@ -1459,16 +1459,16 @@ break; case 'x': { - if (optarg[0] == '\n') + if (option_arg[0] == '\n') { m_thread_index = UINT32_MAX; m_thread_index_passed = true; } else { - m_thread_index = Args::StringToUInt32 (optarg, UINT32_MAX, 0); + m_thread_index = Args::StringToUInt32 (option_arg, UINT32_MAX, 0); if (m_thread_id == UINT32_MAX) - error.SetErrorStringWithFormat ("Invalid thread index string '%s'.\n", optarg); + error.SetErrorStringWithFormat ("Invalid thread index string '%s'.\n", option_arg); else m_thread_index_passed = true; } Modified: lldb/trunk/source/Commands/CommandObjectFile.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectFile.cpp?rev=128064&r1=128063&r2=128064&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectFile.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectFile.cpp Mon Mar 21 20:53:33 2011 @@ -62,7 +62,7 @@ if (option_arch.IsValid()) m_arch = option_arch; else - error.SetErrorStringWithFormat ("Invalid arch string '%s'.\n", optarg); + error.SetErrorStringWithFormat ("Invalid arch string '%s'.\n", option_arg); } break; Modified: lldb/trunk/source/Commands/CommandObjectTarget.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectTarget.cpp?rev=128064&r1=128063&r2=128064&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectTarget.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectTarget.cpp Mon Mar 21 20:53:33 2011 @@ -557,9 +557,9 @@ break; case 't' : { - m_thread_id = Args::StringToUInt64(optarg, LLDB_INVALID_THREAD_ID, 0); + m_thread_id = Args::StringToUInt64(option_arg, LLDB_INVALID_THREAD_ID, 0); if (m_thread_id == LLDB_INVALID_THREAD_ID) - error.SetErrorStringWithFormat ("Invalid thread id string '%s'.\n", optarg); + error.SetErrorStringWithFormat ("Invalid thread id string '%s'.\n", option_arg); m_thread_specified = true; } break; @@ -573,9 +573,9 @@ break; case 'x': { - m_thread_index = Args::StringToUInt32(optarg, UINT32_MAX, 0); + m_thread_index = Args::StringToUInt32(option_arg, UINT32_MAX, 0); if (m_thread_id == UINT32_MAX) - error.SetErrorStringWithFormat ("Invalid thread index string '%s'.\n", optarg); + error.SetErrorStringWithFormat ("Invalid thread index string '%s'.\n", option_arg); m_thread_specified = true; } break; From jingham at apple.com Mon Mar 21 21:29:32 2011 From: jingham at apple.com (Jim Ingham) Date: Tue, 22 Mar 2011 02:29:32 -0000 Subject: [Lldb-commits] [lldb] r128066 - /lldb/trunk/source/Interpreter/CommandInterpreter.cpp Message-ID: <20110322022932.8F14A2A6C12C@llvm.org> Author: jingham Date: Mon Mar 21 21:29:32 2011 New Revision: 128066 URL: http://llvm.org/viewvc/llvm-project?rev=128066&view=rev Log: Add "up" and "down" aliases. Modified: lldb/trunk/source/Interpreter/CommandInterpreter.cpp Modified: lldb/trunk/source/Interpreter/CommandInterpreter.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandInterpreter.cpp?rev=128066&r1=128065&r2=128066&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/CommandInterpreter.cpp (original) +++ lldb/trunk/source/Interpreter/CommandInterpreter.cpp Mon Mar 21 21:29:32 2011 @@ -114,6 +114,9 @@ HandleCommand ("command alias p frame variable", false, result); HandleCommand ("command alias print frame variable", false, result); HandleCommand ("command alias po expression -o --", false, result); + HandleCommand ("command alias up regexp-up", false, result); + HandleCommand ("command alias down regexp-down", false, result); + } const char * @@ -197,6 +200,36 @@ m_command_dict[break_regex_cmd_sp->GetCommandName ()] = break_regex_cmd_sp; } } + + std::auto_ptr + down_regex_cmd_ap(new CommandObjectRegexCommand (*this, + "regexp-down", + "Go down \"n\" frames in the stack (1 frame by default).", + "down [n]", 2)); + if (down_regex_cmd_ap.get()) + { + if (down_regex_cmd_ap->AddRegexCommand("^$", "frame select -r -1") && + down_regex_cmd_ap->AddRegexCommand("^([0-9]+)$", "frame select -r -%1")) + { + CommandObjectSP down_regex_cmd_sp(down_regex_cmd_ap.release()); + m_command_dict[down_regex_cmd_sp->GetCommandName ()] = down_regex_cmd_sp; + } + } + + std::auto_ptr + up_regex_cmd_ap(new CommandObjectRegexCommand (*this, + "regexp-up", + "Go up \"n\" frames in the stack (1 frame by default).", + "up [n]", 2)); + if (up_regex_cmd_ap.get()) + { + if (up_regex_cmd_ap->AddRegexCommand("^$", "frame select -r 1") && + up_regex_cmd_ap->AddRegexCommand("^([0-9]+)$", "frame select -r %1")) + { + CommandObjectSP up_regex_cmd_sp(up_regex_cmd_ap.release()); + m_command_dict[up_regex_cmd_sp->GetCommandName ()] = up_regex_cmd_sp; + } + } } int From gclayton at apple.com Mon Mar 21 23:00:09 2011 From: gclayton at apple.com (Greg Clayton) Date: Tue, 22 Mar 2011 04:00:09 -0000 Subject: [Lldb-commits] [lldb] r128070 - in /lldb/trunk: lldb.xcodeproj/ source/Plugins/Process/gdb-remote/ source/Utility/ tools/lldb-platform/ Message-ID: <20110322040010.0D6E12A6C12C@llvm.org> Author: gclayton Date: Mon Mar 21 23:00:09 2011 New Revision: 128070 URL: http://llvm.org/viewvc/llvm-project?rev=128070&view=rev Log: Split the GDBRemoteCommunication class into three classes: GDBRemoteCommunication - The base GDB remote communication class GDBRemoteCommunicationClient - designed to be used for clients the connect to a remote GDB server GDBRemoteCommunicationServer - designed to be used on the server side of a GDB server implementation. Added: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.h Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h lldb/trunk/source/Utility/StringExtractorGDBRemote.cpp lldb/trunk/source/Utility/StringExtractorGDBRemote.h lldb/trunk/tools/lldb-platform/lldb-platform.cpp Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=128070&r1=128069&r2=128070&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Mon Mar 21 23:00:09 2011 @@ -56,6 +56,10 @@ 26680336116005EF008E1FE4 /* SBBreakpointLocation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AF16CC7114086A1007A7B3F /* SBBreakpointLocation.cpp */; }; 26680337116005F1008E1FE4 /* SBBreakpoint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AF16A9C11402D5B007A7B3F /* SBBreakpoint.cpp */; }; 2668035C11601108008E1FE4 /* LLDB.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 26680207115FD0ED008E1FE4 /* LLDB.framework */; }; + 26744EF11338317700EF765A /* GDBRemoteCommunicationClient.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26744EED1338317700EF765A /* GDBRemoteCommunicationClient.cpp */; }; + 26744EF21338317700EF765A /* GDBRemoteCommunicationClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 26744EEE1338317700EF765A /* GDBRemoteCommunicationClient.h */; }; + 26744EF31338317700EF765A /* GDBRemoteCommunicationServer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26744EEF1338317700EF765A /* GDBRemoteCommunicationServer.cpp */; }; + 26744EF41338317700EF765A /* GDBRemoteCommunicationServer.h in Headers */ = {isa = PBXBuildFile; fileRef = 26744EF01338317700EF765A /* GDBRemoteCommunicationServer.h */; }; 2689000013353DB600698AC0 /* BreakpointResolverAddress.h in Headers */ = {isa = PBXBuildFile; fileRef = 26D0DD5010FE554D00271C65 /* BreakpointResolverAddress.h */; }; 2689000113353DB600698AC0 /* BreakpointResolverAddress.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26D0DD5310FE555900271C65 /* BreakpointResolverAddress.cpp */; }; 2689000213353DB600698AC0 /* BreakpointResolverFileLine.h in Headers */ = {isa = PBXBuildFile; fileRef = 26D0DD5110FE554D00271C65 /* BreakpointResolverFileLine.h */; }; @@ -635,6 +639,10 @@ 266F5CBB12FC846200DFCE33 /* Config.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Config.h; path = include/lldb/Host/Config.h; sourceTree = ""; }; 2672D8461189055500FF4019 /* CommandObjectFrame.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommandObjectFrame.cpp; path = source/Commands/CommandObjectFrame.cpp; sourceTree = ""; }; 2672D8471189055500FF4019 /* CommandObjectFrame.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CommandObjectFrame.h; path = source/Commands/CommandObjectFrame.h; sourceTree = ""; }; + 26744EED1338317700EF765A /* GDBRemoteCommunicationClient.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GDBRemoteCommunicationClient.cpp; sourceTree = ""; }; + 26744EEE1338317700EF765A /* GDBRemoteCommunicationClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GDBRemoteCommunicationClient.h; sourceTree = ""; }; + 26744EEF1338317700EF765A /* GDBRemoteCommunicationServer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GDBRemoteCommunicationServer.cpp; sourceTree = ""; }; + 26744EF01338317700EF765A /* GDBRemoteCommunicationServer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GDBRemoteCommunicationServer.h; sourceTree = ""; }; 2675F6FE1332BE690067997B /* PlatformRemoteiOS.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PlatformRemoteiOS.cpp; sourceTree = ""; }; 2675F6FF1332BE690067997B /* PlatformRemoteiOS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlatformRemoteiOS.h; sourceTree = ""; }; 2676A093119C93C8008A98EF /* StringExtractorGDBRemote.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = StringExtractorGDBRemote.cpp; path = source/Utility/StringExtractorGDBRemote.cpp; sourceTree = ""; }; @@ -2380,6 +2388,10 @@ children = ( 2618EE5B1315B29C001D6D71 /* GDBRemoteCommunication.cpp */, 2618EE5C1315B29C001D6D71 /* GDBRemoteCommunication.h */, + 26744EED1338317700EF765A /* GDBRemoteCommunicationClient.cpp */, + 26744EEE1338317700EF765A /* GDBRemoteCommunicationClient.h */, + 26744EEF1338317700EF765A /* GDBRemoteCommunicationServer.cpp */, + 26744EF01338317700EF765A /* GDBRemoteCommunicationServer.h */, 2618EE5D1315B29C001D6D71 /* GDBRemoteRegisterContext.cpp */, 2618EE5E1315B29C001D6D71 /* GDBRemoteRegisterContext.h */, 2618EE5F1315B29C001D6D71 /* ProcessGDBRemote.cpp */, @@ -2483,6 +2495,8 @@ 2689000C13353DB600698AC0 /* StoppointCallbackContext.h in Headers */, 2689000E13353DB600698AC0 /* StoppointLocation.h in Headers */, 2689001013353DB600698AC0 /* WatchpointLocation.h in Headers */, + 26744EF21338317700EF765A /* GDBRemoteCommunicationClient.h in Headers */, + 26744EF41338317700EF765A /* GDBRemoteCommunicationServer.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -3038,6 +3052,8 @@ 2689011213353E8200698AC0 /* StringExtractorGDBRemote.cpp in Sources */, 2689011313353E8200698AC0 /* PseudoTerminal.cpp in Sources */, 26B1FCC21338115F002886E2 /* Host.mm in Sources */, + 26744EF11338317700EF765A /* GDBRemoteCommunicationClient.cpp in Sources */, + 26744EF31338317700EF765A /* GDBRemoteCommunicationServer.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp?rev=128070&r1=128069&r2=128070&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp Mon Mar 21 23:00:09 2011 @@ -13,18 +13,11 @@ // C Includes // C++ Includes // Other libraries and framework includes -#include "llvm/ADT/Triple.h" -#include "lldb/Interpreter/Args.h" -#include "lldb/Core/ConnectionFileDescriptor.h" #include "lldb/Core/Log.h" -#include "lldb/Core/State.h" #include "lldb/Core/StreamString.h" -#include "lldb/Host/Host.h" #include "lldb/Host/TimeValue.h" // Project includes -#include "Utility/StringExtractorGDBRemote.h" -#include "ProcessGDBRemote.h" #include "ProcessGDBRemoteLog.h" using namespace lldb; @@ -33,32 +26,13 @@ //---------------------------------------------------------------------- // GDBRemoteCommunication constructor //---------------------------------------------------------------------- -GDBRemoteCommunication::GDBRemoteCommunication() : - Communication("gdb-remote.packets"), +GDBRemoteCommunication::GDBRemoteCommunication(const char *comm_name, const char *listener_name) : + Communication(comm_name), m_packet_timeout (1), - m_supports_not_sending_acks (eLazyBoolCalculate), - m_supports_thread_suffix (eLazyBoolCalculate), - m_supports_qHostInfo (eLazyBoolCalculate), - m_supports_vCont_all (eLazyBoolCalculate), - m_supports_vCont_any (eLazyBoolCalculate), - m_supports_vCont_c (eLazyBoolCalculate), - m_supports_vCont_C (eLazyBoolCalculate), - m_supports_vCont_s (eLazyBoolCalculate), - m_supports_vCont_S (eLazyBoolCalculate), - m_rx_packet_listener ("gdbremote.rx_packet"), + m_rx_packet_listener (listener_name), m_sequence_mutex (Mutex::eMutexTypeRecursive), m_public_is_running (false), - m_private_is_running (false), - m_async_mutex (Mutex::eMutexTypeRecursive), - m_async_packet_predicate (false), - m_async_packet (), - m_async_response (), - m_async_signal (-1), - m_arch(), - m_os(), - m_vendor(), - m_byte_order(lldb::endian::InlHostByteOrder()), - m_pointer_byte_size(0) + m_private_is_running (false) { m_rx_packet_listener.StartListeningForEvents(this, Communication::eBroadcastBitPacketAvailable | @@ -117,419 +91,6 @@ return Write (&nack_char, 1, status, NULL) == 1; } -bool -GDBRemoteCommunication::GetSendAcks () -{ - if (m_supports_not_sending_acks == eLazyBoolCalculate) - { - StringExtractorGDBRemote response; - m_supports_not_sending_acks = eLazyBoolNo; - if (SendPacketAndWaitForResponse("QStartNoAckMode", response, false)) - { - if (response.IsOKPacket()) - m_supports_not_sending_acks = eLazyBoolYes; - } - } - return m_supports_not_sending_acks != eLazyBoolYes; -} - -void -GDBRemoteCommunication::ResetDiscoverableSettings() -{ - m_supports_not_sending_acks = eLazyBoolCalculate; - m_supports_thread_suffix = eLazyBoolCalculate; - m_supports_qHostInfo = eLazyBoolCalculate; - m_supports_vCont_c = eLazyBoolCalculate; - m_supports_vCont_C = eLazyBoolCalculate; - m_supports_vCont_s = eLazyBoolCalculate; - m_supports_vCont_S = eLazyBoolCalculate; - m_arch.Clear(); - m_os.Clear(); - m_vendor.Clear(); - m_byte_order = lldb::endian::InlHostByteOrder(); - m_pointer_byte_size = 0; -} - - -bool -GDBRemoteCommunication::GetThreadSuffixSupported () -{ - if (m_supports_thread_suffix == eLazyBoolCalculate) - { - StringExtractorGDBRemote response; - m_supports_thread_suffix = eLazyBoolNo; - if (SendPacketAndWaitForResponse("QThreadSuffixSupported", response, false)) - { - if (response.IsOKPacket()) - m_supports_thread_suffix = eLazyBoolYes; - } - } - return m_supports_thread_suffix; -} -bool -GDBRemoteCommunication::GetVContSupported (char flavor) -{ - if (m_supports_vCont_c == eLazyBoolCalculate) - { - StringExtractorGDBRemote response; - m_supports_vCont_any = eLazyBoolNo; - m_supports_vCont_all = eLazyBoolNo; - m_supports_vCont_c = eLazyBoolNo; - m_supports_vCont_C = eLazyBoolNo; - m_supports_vCont_s = eLazyBoolNo; - m_supports_vCont_S = eLazyBoolNo; - if (SendPacketAndWaitForResponse("vCont?", response, false)) - { - const char *response_cstr = response.GetStringRef().c_str(); - if (::strstr (response_cstr, ";c")) - m_supports_vCont_c = eLazyBoolYes; - - if (::strstr (response_cstr, ";C")) - m_supports_vCont_C = eLazyBoolYes; - - if (::strstr (response_cstr, ";s")) - m_supports_vCont_s = eLazyBoolYes; - - if (::strstr (response_cstr, ";S")) - m_supports_vCont_S = eLazyBoolYes; - - if (m_supports_vCont_c == eLazyBoolYes && - m_supports_vCont_C == eLazyBoolYes && - m_supports_vCont_s == eLazyBoolYes && - m_supports_vCont_S == eLazyBoolYes) - { - m_supports_vCont_all = eLazyBoolYes; - } - - if (m_supports_vCont_c == eLazyBoolYes || - m_supports_vCont_C == eLazyBoolYes || - m_supports_vCont_s == eLazyBoolYes || - m_supports_vCont_S == eLazyBoolYes) - { - m_supports_vCont_any = eLazyBoolYes; - } - } - } - - switch (flavor) - { - case 'a': return m_supports_vCont_any; - case 'A': return m_supports_vCont_all; - case 'c': return m_supports_vCont_c; - case 'C': return m_supports_vCont_C; - case 's': return m_supports_vCont_s; - case 'S': return m_supports_vCont_S; - default: break; - } - return false; -} - - -size_t -GDBRemoteCommunication::SendPacketAndWaitForResponse -( - const char *payload, - StringExtractorGDBRemote &response, - bool send_async -) -{ - return SendPacketAndWaitForResponse (payload, - ::strlen (payload), - response, - send_async); -} - -size_t -GDBRemoteCommunication::SendPacketAndWaitForResponse -( - const char *payload, - size_t payload_length, - StringExtractorGDBRemote &response, - bool send_async -) -{ - Mutex::Locker locker; - TimeValue timeout_time; - timeout_time = TimeValue::Now(); - timeout_time.OffsetWithSeconds (m_packet_timeout); - LogSP log (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet (GDBR_LOG_PROCESS)); - - if (GetSequenceMutex (locker)) - { - if (SendPacketNoLock (payload, strlen(payload))) - return WaitForPacketNoLock (response, &timeout_time); - } - else - { - if (send_async) - { - Mutex::Locker async_locker (m_async_mutex); - m_async_packet.assign(payload, payload_length); - m_async_packet_predicate.SetValue (true, eBroadcastNever); - - if (log) - log->Printf ("async: async packet = %s", m_async_packet.c_str()); - - bool timed_out = false; - bool sent_interrupt = false; - if (SendInterrupt(locker, 2, sent_interrupt, timed_out)) - { - if (sent_interrupt) - { - if (log) - log->Printf ("async: sent interrupt"); - if (m_async_packet_predicate.WaitForValueEqualTo (false, &timeout_time, &timed_out)) - { - if (log) - log->Printf ("async: got response"); - response = m_async_response; - return response.GetStringRef().size(); - } - else - { - if (log) - log->Printf ("async: timed out waiting for response"); - } - - // Make sure we wait until the continue packet has been sent again... - if (m_private_is_running.WaitForValueEqualTo (true, &timeout_time, &timed_out)) - { - if (log) - log->Printf ("async: timed out waiting for process to resume"); - } - } - else - { - // We had a racy condition where we went to send the interrupt - // yet we were able to get the loc - } - } - else - { - if (log) - log->Printf ("async: failed to interrupt"); - } - } - else - { - if (log) - log->Printf ("mutex taken and send_async == false, aborting packet"); - } - } - return 0; -} - -//template -//class ScopedValueChanger -//{ -//public: -// // Take a value reference and the value to assign it to when this class -// // instance goes out of scope. -// ScopedValueChanger (_Tp &value_ref, _Tp value) : -// m_value_ref (value_ref), -// m_value (value) -// { -// } -// -// // This object is going out of scope, change the value pointed to by -// // m_value_ref to the value we got during construction which was stored in -// // m_value; -// ~ScopedValueChanger () -// { -// m_value_ref = m_value; -// } -//protected: -// _Tp &m_value_ref; // A reference to the value we will change when this object destructs -// _Tp m_value; // The value to assign to m_value_ref when this goes out of scope. -//}; - -StateType -GDBRemoteCommunication::SendContinuePacketAndWaitForResponse -( - ProcessGDBRemote *process, - const char *payload, - size_t packet_length, - StringExtractorGDBRemote &response -) -{ - LogSP log (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet (GDBR_LOG_PROCESS)); - if (log) - log->Printf ("GDBRemoteCommunication::%s ()", __FUNCTION__); - - Mutex::Locker locker(m_sequence_mutex); - StateType state = eStateRunning; - - BroadcastEvent(eBroadcastBitRunPacketSent, NULL); - m_public_is_running.SetValue (true, eBroadcastNever); - // Set the starting continue packet into "continue_packet". This packet - // make change if we are interrupted and we continue after an async packet... - std::string continue_packet(payload, packet_length); - - while (state == eStateRunning) - { - if (log) - log->Printf ("GDBRemoteCommunication::%s () sending continue packet: %s", __FUNCTION__, continue_packet.c_str()); - if (SendPacket(continue_packet.c_str(), continue_packet.size()) == 0) - state = eStateInvalid; - - m_private_is_running.SetValue (true, eBroadcastNever); - - if (log) - log->Printf ("GDBRemoteCommunication::%s () WaitForPacket(%.*s)", __FUNCTION__); - - if (WaitForPacket (response, (TimeValue*)NULL)) - { - if (response.Empty()) - state = eStateInvalid; - else - { - const char stop_type = response.GetChar(); - if (log) - log->Printf ("GDBRemoteCommunication::%s () got packet: %s", __FUNCTION__, response.GetStringRef().c_str()); - switch (stop_type) - { - case 'T': - case 'S': - if (process->GetStopID() == 0) - { - if (process->GetID() == LLDB_INVALID_PROCESS_ID) - { - lldb::pid_t pid = GetCurrentProcessID (); - if (pid != LLDB_INVALID_PROCESS_ID) - process->SetID (pid); - } - process->BuildDynamicRegisterInfo (true); - } - - // Privately notify any internal threads that we have stopped - // in case we wanted to interrupt our process, yet we might - // send a packet and continue without returning control to the - // user. - m_private_is_running.SetValue (false, eBroadcastAlways); - if (m_async_signal != -1) - { - if (log) - log->Printf ("async: send signo = %s", Host::GetSignalAsCString (m_async_signal)); - - // Save off the async signal we are supposed to send - const int async_signal = m_async_signal; - // Clear the async signal member so we don't end up - // sending the signal multiple times... - m_async_signal = -1; - // Check which signal we stopped with - uint8_t signo = response.GetHexU8(255); - if (signo == async_signal) - { - if (log) - log->Printf ("async: stopped with signal %s, we are done running", Host::GetSignalAsCString (signo)); - - // We already stopped with a signal that we wanted - // to stop with, so we are done - response.SetFilePos (0); - } - else - { - // We stopped with a different signal that the one - // we wanted to stop with, so now we must resume - // with the signal we want - char signal_packet[32]; - int signal_packet_len = 0; - signal_packet_len = ::snprintf (signal_packet, - sizeof (signal_packet), - "C%2.2x", - async_signal); - - if (log) - log->Printf ("async: stopped with signal %s, resume with %s", - Host::GetSignalAsCString (signo), - Host::GetSignalAsCString (async_signal)); - - // Set the continue packet to resume... - continue_packet.assign(signal_packet, signal_packet_len); - continue; - } - } - else if (m_async_packet_predicate.GetValue()) - { - // We are supposed to send an asynchronous packet while - // we are running. - m_async_response.Clear(); - if (m_async_packet.empty()) - { - if (log) - log->Printf ("async: error: empty async packet"); - - } - else - { - if (log) - log->Printf ("async: sending packet: %s", - m_async_packet.c_str()); - - SendPacketAndWaitForResponse (&m_async_packet[0], - m_async_packet.size(), - m_async_response, - false); - } - // Let the other thread that was trying to send the async - // packet know that the packet has been sent and response is - // ready... - m_async_packet_predicate.SetValue(false, eBroadcastAlways); - - // Set the continue packet to resume... - continue_packet.assign (1, 'c'); - continue; - } - // Stop with signal and thread info - state = eStateStopped; - break; - - case 'W': - case 'X': - // process exited - state = eStateExited; - break; - - case 'O': - // STDOUT - { - std::string inferior_stdout; - inferior_stdout.reserve(response.GetBytesLeft () / 2); - char ch; - while ((ch = response.GetHexU8()) != '\0') - inferior_stdout.append(1, ch); - process->AppendSTDOUT (inferior_stdout.c_str(), inferior_stdout.size()); - } - break; - - case 'E': - // ERROR - state = eStateInvalid; - break; - - default: - if (log) - log->Printf ("GDBRemoteCommunication::%s () unrecognized async packet", __FUNCTION__); - state = eStateInvalid; - break; - } - } - } - else - { - if (log) - log->Printf ("GDBRemoteCommunication::%s () WaitForPacket(...) => false", __FUNCTION__); - state = eStateInvalid; - } - } - if (log) - log->Printf ("GDBRemoteCommunication::%s () => %s", __FUNCTION__, StateAsCString(state)); - response.SetFilePos(0); - m_private_is_running.SetValue (false, eBroadcastAlways); - m_public_is_running.SetValue (false, eBroadcastAlways); - return state; -} - size_t GDBRemoteCommunication::SendPacket (const char *payload) { @@ -583,9 +144,9 @@ char GDBRemoteCommunication::GetAck () { - StringExtractorGDBRemote response; - if (WaitForPacket (response, m_packet_timeout) == 1) - return response.GetChar(); + StringExtractorGDBRemote packet; + if (WaitForPacket (packet, m_packet_timeout) == 1) + return packet.GetChar(); return 0; } @@ -595,98 +156,6 @@ return locker.TryLock (m_sequence_mutex.GetMutex()); } -bool -GDBRemoteCommunication::SendAsyncSignal (int signo) -{ - m_async_signal = signo; - bool timed_out = false; - bool sent_interrupt = false; - Mutex::Locker locker; - if (SendInterrupt (locker, 1, sent_interrupt, timed_out)) - return true; - m_async_signal = -1; - return false; -} - -// This function takes a mutex locker as a parameter in case the GetSequenceMutex -// actually succeeds. If it doesn't succeed in acquiring the sequence mutex -// (the expected result), then it will send the halt packet. If it does succeed -// then the caller that requested the interrupt will want to keep the sequence -// locked down so that no one else can send packets while the caller has control. -// This function usually gets called when we are running and need to stop the -// target. It can also be used when we are running and and we need to do something -// else (like read/write memory), so we need to interrupt the running process -// (gdb remote protocol requires this), and do what we need to do, then resume. - -bool -GDBRemoteCommunication::SendInterrupt -( - Mutex::Locker& locker, - uint32_t seconds_to_wait_for_stop, - bool &sent_interrupt, - bool &timed_out -) -{ - sent_interrupt = false; - timed_out = false; - LogSP log (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet (GDBR_LOG_PROCESS)); - - if (IsRunning()) - { - // Only send an interrupt if our debugserver is running... - if (GetSequenceMutex (locker) == false) - { - // Someone has the mutex locked waiting for a response or for the - // inferior to stop, so send the interrupt on the down low... - char ctrl_c = '\x03'; - ConnectionStatus status = eConnectionStatusSuccess; - TimeValue timeout; - if (seconds_to_wait_for_stop) - { - timeout = TimeValue::Now(); - timeout.OffsetWithSeconds (seconds_to_wait_for_stop); - } - size_t bytes_written = Write (&ctrl_c, 1, status, NULL); - ProcessGDBRemoteLog::LogIf (GDBR_LOG_PACKETS | GDBR_LOG_PROCESS, "send packet: \\x03"); - if (bytes_written > 0) - { - sent_interrupt = true; - if (seconds_to_wait_for_stop) - { - if (m_private_is_running.WaitForValueEqualTo (false, &timeout, &timed_out)) - { - if (log) - log->Printf ("GDBRemoteCommunication::%s () - sent interrupt, private state stopped", __FUNCTION__); - return true; - } - else - { - if (log) - log->Printf ("GDBRemoteCommunication::%s () - sent interrupt, timed out wating for async thread resume", __FUNCTION__); - } - } - else - { - if (log) - log->Printf ("GDBRemoteCommunication::%s () - sent interrupt, not waiting for stop...", __FUNCTION__); - return true; - } - } - else - { - if (log) - log->Printf ("GDBRemoteCommunication::%s () - failed to write interrupt", __FUNCTION__); - } - return false; - } - else - { - if (log) - log->Printf ("GDBRemoteCommunication::%s () - got sequence mutex without having to interrupt", __FUNCTION__); - } - } - return true; -} bool GDBRemoteCommunication::WaitForNotRunningPrivate (const TimeValue *timeout_ptr) @@ -695,27 +164,27 @@ } size_t -GDBRemoteCommunication::WaitForPacket (StringExtractorGDBRemote &response, uint32_t timeout_seconds) +GDBRemoteCommunication::WaitForPacket (StringExtractorGDBRemote &packet, uint32_t timeout_seconds) { Mutex::Locker locker(m_sequence_mutex); TimeValue timeout_time; timeout_time = TimeValue::Now(); timeout_time.OffsetWithSeconds (timeout_seconds); - return WaitForPacketNoLock (response, &timeout_time); + return WaitForPacketNoLock (packet, &timeout_time); } size_t -GDBRemoteCommunication::WaitForPacket (StringExtractorGDBRemote &response, const TimeValue* timeout_time_ptr) +GDBRemoteCommunication::WaitForPacket (StringExtractorGDBRemote &packet, const TimeValue* timeout_time_ptr) { Mutex::Locker locker(m_sequence_mutex); - return WaitForPacketNoLock (response, timeout_time_ptr); + return WaitForPacketNoLock (packet, timeout_time_ptr); } size_t -GDBRemoteCommunication::WaitForPacketNoLock (StringExtractorGDBRemote &response, const TimeValue* timeout_time_ptr) +GDBRemoteCommunication::WaitForPacketNoLock (StringExtractorGDBRemote &packet, const TimeValue* timeout_time_ptr) { bool checksum_error = false; - response.Clear (); + packet.Clear (); EventSP event_sp; @@ -734,7 +203,7 @@ const size_t packet_size = event_bytes->GetByteSize(); if (packet_data && packet_size > 0) { - std::string &response_str = response.GetStringRef(); + std::string &packet_str = packet.GetStringRef(); if (packet_data[0] == '$') { bool success = false; @@ -748,11 +217,11 @@ success = true; if (success) - response_str.assign (packet_data + 1, packet_size - 4); + packet_str.assign (packet_data + 1, packet_size - 4); if (GetSendAcks ()) { char packet_checksum = strtol (&packet_data[packet_size-2], NULL, 16); - char actual_checksum = CalculcateChecksum (&response_str[0], response_str.size()); + char actual_checksum = CalculcateChecksum (&packet_str[0], packet_str.size()); checksum_error = packet_checksum != actual_checksum; // Send the ack or nack if needed if (checksum_error || !success) @@ -763,9 +232,9 @@ } else { - response_str.assign (packet_data, packet_size); + packet_str.assign (packet_data, packet_size); } - return response_str.size(); + return packet_str.size(); } } } @@ -845,353 +314,3 @@ } } -lldb::pid_t -GDBRemoteCommunication::GetCurrentProcessID () -{ - StringExtractorGDBRemote response; - if (SendPacketAndWaitForResponse("qC", strlen("qC"), response, false)) - { - if (response.GetChar() == 'Q') - if (response.GetChar() == 'C') - return response.GetHexMaxU32 (false, LLDB_INVALID_PROCESS_ID); - } - return LLDB_INVALID_PROCESS_ID; -} - -bool -GDBRemoteCommunication::GetLaunchSuccess (std::string &error_str) -{ - error_str.clear(); - StringExtractorGDBRemote response; - if (SendPacketAndWaitForResponse("qLaunchSuccess", strlen("qLaunchSuccess"), response, false)) - { - if (response.IsOKPacket()) - return true; - if (response.GetChar() == 'E') - { - // A string the describes what failed when launching... - error_str = response.GetStringRef().substr(1); - } - else - { - error_str.assign ("unknown error occurred launching process"); - } - } - else - { - error_str.assign ("failed to send the qLaunchSuccess packet"); - } - return false; -} - -int -GDBRemoteCommunication::SendArgumentsPacket (char const *argv[]) -{ - if (argv && argv[0]) - { - StreamString packet; - packet.PutChar('A'); - const char *arg; - for (uint32_t i = 0; (arg = argv[i]) != NULL; ++i) - { - const int arg_len = strlen(arg); - if (i > 0) - packet.PutChar(','); - packet.Printf("%i,%i,", arg_len * 2, i); - packet.PutBytesAsRawHex8 (arg, arg_len); - } - - StringExtractorGDBRemote response; - if (SendPacketAndWaitForResponse (packet.GetData(), packet.GetSize(), response, false)) - { - if (response.IsOKPacket()) - return 0; - uint8_t error = response.GetError(); - if (error) - return error; - } - } - return -1; -} - -int -GDBRemoteCommunication::SendEnvironmentPacket (char const *name_equal_value) -{ - if (name_equal_value && name_equal_value[0]) - { - StreamString packet; - packet.Printf("QEnvironment:%s", name_equal_value); - StringExtractorGDBRemote response; - if (SendPacketAndWaitForResponse (packet.GetData(), packet.GetSize(), response, false)) - { - if (response.IsOKPacket()) - return 0; - uint8_t error = response.GetError(); - if (error) - return error; - } - } - return -1; -} - -bool -GDBRemoteCommunication::GetHostInfo () -{ - if (m_supports_qHostInfo == eLazyBoolCalculate) - { - m_supports_qHostInfo = eLazyBoolNo; - - StringExtractorGDBRemote response; - if (SendPacketAndWaitForResponse ("qHostInfo", response, false)) - { - if (response.IsUnsupportedPacket()) - return false; - - m_supports_qHostInfo = eLazyBoolYes; - - std::string name; - std::string value; - uint32_t cpu = LLDB_INVALID_CPUTYPE; - uint32_t sub = 0; - - while (response.GetNameColonValue(name, value)) - { - if (name.compare("cputype") == 0) - { - // exception type in big endian hex - cpu = Args::StringToUInt32 (value.c_str(), LLDB_INVALID_CPUTYPE, 0); - } - else if (name.compare("cpusubtype") == 0) - { - // exception count in big endian hex - sub = Args::StringToUInt32 (value.c_str(), 0, 0); - } - else if (name.compare("ostype") == 0) - { - // exception data in big endian hex - m_os.SetCString(value.c_str()); - } - else if (name.compare("vendor") == 0) - { - m_vendor.SetCString(value.c_str()); - } - else if (name.compare("endian") == 0) - { - if (value.compare("little") == 0) - m_byte_order = eByteOrderLittle; - else if (value.compare("big") == 0) - m_byte_order = eByteOrderBig; - else if (value.compare("pdp") == 0) - m_byte_order = eByteOrderPDP; - } - else if (name.compare("ptrsize") == 0) - { - m_pointer_byte_size = Args::StringToUInt32 (value.c_str(), 0, 0); - } - } - - if (cpu != LLDB_INVALID_CPUTYPE) - m_arch.SetArchitecture (lldb::eArchTypeMachO, cpu, sub); - } - } - return m_supports_qHostInfo == eLazyBoolYes; -} - -int -GDBRemoteCommunication::SendAttach -( - lldb::pid_t pid, - StringExtractorGDBRemote& response -) -{ - if (pid != LLDB_INVALID_PROCESS_ID) - { - StreamString packet; - packet.Printf("vAttach;%x", pid); - - if (SendPacketAndWaitForResponse (packet.GetData(), packet.GetSize(), response, false)) - { - if (response.IsErrorPacket()) - return response.GetError(); - return 0; - } - } - return -1; -} - -const lldb_private::ArchSpec & -GDBRemoteCommunication::GetHostArchitecture () -{ - if (!HostInfoIsValid ()) - GetHostInfo (); - return m_arch; -} - -const lldb_private::ConstString & -GDBRemoteCommunication::GetOSString () -{ - if (!HostInfoIsValid ()) - GetHostInfo (); - return m_os; -} - -const lldb_private::ConstString & -GDBRemoteCommunication::GetVendorString() -{ - if (!HostInfoIsValid ()) - GetHostInfo (); - return m_vendor; -} - -lldb::ByteOrder -GDBRemoteCommunication::GetByteOrder () -{ - if (!HostInfoIsValid ()) - GetHostInfo (); - return m_byte_order; -} - -uint32_t -GDBRemoteCommunication::GetAddressByteSize () -{ - if (!HostInfoIsValid ()) - GetHostInfo (); - return m_pointer_byte_size; -} - -addr_t -GDBRemoteCommunication::AllocateMemory (size_t size, uint32_t permissions) -{ - char packet[64]; - ::snprintf (packet, sizeof(packet), "_M%zx,%s%s%s", size, - permissions & lldb::ePermissionsReadable ? "r" : "", - permissions & lldb::ePermissionsWritable ? "w" : "", - permissions & lldb::ePermissionsExecutable ? "x" : ""); - StringExtractorGDBRemote response; - if (SendPacketAndWaitForResponse (packet, response, false)) - { - if (!response.IsErrorPacket()) - return response.GetHexMaxU64(false, LLDB_INVALID_ADDRESS); - } - return LLDB_INVALID_ADDRESS; -} - -bool -GDBRemoteCommunication::DeallocateMemory (addr_t addr) -{ - char packet[64]; - snprintf(packet, sizeof(packet), "_m%llx", (uint64_t)addr); - StringExtractorGDBRemote response; - if (SendPacketAndWaitForResponse (packet, response, false)) - { - if (response.IsOKPacket()) - return true; - } - return false; -} - -int -GDBRemoteCommunication::SetSTDIN (char const *path) -{ - if (path && path[0]) - { - StreamString packet; - packet.PutCString("QSetSTDIN:"); - packet.PutBytesAsRawHex8(path, strlen(path)); - - StringExtractorGDBRemote response; - if (SendPacketAndWaitForResponse (packet.GetData(), packet.GetSize(), response, false)) - { - if (response.IsOKPacket()) - return 0; - uint8_t error = response.GetError(); - if (error) - return error; - } - } - return -1; -} - -int -GDBRemoteCommunication::SetSTDOUT (char const *path) -{ - if (path && path[0]) - { - StreamString packet; - packet.PutCString("QSetSTDOUT:"); - packet.PutBytesAsRawHex8(path, strlen(path)); - - StringExtractorGDBRemote response; - if (SendPacketAndWaitForResponse (packet.GetData(), packet.GetSize(), response, false)) - { - if (response.IsOKPacket()) - return 0; - uint8_t error = response.GetError(); - if (error) - return error; - } - } - return -1; -} - -int -GDBRemoteCommunication::SetSTDERR (char const *path) -{ - if (path && path[0]) - { - StreamString packet; - packet.PutCString("QSetSTDERR:"); - packet.PutBytesAsRawHex8(path, strlen(path)); - - StringExtractorGDBRemote response; - if (SendPacketAndWaitForResponse (packet.GetData(), packet.GetSize(), response, false)) - { - if (response.IsOKPacket()) - return 0; - uint8_t error = response.GetError(); - if (error) - return error; - } - } - return -1; -} - -int -GDBRemoteCommunication::SetWorkingDir (char const *path) -{ - if (path && path[0]) - { - StreamString packet; - packet.PutCString("QSetWorkingDir:"); - packet.PutBytesAsRawHex8(path, strlen(path)); - - StringExtractorGDBRemote response; - if (SendPacketAndWaitForResponse (packet.GetData(), packet.GetSize(), response, false)) - { - if (response.IsOKPacket()) - return 0; - uint8_t error = response.GetError(); - if (error) - return error; - } - } - return -1; -} - -int -GDBRemoteCommunication::SetDisableASLR (bool enable) -{ - StreamString packet; - packet.Printf("QSetDisableASLR:%i", enable ? 1 : 0); - - StringExtractorGDBRemote response; - if (SendPacketAndWaitForResponse (packet.GetData(), packet.GetSize(), response, false)) - { - if (response.IsOKPacket()) - return 0; - uint8_t error = response.GetError(); - if (error) - return error; - } - return -1; -} Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h?rev=128070&r1=128069&r2=128070&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h Mon Mar 21 23:00:09 2011 @@ -18,10 +18,7 @@ // Other libraries and framework includes // Project includes #include "lldb/lldb-private.h" -#include "lldb/Core/ArchSpec.h" #include "lldb/Core/Communication.h" -#include "lldb/Core/ConstString.h" -#include "lldb/Core/Error.h" #include "lldb/Core/Listener.h" #include "lldb/Host/Mutex.h" #include "lldb/Host/Predicate.h" @@ -30,8 +27,7 @@ class ProcessGDBRemote; -class GDBRemoteCommunication : - public lldb_private::Communication +class GDBRemoteCommunication : public lldb_private::Communication { public: enum @@ -41,7 +37,7 @@ //------------------------------------------------------------------ // Constructors and Destructors //------------------------------------------------------------------ - GDBRemoteCommunication(); + GDBRemoteCommunication(const char *comm_name, const char *listener_name); virtual ~GDBRemoteCommunication(); @@ -53,23 +49,6 @@ SendPacket (const char *payload, size_t payload_length); - size_t - SendPacketAndWaitForResponse (const char *send_payload, - StringExtractorGDBRemote &response, - bool send_async); - - size_t - SendPacketAndWaitForResponse (const char *send_payload, - size_t send_length, - StringExtractorGDBRemote &response, - bool send_async); - - lldb::StateType - SendContinuePacketAndWaitForResponse (ProcessGDBRemote *process, - const char *packet_payload, - size_t packet_length, - StringExtractorGDBRemote &response); - // Wait for a packet within 'nsec' seconds size_t WaitForPacket (StringExtractorGDBRemote &response, @@ -90,24 +69,11 @@ size_t SendNack (); - char CalculcateChecksum (const char *payload, size_t payload_length); bool - GetThreadSuffixSupported (); - - bool - SendAsyncSignal (int signo); - - bool - SendInterrupt (lldb_private::Mutex::Locker &locker, - uint32_t seconds_to_wait_for_stop, - bool &sent_interrupt, - bool &timed_out); - - bool GetSequenceMutex(lldb_private::Mutex::Locker& locker); //------------------------------------------------------------------ @@ -116,167 +82,29 @@ virtual void AppendBytesToCache (const uint8_t *src, size_t src_len, bool broadcast, lldb::ConnectionStatus status); - - lldb::pid_t - GetCurrentProcessID (); - - bool - GetLaunchSuccess (std::string &error_str); - - //------------------------------------------------------------------ - /// Sends a GDB remote protocol 'A' packet that delivers program - /// arguments to the remote server. - /// - /// @param[in] argv - /// A NULL terminated array of const C strings to use as the - /// arguments. - /// - /// @return - /// Zero if the response was "OK", a positive value if the - /// the response was "Exx" where xx are two hex digits, or - /// -1 if the call is unsupported or any other unexpected - /// response was received. - //------------------------------------------------------------------ - int - SendArgumentsPacket (char const *argv[]); - - //------------------------------------------------------------------ - /// Sends a "QEnvironment:NAME=VALUE" packet that will build up the - /// environment that will get used when launching an application - /// in conjunction with the 'A' packet. This function can be called - /// multiple times in a row in order to pass on the desired - /// environment that the inferior should be launched with. - /// - /// @param[in] name_equal_value - /// A NULL terminated C string that contains a single environment - /// in the format "NAME=VALUE". - /// - /// @return - /// Zero if the response was "OK", a positive value if the - /// the response was "Exx" where xx are two hex digits, or - /// -1 if the call is unsupported or any other unexpected - /// response was received. - //------------------------------------------------------------------ - int - SendEnvironmentPacket (char const *name_equal_value); - - //------------------------------------------------------------------ - /// Sends a "vAttach:PID" where PID is in hex. - /// - /// @param[in] pid - /// A process ID for the remote gdb server to attach to. - /// - /// @param[out] response - /// The response received from the gdb server. If the return - /// value is zero, \a response will contain a stop reply - /// packet. - /// - /// @return - /// Zero if the attach was successful, or an error indicating - /// an error code. - //------------------------------------------------------------------ - int - SendAttach (lldb::pid_t pid, - StringExtractorGDBRemote& response); - - - //------------------------------------------------------------------ - /// Sets the path to use for stdin/out/err for a process - /// that will be launched with the 'A' packet. - /// - /// @param[in] path - /// The path to use for stdin/out/err - /// - /// @return - /// Zero if the for success, or an error code for failure. - //------------------------------------------------------------------ - int - SetSTDIN (char const *path); - int - SetSTDOUT (char const *path); - int - SetSTDERR (char const *path); - - //------------------------------------------------------------------ - /// Sets the disable ASLR flag to \a enable for a process that will - /// be launched with the 'A' packet. - /// - /// @param[in] enable - /// A boolean value indicating wether to disable ASLR or not. - /// - /// @return - /// Zero if the for success, or an error code for failure. - //------------------------------------------------------------------ - int - SetDisableASLR (bool enable); - - //------------------------------------------------------------------ - /// Sets the working directory to \a path for a process that will - /// be launched with the 'A' packet. - /// - /// @param[in] path - /// The path to a directory to use when launching our processs - /// - /// @return - /// Zero if the for success, or an error code for failure. - //------------------------------------------------------------------ - int - SetWorkingDir (char const *path); - - lldb::addr_t - AllocateMemory (size_t size, uint32_t permissions); - - bool - DeallocateMemory (lldb::addr_t addr); - bool IsRunning() const { return m_public_is_running.GetValue(); } - const lldb_private::ArchSpec & - GetHostArchitecture (); - - const lldb_private::ConstString & - GetOSString (); - - const lldb_private::ConstString & - GetVendorString(); - - lldb::ByteOrder - GetByteOrder (); - - uint32_t - GetAddressByteSize (); - - bool - GetVContSupported (char flavor); - - void - ResetDiscoverableSettings(); - - bool - GetHostInfo (); - - bool - GetSendAcks (); - - bool - GetSupportsThreadSuffix (); - - bool - HasFullVContSupport () - { - return GetVContSupported ('A'); - } + //------------------------------------------------------------------ + // Client and server must implement these pure virtual functions + //------------------------------------------------------------------ + virtual bool + GetThreadSuffixSupported () = 0; - bool - HasAnyVContSupport () - { - return GetVContSupported ('a'); - } + virtual bool + GetSendAcks () = 0; + //------------------------------------------------------------------ + // Set the global packet timeout. + // + // For clients, this is the timeout that gets used when sending + // packets and waiting for responses. For servers, this might not + // get used, and if it doesn't this should be moved to the + // GDBRemoteCommunicationClient. + //------------------------------------------------------------------ uint32_t SetPacketTimeout (uint32_t packet_timeout) { @@ -299,46 +127,15 @@ bool WaitForNotRunningPrivate (const lldb_private::TimeValue *timeout_ptr); - bool - HostInfoIsValid () const - { - return m_supports_qHostInfo != lldb::eLazyBoolCalculate; - } - //------------------------------------------------------------------ // Classes that inherit from GDBRemoteCommunication can see and modify these //------------------------------------------------------------------ uint32_t m_packet_timeout; - lldb::LazyBool m_supports_not_sending_acks; - lldb::LazyBool m_supports_thread_suffix; - lldb::LazyBool m_supports_qHostInfo; - lldb::LazyBool m_supports_vCont_all; - lldb::LazyBool m_supports_vCont_any; - lldb::LazyBool m_supports_vCont_c; - lldb::LazyBool m_supports_vCont_C; - lldb::LazyBool m_supports_vCont_s; - lldb::LazyBool m_supports_vCont_S; lldb_private::Listener m_rx_packet_listener; lldb_private::Mutex m_sequence_mutex; // Restrict access to sending/receiving packets to a single thread at a time lldb_private::Predicate m_public_is_running; lldb_private::Predicate m_private_is_running; - // If we need to send a packet while the target is running, the m_async_XXX - // member variables take care of making this happen. - lldb_private::Mutex m_async_mutex; - lldb_private::Predicate m_async_packet_predicate; - std::string m_async_packet; - StringExtractorGDBRemote m_async_response; - int m_async_signal; // We were asked to deliver a signal to the inferior process. - - lldb_private::ArchSpec m_arch; // Results from the qHostInfo call - uint32_t m_cpusubtype; // Results from the qHostInfo call - lldb_private::ConstString m_os; // Results from the qHostInfo call - lldb_private::ConstString m_vendor; // Results from the qHostInfo call - lldb::ByteOrder m_byte_order; // Results from the qHostInfo call - uint32_t m_pointer_byte_size; // Results from the qHostInfo call - - private: //------------------------------------------------------------------ // For GDBRemoteCommunication only Added: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp?rev=128070&view=auto ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp (added) +++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp Mon Mar 21 23:00:09 2011 @@ -0,0 +1,934 @@ +//===-- GDBRemoteCommunicationClient.cpp ------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + + +#include "GDBRemoteCommunicationClient.h" + +// C Includes +// C++ Includes +// Other libraries and framework includes +#include "llvm/ADT/Triple.h" +#include "lldb/Interpreter/Args.h" +#include "lldb/Core/ConnectionFileDescriptor.h" +#include "lldb/Core/Log.h" +#include "lldb/Core/State.h" +#include "lldb/Core/StreamString.h" +#include "lldb/Host/Endian.h" +#include "lldb/Host/Host.h" +#include "lldb/Host/TimeValue.h" + +// Project includes +#include "Utility/StringExtractorGDBRemote.h" +#include "ProcessGDBRemote.h" +#include "ProcessGDBRemoteLog.h" + +using namespace lldb; +using namespace lldb_private; + +//---------------------------------------------------------------------- +// GDBRemoteCommunicationClient constructor +//---------------------------------------------------------------------- +GDBRemoteCommunicationClient::GDBRemoteCommunicationClient() : + GDBRemoteCommunication("gdb-remote.client", "gdb-remote.client.rx_packet"), + m_supports_not_sending_acks (eLazyBoolCalculate), + m_supports_thread_suffix (eLazyBoolCalculate), + m_supports_qHostInfo (eLazyBoolCalculate), + m_supports_vCont_all (eLazyBoolCalculate), + m_supports_vCont_any (eLazyBoolCalculate), + m_supports_vCont_c (eLazyBoolCalculate), + m_supports_vCont_C (eLazyBoolCalculate), + m_supports_vCont_s (eLazyBoolCalculate), + m_supports_vCont_S (eLazyBoolCalculate), + m_async_mutex (Mutex::eMutexTypeRecursive), + m_async_packet_predicate (false), + m_async_packet (), + m_async_response (), + m_async_signal (-1), + m_arch(), + m_os(), + m_vendor(), + m_byte_order(lldb::endian::InlHostByteOrder()), + m_pointer_byte_size(0) +{ + m_rx_packet_listener.StartListeningForEvents(this, + Communication::eBroadcastBitPacketAvailable | + Communication::eBroadcastBitReadThreadDidExit); +} + +//---------------------------------------------------------------------- +// Destructor +//---------------------------------------------------------------------- +GDBRemoteCommunicationClient::~GDBRemoteCommunicationClient() +{ + m_rx_packet_listener.StopListeningForEvents(this, + Communication::eBroadcastBitPacketAvailable | + Communication::eBroadcastBitReadThreadDidExit); + if (IsConnected()) + { + StopReadThread(); + Disconnect(); + } +} + +bool +GDBRemoteCommunicationClient::GetSendAcks () +{ + if (m_supports_not_sending_acks == eLazyBoolCalculate) + { + StringExtractorGDBRemote response; + m_supports_not_sending_acks = eLazyBoolNo; + if (SendPacketAndWaitForResponse("QStartNoAckMode", response, false)) + { + if (response.IsOKResponse()) + m_supports_not_sending_acks = eLazyBoolYes; + } + } + return m_supports_not_sending_acks != eLazyBoolYes; +} + +void +GDBRemoteCommunicationClient::ResetDiscoverableSettings() +{ + m_supports_not_sending_acks = eLazyBoolCalculate; + m_supports_thread_suffix = eLazyBoolCalculate; + m_supports_qHostInfo = eLazyBoolCalculate; + m_supports_vCont_c = eLazyBoolCalculate; + m_supports_vCont_C = eLazyBoolCalculate; + m_supports_vCont_s = eLazyBoolCalculate; + m_supports_vCont_S = eLazyBoolCalculate; + m_arch.Clear(); + m_os.Clear(); + m_vendor.Clear(); + m_byte_order = lldb::endian::InlHostByteOrder(); + m_pointer_byte_size = 0; +} + + +bool +GDBRemoteCommunicationClient::GetThreadSuffixSupported () +{ + if (m_supports_thread_suffix == eLazyBoolCalculate) + { + StringExtractorGDBRemote response; + m_supports_thread_suffix = eLazyBoolNo; + if (SendPacketAndWaitForResponse("QThreadSuffixSupported", response, false)) + { + if (response.IsOKResponse()) + m_supports_thread_suffix = eLazyBoolYes; + } + } + return m_supports_thread_suffix; +} +bool +GDBRemoteCommunicationClient::GetVContSupported (char flavor) +{ + if (m_supports_vCont_c == eLazyBoolCalculate) + { + StringExtractorGDBRemote response; + m_supports_vCont_any = eLazyBoolNo; + m_supports_vCont_all = eLazyBoolNo; + m_supports_vCont_c = eLazyBoolNo; + m_supports_vCont_C = eLazyBoolNo; + m_supports_vCont_s = eLazyBoolNo; + m_supports_vCont_S = eLazyBoolNo; + if (SendPacketAndWaitForResponse("vCont?", response, false)) + { + const char *response_cstr = response.GetStringRef().c_str(); + if (::strstr (response_cstr, ";c")) + m_supports_vCont_c = eLazyBoolYes; + + if (::strstr (response_cstr, ";C")) + m_supports_vCont_C = eLazyBoolYes; + + if (::strstr (response_cstr, ";s")) + m_supports_vCont_s = eLazyBoolYes; + + if (::strstr (response_cstr, ";S")) + m_supports_vCont_S = eLazyBoolYes; + + if (m_supports_vCont_c == eLazyBoolYes && + m_supports_vCont_C == eLazyBoolYes && + m_supports_vCont_s == eLazyBoolYes && + m_supports_vCont_S == eLazyBoolYes) + { + m_supports_vCont_all = eLazyBoolYes; + } + + if (m_supports_vCont_c == eLazyBoolYes || + m_supports_vCont_C == eLazyBoolYes || + m_supports_vCont_s == eLazyBoolYes || + m_supports_vCont_S == eLazyBoolYes) + { + m_supports_vCont_any = eLazyBoolYes; + } + } + } + + switch (flavor) + { + case 'a': return m_supports_vCont_any; + case 'A': return m_supports_vCont_all; + case 'c': return m_supports_vCont_c; + case 'C': return m_supports_vCont_C; + case 's': return m_supports_vCont_s; + case 'S': return m_supports_vCont_S; + default: break; + } + return false; +} + + +size_t +GDBRemoteCommunicationClient::SendPacketAndWaitForResponse +( + const char *payload, + StringExtractorGDBRemote &response, + bool send_async +) +{ + return SendPacketAndWaitForResponse (payload, + ::strlen (payload), + response, + send_async); +} + +size_t +GDBRemoteCommunicationClient::SendPacketAndWaitForResponse +( + const char *payload, + size_t payload_length, + StringExtractorGDBRemote &response, + bool send_async +) +{ + Mutex::Locker locker; + TimeValue timeout_time; + timeout_time = TimeValue::Now(); + timeout_time.OffsetWithSeconds (m_packet_timeout); + LogSP log (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet (GDBR_LOG_PROCESS)); + + if (GetSequenceMutex (locker)) + { + if (SendPacketNoLock (payload, strlen(payload))) + return WaitForPacketNoLock (response, &timeout_time); + } + else + { + if (send_async) + { + Mutex::Locker async_locker (m_async_mutex); + m_async_packet.assign(payload, payload_length); + m_async_packet_predicate.SetValue (true, eBroadcastNever); + + if (log) + log->Printf ("async: async packet = %s", m_async_packet.c_str()); + + bool timed_out = false; + bool sent_interrupt = false; + if (SendInterrupt(locker, 2, sent_interrupt, timed_out)) + { + if (sent_interrupt) + { + if (log) + log->Printf ("async: sent interrupt"); + if (m_async_packet_predicate.WaitForValueEqualTo (false, &timeout_time, &timed_out)) + { + if (log) + log->Printf ("async: got response"); + response = m_async_response; + return response.GetStringRef().size(); + } + else + { + if (log) + log->Printf ("async: timed out waiting for response"); + } + + // Make sure we wait until the continue packet has been sent again... + if (m_private_is_running.WaitForValueEqualTo (true, &timeout_time, &timed_out)) + { + if (log) + log->Printf ("async: timed out waiting for process to resume"); + } + } + else + { + // We had a racy condition where we went to send the interrupt + // yet we were able to get the loc + } + } + else + { + if (log) + log->Printf ("async: failed to interrupt"); + } + } + else + { + if (log) + log->Printf ("mutex taken and send_async == false, aborting packet"); + } + } + return 0; +} + +//template +//class ScopedValueChanger +//{ +//public: +// // Take a value reference and the value to assign it to when this class +// // instance goes out of scope. +// ScopedValueChanger (_Tp &value_ref, _Tp value) : +// m_value_ref (value_ref), +// m_value (value) +// { +// } +// +// // This object is going out of scope, change the value pointed to by +// // m_value_ref to the value we got during construction which was stored in +// // m_value; +// ~ScopedValueChanger () +// { +// m_value_ref = m_value; +// } +//protected: +// _Tp &m_value_ref; // A reference to the value we will change when this object destructs +// _Tp m_value; // The value to assign to m_value_ref when this goes out of scope. +//}; + +StateType +GDBRemoteCommunicationClient::SendContinuePacketAndWaitForResponse +( + ProcessGDBRemote *process, + const char *payload, + size_t packet_length, + StringExtractorGDBRemote &response +) +{ + LogSP log (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet (GDBR_LOG_PROCESS)); + if (log) + log->Printf ("GDBRemoteCommunicationClient::%s ()", __FUNCTION__); + + Mutex::Locker locker(m_sequence_mutex); + StateType state = eStateRunning; + + BroadcastEvent(eBroadcastBitRunPacketSent, NULL); + m_public_is_running.SetValue (true, eBroadcastNever); + // Set the starting continue packet into "continue_packet". This packet + // make change if we are interrupted and we continue after an async packet... + std::string continue_packet(payload, packet_length); + + while (state == eStateRunning) + { + if (log) + log->Printf ("GDBRemoteCommunicationClient::%s () sending continue packet: %s", __FUNCTION__, continue_packet.c_str()); + if (SendPacket(continue_packet.c_str(), continue_packet.size()) == 0) + state = eStateInvalid; + + m_private_is_running.SetValue (true, eBroadcastNever); + + if (log) + log->Printf ("GDBRemoteCommunicationClient::%s () WaitForPacket(%.*s)", __FUNCTION__); + + if (WaitForPacket (response, (TimeValue*)NULL)) + { + if (response.Empty()) + state = eStateInvalid; + else + { + const char stop_type = response.GetChar(); + if (log) + log->Printf ("GDBRemoteCommunicationClient::%s () got packet: %s", __FUNCTION__, response.GetStringRef().c_str()); + switch (stop_type) + { + case 'T': + case 'S': + if (process->GetStopID() == 0) + { + if (process->GetID() == LLDB_INVALID_PROCESS_ID) + { + lldb::pid_t pid = GetCurrentProcessID (); + if (pid != LLDB_INVALID_PROCESS_ID) + process->SetID (pid); + } + process->BuildDynamicRegisterInfo (true); + } + + // Privately notify any internal threads that we have stopped + // in case we wanted to interrupt our process, yet we might + // send a packet and continue without returning control to the + // user. + m_private_is_running.SetValue (false, eBroadcastAlways); + if (m_async_signal != -1) + { + if (log) + log->Printf ("async: send signo = %s", Host::GetSignalAsCString (m_async_signal)); + + // Save off the async signal we are supposed to send + const int async_signal = m_async_signal; + // Clear the async signal member so we don't end up + // sending the signal multiple times... + m_async_signal = -1; + // Check which signal we stopped with + uint8_t signo = response.GetHexU8(255); + if (signo == async_signal) + { + if (log) + log->Printf ("async: stopped with signal %s, we are done running", Host::GetSignalAsCString (signo)); + + // We already stopped with a signal that we wanted + // to stop with, so we are done + response.SetFilePos (0); + } + else + { + // We stopped with a different signal that the one + // we wanted to stop with, so now we must resume + // with the signal we want + char signal_packet[32]; + int signal_packet_len = 0; + signal_packet_len = ::snprintf (signal_packet, + sizeof (signal_packet), + "C%2.2x", + async_signal); + + if (log) + log->Printf ("async: stopped with signal %s, resume with %s", + Host::GetSignalAsCString (signo), + Host::GetSignalAsCString (async_signal)); + + // Set the continue packet to resume... + continue_packet.assign(signal_packet, signal_packet_len); + continue; + } + } + else if (m_async_packet_predicate.GetValue()) + { + // We are supposed to send an asynchronous packet while + // we are running. + m_async_response.Clear(); + if (m_async_packet.empty()) + { + if (log) + log->Printf ("async: error: empty async packet"); + + } + else + { + if (log) + log->Printf ("async: sending packet: %s", + m_async_packet.c_str()); + + SendPacketAndWaitForResponse (&m_async_packet[0], + m_async_packet.size(), + m_async_response, + false); + } + // Let the other thread that was trying to send the async + // packet know that the packet has been sent and response is + // ready... + m_async_packet_predicate.SetValue(false, eBroadcastAlways); + + // Set the continue packet to resume... + continue_packet.assign (1, 'c'); + continue; + } + // Stop with signal and thread info + state = eStateStopped; + break; + + case 'W': + case 'X': + // process exited + state = eStateExited; + break; + + case 'O': + // STDOUT + { + std::string inferior_stdout; + inferior_stdout.reserve(response.GetBytesLeft () / 2); + char ch; + while ((ch = response.GetHexU8()) != '\0') + inferior_stdout.append(1, ch); + process->AppendSTDOUT (inferior_stdout.c_str(), inferior_stdout.size()); + } + break; + + case 'E': + // ERROR + state = eStateInvalid; + break; + + default: + if (log) + log->Printf ("GDBRemoteCommunicationClient::%s () unrecognized async packet", __FUNCTION__); + state = eStateInvalid; + break; + } + } + } + else + { + if (log) + log->Printf ("GDBRemoteCommunicationClient::%s () WaitForPacket(...) => false", __FUNCTION__); + state = eStateInvalid; + } + } + if (log) + log->Printf ("GDBRemoteCommunicationClient::%s () => %s", __FUNCTION__, StateAsCString(state)); + response.SetFilePos(0); + m_private_is_running.SetValue (false, eBroadcastAlways); + m_public_is_running.SetValue (false, eBroadcastAlways); + return state; +} + +bool +GDBRemoteCommunicationClient::SendAsyncSignal (int signo) +{ + m_async_signal = signo; + bool timed_out = false; + bool sent_interrupt = false; + Mutex::Locker locker; + if (SendInterrupt (locker, 1, sent_interrupt, timed_out)) + return true; + m_async_signal = -1; + return false; +} + +// This function takes a mutex locker as a parameter in case the GetSequenceMutex +// actually succeeds. If it doesn't succeed in acquiring the sequence mutex +// (the expected result), then it will send the halt packet. If it does succeed +// then the caller that requested the interrupt will want to keep the sequence +// locked down so that no one else can send packets while the caller has control. +// This function usually gets called when we are running and need to stop the +// target. It can also be used when we are running and and we need to do something +// else (like read/write memory), so we need to interrupt the running process +// (gdb remote protocol requires this), and do what we need to do, then resume. + +bool +GDBRemoteCommunicationClient::SendInterrupt +( + Mutex::Locker& locker, + uint32_t seconds_to_wait_for_stop, + bool &sent_interrupt, + bool &timed_out +) +{ + sent_interrupt = false; + timed_out = false; + LogSP log (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet (GDBR_LOG_PROCESS)); + + if (IsRunning()) + { + // Only send an interrupt if our debugserver is running... + if (GetSequenceMutex (locker) == false) + { + // Someone has the mutex locked waiting for a response or for the + // inferior to stop, so send the interrupt on the down low... + char ctrl_c = '\x03'; + ConnectionStatus status = eConnectionStatusSuccess; + TimeValue timeout; + if (seconds_to_wait_for_stop) + { + timeout = TimeValue::Now(); + timeout.OffsetWithSeconds (seconds_to_wait_for_stop); + } + size_t bytes_written = Write (&ctrl_c, 1, status, NULL); + ProcessGDBRemoteLog::LogIf (GDBR_LOG_PACKETS | GDBR_LOG_PROCESS, "send packet: \\x03"); + if (bytes_written > 0) + { + sent_interrupt = true; + if (seconds_to_wait_for_stop) + { + if (m_private_is_running.WaitForValueEqualTo (false, &timeout, &timed_out)) + { + if (log) + log->Printf ("GDBRemoteCommunicationClient::%s () - sent interrupt, private state stopped", __FUNCTION__); + return true; + } + else + { + if (log) + log->Printf ("GDBRemoteCommunicationClient::%s () - sent interrupt, timed out wating for async thread resume", __FUNCTION__); + } + } + else + { + if (log) + log->Printf ("GDBRemoteCommunicationClient::%s () - sent interrupt, not waiting for stop...", __FUNCTION__); + return true; + } + } + else + { + if (log) + log->Printf ("GDBRemoteCommunicationClient::%s () - failed to write interrupt", __FUNCTION__); + } + return false; + } + else + { + if (log) + log->Printf ("GDBRemoteCommunicationClient::%s () - got sequence mutex without having to interrupt", __FUNCTION__); + } + } + return true; +} + +lldb::pid_t +GDBRemoteCommunicationClient::GetCurrentProcessID () +{ + StringExtractorGDBRemote response; + if (SendPacketAndWaitForResponse("qC", strlen("qC"), response, false)) + { + if (response.GetChar() == 'Q') + if (response.GetChar() == 'C') + return response.GetHexMaxU32 (false, LLDB_INVALID_PROCESS_ID); + } + return LLDB_INVALID_PROCESS_ID; +} + +bool +GDBRemoteCommunicationClient::GetLaunchSuccess (std::string &error_str) +{ + error_str.clear(); + StringExtractorGDBRemote response; + if (SendPacketAndWaitForResponse("qLaunchSuccess", strlen("qLaunchSuccess"), response, false)) + { + if (response.IsOKResponse()) + return true; + if (response.GetChar() == 'E') + { + // A string the describes what failed when launching... + error_str = response.GetStringRef().substr(1); + } + else + { + error_str.assign ("unknown error occurred launching process"); + } + } + else + { + error_str.assign ("failed to send the qLaunchSuccess packet"); + } + return false; +} + +int +GDBRemoteCommunicationClient::SendArgumentsPacket (char const *argv[]) +{ + if (argv && argv[0]) + { + StreamString packet; + packet.PutChar('A'); + const char *arg; + for (uint32_t i = 0; (arg = argv[i]) != NULL; ++i) + { + const int arg_len = strlen(arg); + if (i > 0) + packet.PutChar(','); + packet.Printf("%i,%i,", arg_len * 2, i); + packet.PutBytesAsRawHex8 (arg, arg_len); + } + + StringExtractorGDBRemote response; + if (SendPacketAndWaitForResponse (packet.GetData(), packet.GetSize(), response, false)) + { + if (response.IsOKResponse()) + return 0; + uint8_t error = response.GetError(); + if (error) + return error; + } + } + return -1; +} + +int +GDBRemoteCommunicationClient::SendEnvironmentPacket (char const *name_equal_value) +{ + if (name_equal_value && name_equal_value[0]) + { + StreamString packet; + packet.Printf("QEnvironment:%s", name_equal_value); + StringExtractorGDBRemote response; + if (SendPacketAndWaitForResponse (packet.GetData(), packet.GetSize(), response, false)) + { + if (response.IsOKResponse()) + return 0; + uint8_t error = response.GetError(); + if (error) + return error; + } + } + return -1; +} + +bool +GDBRemoteCommunicationClient::GetHostInfo () +{ + if (m_supports_qHostInfo == eLazyBoolCalculate) + { + m_supports_qHostInfo = eLazyBoolNo; + + StringExtractorGDBRemote response; + if (SendPacketAndWaitForResponse ("qHostInfo", response, false)) + { + if (response.IsUnsupportedResponse()) + return false; + + m_supports_qHostInfo = eLazyBoolYes; + + std::string name; + std::string value; + uint32_t cpu = LLDB_INVALID_CPUTYPE; + uint32_t sub = 0; + + while (response.GetNameColonValue(name, value)) + { + if (name.compare("cputype") == 0) + { + // exception type in big endian hex + cpu = Args::StringToUInt32 (value.c_str(), LLDB_INVALID_CPUTYPE, 0); + } + else if (name.compare("cpusubtype") == 0) + { + // exception count in big endian hex + sub = Args::StringToUInt32 (value.c_str(), 0, 0); + } + else if (name.compare("ostype") == 0) + { + // exception data in big endian hex + m_os.SetCString(value.c_str()); + } + else if (name.compare("vendor") == 0) + { + m_vendor.SetCString(value.c_str()); + } + else if (name.compare("endian") == 0) + { + if (value.compare("little") == 0) + m_byte_order = eByteOrderLittle; + else if (value.compare("big") == 0) + m_byte_order = eByteOrderBig; + else if (value.compare("pdp") == 0) + m_byte_order = eByteOrderPDP; + } + else if (name.compare("ptrsize") == 0) + { + m_pointer_byte_size = Args::StringToUInt32 (value.c_str(), 0, 0); + } + } + + if (cpu != LLDB_INVALID_CPUTYPE) + m_arch.SetArchitecture (lldb::eArchTypeMachO, cpu, sub); + } + } + return m_supports_qHostInfo == eLazyBoolYes; +} + +int +GDBRemoteCommunicationClient::SendAttach +( + lldb::pid_t pid, + StringExtractorGDBRemote& response +) +{ + if (pid != LLDB_INVALID_PROCESS_ID) + { + StreamString packet; + packet.Printf("vAttach;%x", pid); + + if (SendPacketAndWaitForResponse (packet.GetData(), packet.GetSize(), response, false)) + { + if (response.IsErrorResponse()) + return response.GetError(); + return 0; + } + } + return -1; +} + +const lldb_private::ArchSpec & +GDBRemoteCommunicationClient::GetHostArchitecture () +{ + if (!HostInfoIsValid ()) + GetHostInfo (); + return m_arch; +} + +const lldb_private::ConstString & +GDBRemoteCommunicationClient::GetOSString () +{ + if (!HostInfoIsValid ()) + GetHostInfo (); + return m_os; +} + +const lldb_private::ConstString & +GDBRemoteCommunicationClient::GetVendorString() +{ + if (!HostInfoIsValid ()) + GetHostInfo (); + return m_vendor; +} + +lldb::ByteOrder +GDBRemoteCommunicationClient::GetByteOrder () +{ + if (!HostInfoIsValid ()) + GetHostInfo (); + return m_byte_order; +} + +uint32_t +GDBRemoteCommunicationClient::GetAddressByteSize () +{ + if (!HostInfoIsValid ()) + GetHostInfo (); + return m_pointer_byte_size; +} + +addr_t +GDBRemoteCommunicationClient::AllocateMemory (size_t size, uint32_t permissions) +{ + char packet[64]; + ::snprintf (packet, sizeof(packet), "_M%zx,%s%s%s", size, + permissions & lldb::ePermissionsReadable ? "r" : "", + permissions & lldb::ePermissionsWritable ? "w" : "", + permissions & lldb::ePermissionsExecutable ? "x" : ""); + StringExtractorGDBRemote response; + if (SendPacketAndWaitForResponse (packet, response, false)) + { + if (!response.IsErrorResponse()) + return response.GetHexMaxU64(false, LLDB_INVALID_ADDRESS); + } + return LLDB_INVALID_ADDRESS; +} + +bool +GDBRemoteCommunicationClient::DeallocateMemory (addr_t addr) +{ + char packet[64]; + snprintf(packet, sizeof(packet), "_m%llx", (uint64_t)addr); + StringExtractorGDBRemote response; + if (SendPacketAndWaitForResponse (packet, response, false)) + { + if (response.IsOKResponse()) + return true; + } + return false; +} + +int +GDBRemoteCommunicationClient::SetSTDIN (char const *path) +{ + if (path && path[0]) + { + StreamString packet; + packet.PutCString("QSetSTDIN:"); + packet.PutBytesAsRawHex8(path, strlen(path)); + + StringExtractorGDBRemote response; + if (SendPacketAndWaitForResponse (packet.GetData(), packet.GetSize(), response, false)) + { + if (response.IsOKResponse()) + return 0; + uint8_t error = response.GetError(); + if (error) + return error; + } + } + return -1; +} + +int +GDBRemoteCommunicationClient::SetSTDOUT (char const *path) +{ + if (path && path[0]) + { + StreamString packet; + packet.PutCString("QSetSTDOUT:"); + packet.PutBytesAsRawHex8(path, strlen(path)); + + StringExtractorGDBRemote response; + if (SendPacketAndWaitForResponse (packet.GetData(), packet.GetSize(), response, false)) + { + if (response.IsOKResponse()) + return 0; + uint8_t error = response.GetError(); + if (error) + return error; + } + } + return -1; +} + +int +GDBRemoteCommunicationClient::SetSTDERR (char const *path) +{ + if (path && path[0]) + { + StreamString packet; + packet.PutCString("QSetSTDERR:"); + packet.PutBytesAsRawHex8(path, strlen(path)); + + StringExtractorGDBRemote response; + if (SendPacketAndWaitForResponse (packet.GetData(), packet.GetSize(), response, false)) + { + if (response.IsOKResponse()) + return 0; + uint8_t error = response.GetError(); + if (error) + return error; + } + } + return -1; +} + +int +GDBRemoteCommunicationClient::SetWorkingDir (char const *path) +{ + if (path && path[0]) + { + StreamString packet; + packet.PutCString("QSetWorkingDir:"); + packet.PutBytesAsRawHex8(path, strlen(path)); + + StringExtractorGDBRemote response; + if (SendPacketAndWaitForResponse (packet.GetData(), packet.GetSize(), response, false)) + { + if (response.IsOKResponse()) + return 0; + uint8_t error = response.GetError(); + if (error) + return error; + } + } + return -1; +} + +int +GDBRemoteCommunicationClient::SetDisableASLR (bool enable) +{ + StreamString packet; + packet.Printf("QSetDisableASLR:%i", enable ? 1 : 0); + + StringExtractorGDBRemote response; + if (SendPacketAndWaitForResponse (packet.GetData(), packet.GetSize(), response, false)) + { + if (response.IsOKResponse()) + return 0; + uint8_t error = response.GetError(); + if (error) + return error; + } + return -1; +} Added: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h?rev=128070&view=auto ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h (added) +++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h Mon Mar 21 23:00:09 2011 @@ -0,0 +1,268 @@ +//===-- GDBRemoteCommunicationClient.h --------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef liblldb_GDBRemoteCommunicationClient_h_ +#define liblldb_GDBRemoteCommunicationClient_h_ + +// C Includes +// C++ Includes +// Other libraries and framework includes +// Project includes +#include "lldb/Core/ArchSpec.h" + +#include "GDBRemoteCommunication.h" + +class GDBRemoteCommunicationClient : public GDBRemoteCommunication +{ +public: + //------------------------------------------------------------------ + // Constructors and Destructors + //------------------------------------------------------------------ + GDBRemoteCommunicationClient(); + + virtual + ~GDBRemoteCommunicationClient(); + + size_t + SendPacketAndWaitForResponse (const char *send_payload, + StringExtractorGDBRemote &response, + bool send_async); + + size_t + SendPacketAndWaitForResponse (const char *send_payload, + size_t send_length, + StringExtractorGDBRemote &response, + bool send_async); + + lldb::StateType + SendContinuePacketAndWaitForResponse (ProcessGDBRemote *process, + const char *packet_payload, + size_t packet_length, + StringExtractorGDBRemote &response); + + virtual bool + GetThreadSuffixSupported (); + + virtual bool + GetSendAcks (); + + bool + SendAsyncSignal (int signo); + + bool + SendInterrupt (lldb_private::Mutex::Locker &locker, + uint32_t seconds_to_wait_for_stop, + bool &sent_interrupt, + bool &timed_out); + + lldb::pid_t + GetCurrentProcessID (); + + bool + GetLaunchSuccess (std::string &error_str); + + //------------------------------------------------------------------ + /// Sends a GDB remote protocol 'A' packet that delivers program + /// arguments to the remote server. + /// + /// @param[in] argv + /// A NULL terminated array of const C strings to use as the + /// arguments. + /// + /// @return + /// Zero if the response was "OK", a positive value if the + /// the response was "Exx" where xx are two hex digits, or + /// -1 if the call is unsupported or any other unexpected + /// response was received. + //------------------------------------------------------------------ + int + SendArgumentsPacket (char const *argv[]); + + //------------------------------------------------------------------ + /// Sends a "QEnvironment:NAME=VALUE" packet that will build up the + /// environment that will get used when launching an application + /// in conjunction with the 'A' packet. This function can be called + /// multiple times in a row in order to pass on the desired + /// environment that the inferior should be launched with. + /// + /// @param[in] name_equal_value + /// A NULL terminated C string that contains a single environment + /// in the format "NAME=VALUE". + /// + /// @return + /// Zero if the response was "OK", a positive value if the + /// the response was "Exx" where xx are two hex digits, or + /// -1 if the call is unsupported or any other unexpected + /// response was received. + //------------------------------------------------------------------ + int + SendEnvironmentPacket (char const *name_equal_value); + + //------------------------------------------------------------------ + /// Sends a "vAttach:PID" where PID is in hex. + /// + /// @param[in] pid + /// A process ID for the remote gdb server to attach to. + /// + /// @param[out] response + /// The response received from the gdb server. If the return + /// value is zero, \a response will contain a stop reply + /// packet. + /// + /// @return + /// Zero if the attach was successful, or an error indicating + /// an error code. + //------------------------------------------------------------------ + int + SendAttach (lldb::pid_t pid, + StringExtractorGDBRemote& response); + + + //------------------------------------------------------------------ + /// Sets the path to use for stdin/out/err for a process + /// that will be launched with the 'A' packet. + /// + /// @param[in] path + /// The path to use for stdin/out/err + /// + /// @return + /// Zero if the for success, or an error code for failure. + //------------------------------------------------------------------ + int + SetSTDIN (char const *path); + int + SetSTDOUT (char const *path); + int + SetSTDERR (char const *path); + + //------------------------------------------------------------------ + /// Sets the disable ASLR flag to \a enable for a process that will + /// be launched with the 'A' packet. + /// + /// @param[in] enable + /// A boolean value indicating wether to disable ASLR or not. + /// + /// @return + /// Zero if the for success, or an error code for failure. + //------------------------------------------------------------------ + int + SetDisableASLR (bool enable); + + //------------------------------------------------------------------ + /// Sets the working directory to \a path for a process that will + /// be launched with the 'A' packet. + /// + /// @param[in] path + /// The path to a directory to use when launching our processs + /// + /// @return + /// Zero if the for success, or an error code for failure. + //------------------------------------------------------------------ + int + SetWorkingDir (char const *path); + + lldb::addr_t + AllocateMemory (size_t size, uint32_t permissions); + + bool + DeallocateMemory (lldb::addr_t addr); + + const lldb_private::ArchSpec & + GetHostArchitecture (); + + const lldb_private::ConstString & + GetOSString (); + + const lldb_private::ConstString & + GetVendorString(); + + lldb::ByteOrder + GetByteOrder (); + + uint32_t + GetAddressByteSize (); + + bool + GetVContSupported (char flavor); + + void + ResetDiscoverableSettings(); + + bool + GetHostInfo (); + + bool + GetSupportsThreadSuffix (); + + bool + HasFullVContSupport () + { + return GetVContSupported ('A'); + } + + bool + HasAnyVContSupport () + { + return GetVContSupported ('a'); + } + + uint32_t + SetPacketTimeout (uint32_t packet_timeout) + { + const uint32_t old_packet_timeout = m_packet_timeout; + m_packet_timeout = packet_timeout; + return old_packet_timeout; + } + +protected: + + bool + HostInfoIsValid () const + { + return m_supports_qHostInfo != lldb::eLazyBoolCalculate; + } + + //------------------------------------------------------------------ + // Classes that inherit from GDBRemoteCommunicationClient can see and modify these + //------------------------------------------------------------------ + lldb::LazyBool m_supports_not_sending_acks; + lldb::LazyBool m_supports_thread_suffix; + lldb::LazyBool m_supports_qHostInfo; + lldb::LazyBool m_supports_vCont_all; + lldb::LazyBool m_supports_vCont_any; + lldb::LazyBool m_supports_vCont_c; + lldb::LazyBool m_supports_vCont_C; + lldb::LazyBool m_supports_vCont_s; + lldb::LazyBool m_supports_vCont_S; + + // If we need to send a packet while the target is running, the m_async_XXX + // member variables take care of making this happen. + lldb_private::Mutex m_async_mutex; + lldb_private::Predicate m_async_packet_predicate; + std::string m_async_packet; + StringExtractorGDBRemote m_async_response; + int m_async_signal; // We were asked to deliver a signal to the inferior process. + + lldb_private::ArchSpec m_arch; + uint32_t m_cpusubtype; + lldb_private::ConstString m_os; + lldb_private::ConstString m_vendor; + lldb::ByteOrder m_byte_order; + uint32_t m_pointer_byte_size; + + + +private: + //------------------------------------------------------------------ + // For GDBRemoteCommunicationClient only + //------------------------------------------------------------------ + DISALLOW_COPY_AND_ASSIGN (GDBRemoteCommunicationClient); +}; + +#endif // liblldb_GDBRemoteCommunicationClient_h_ Added: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp?rev=128070&view=auto ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp (added) +++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp Mon Mar 21 23:00:09 2011 @@ -0,0 +1,134 @@ +//===-- GDBRemoteCommunicationServer.cpp ------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + + +#include "GDBRemoteCommunicationServer.h" + +// C Includes +// C++ Includes +// Other libraries and framework includes +#include "llvm/ADT/Triple.h" +#include "lldb/Interpreter/Args.h" +#include "lldb/Core/ConnectionFileDescriptor.h" +#include "lldb/Core/Log.h" +#include "lldb/Core/State.h" +#include "lldb/Core/StreamString.h" +#include "lldb/Host/Host.h" +#include "lldb/Host/TimeValue.h" + +// Project includes +#include "Utility/StringExtractorGDBRemote.h" +#include "ProcessGDBRemote.h" +#include "ProcessGDBRemoteLog.h" + +using namespace lldb; +using namespace lldb_private; + +//---------------------------------------------------------------------- +// GDBRemoteCommunicationServer constructor +//---------------------------------------------------------------------- +GDBRemoteCommunicationServer::GDBRemoteCommunicationServer() : + GDBRemoteCommunication ("gdb-remote.server", "gdb-remote.server.rx_packet"), + m_async_thread (LLDB_INVALID_HOST_THREAD), + m_send_acks (true) +{ +} + +//---------------------------------------------------------------------- +// Destructor +//---------------------------------------------------------------------- +GDBRemoteCommunicationServer::~GDBRemoteCommunicationServer() +{ +} + + +//void * +//GDBRemoteCommunicationServer::AsyncThread (void *arg) +//{ +// GDBRemoteCommunicationServer *server = (GDBRemoteCommunicationServer*) arg; +// +// LogSP log;// (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet (GDBR_LOG_PROCESS)); +// if (log) +// log->Printf ("ProcessGDBRemote::%s (arg = %p, pid = %i) thread starting...", __FUNCTION__, arg, process->GetID()); +// +// StringExtractorGDBRemote packet; +// +// while () +// { +// if (packet. +// } +// +// if (log) +// log->Printf ("ProcessGDBRemote::%s (arg = %p, pid = %i) thread exiting...", __FUNCTION__, arg, process->GetID()); +// +// process->m_async_thread = LLDB_INVALID_HOST_THREAD; +// return NULL; +//} +// +bool +GDBRemoteCommunicationServer::GetPacketAndSendResponse (const TimeValue* timeout_time_ptr) +{ + StringExtractorGDBRemote packet; + if (WaitForPacketNoLock (packet, timeout_time_ptr)) + { + const StringExtractorGDBRemote::ServerPacketType packet_type = packet.GetServerPacketType (); + switch (packet_type) + { + case StringExtractorGDBRemote::eServerPacketType_nack: + case StringExtractorGDBRemote::eServerPacketType_ack: + break; + + case StringExtractorGDBRemote::eServerPacketType_invalid: + case StringExtractorGDBRemote::eServerPacketType_unimplemented: + return SendUnimplementedResponse () > 0; + + case StringExtractorGDBRemote::eServerPacketType_qHostInfo: + return Handle_qHostInfo (); + } + return true; + } + return false; +} + +size_t +GDBRemoteCommunicationServer::SendUnimplementedResponse () +{ + return SendPacket (""); +} + + +bool +GDBRemoteCommunicationServer::Handle_qHostInfo () +{ + StreamString response; + + // $cputype:16777223;cpusubtype:3;ostype:Darwin;vendor:apple;endian:little;ptrsize:8;#00 + + ArchSpec host_arch (Host::GetArchitecture ()); + + const llvm::Triple &host_triple = host_arch.GetTriple(); + const llvm::StringRef arch_name (host_triple.getArchName()); + const llvm::StringRef vendor_name (host_triple.getOSName()); + const llvm::StringRef os_name (host_triple.getVendorName()); + response.Printf ("arch:%.*s;ostype:%.*s;vendor:%.*s;ptrsize:%u", + (int)arch_name.size(), arch_name.data(), + (int)os_name.size(), os_name.data(), + (int)vendor_name.size(), vendor_name.data(), + host_arch.GetAddressByteSize()); + + switch (lldb::endian::InlHostByteOrder()) + { + case eByteOrderBig: response.PutCString ("endian:big;"); break; + case eByteOrderLittle: response.PutCString ("endian:little;"); break; + case eByteOrderPDP: response.PutCString ("endian:pdp;"); break; + default: response.PutCString ("endian:unknown;"); break; + } + + return SendPacket (response.GetString().c_str(),response.GetString().size()) > 0; +} Added: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.h?rev=128070&view=auto ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.h (added) +++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.h Mon Mar 21 23:00:09 2011 @@ -0,0 +1,69 @@ +//===-- GDBRemoteCommunicationServer.h --------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef liblldb_GDBRemoteCommunicationServer_h_ +#define liblldb_GDBRemoteCommunicationServer_h_ + +// C Includes +// C++ Includes +// Other libraries and framework includes +// Project includes +#include "GDBRemoteCommunication.h" + +class ProcessGDBRemote; + +class GDBRemoteCommunicationServer : public GDBRemoteCommunication +{ +public: + enum + { + eBroadcastBitRunPacketSent = kLoUserBroadcastBit + }; + //------------------------------------------------------------------ + // Constructors and Destructors + //------------------------------------------------------------------ + GDBRemoteCommunicationServer(); + + virtual + ~GDBRemoteCommunicationServer(); + + bool + GetPacketAndSendResponse (const lldb_private::TimeValue* timeout_time_ptr); + + virtual bool + GetThreadSuffixSupported () + { + return true; + } + + virtual bool + GetSendAcks () + { + return m_send_acks; + } + +protected: + lldb::thread_t m_async_thread; + bool m_send_acks; + + size_t + SendUnimplementedResponse (); + + + bool + Handle_qHostInfo (); + +private: + //------------------------------------------------------------------ + // For GDBRemoteCommunicationServer only + //------------------------------------------------------------------ + DISALLOW_COPY_AND_ASSIGN (GDBRemoteCommunicationServer); +}; + +#endif // liblldb_GDBRemoteCommunicationServer_h_ Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp?rev=128070&r1=128069&r2=128070&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp Mon Mar 21 23:00:09 2011 @@ -208,7 +208,7 @@ bool GDBRemoteRegisterContext::ReadRegisterBytes (uint32_t reg, DataExtractor &data) { - GDBRemoteCommunication &gdb_comm = GetGDBProcess().GetGDBRemote(); + GDBRemoteCommunicationClient &gdb_comm (GetGDBProcess().GetGDBRemote()); InvalidateIfNeeded(false); @@ -235,7 +235,7 @@ assert (packet_len < (sizeof(packet) - 1)); if (gdb_comm.SendPacketAndWaitForResponse(packet, response, false)) { - if (response.IsNormalPacket()) + if (response.IsNormalResponse()) if (response.GetHexBytes ((void *)m_reg_data.GetDataStart(), m_reg_data.GetByteSize(), '\xcc') == m_reg_data.GetByteSize()) SetAllRegisterValid (true); } @@ -290,7 +290,7 @@ bool GDBRemoteRegisterContext::WriteRegisterBytes (uint32_t reg, DataExtractor &data, uint32_t data_offset) { - GDBRemoteCommunication &gdb_comm = GetGDBProcess().GetGDBRemote(); + GDBRemoteCommunicationClient &gdb_comm (GetGDBProcess().GetGDBRemote()); // FIXME: This check isn't right because IsRunning checks the Public state, but this // is work you need to do - for instance in ShouldStop & friends - before the public // state has been changed. @@ -358,7 +358,7 @@ false)) { SetAllRegisterValid (false); - if (response.IsOKPacket()) + if (response.IsOKResponse()) { return true; } @@ -383,7 +383,7 @@ response, false)) { - if (response.IsOKPacket()) + if (response.IsOKResponse()) { return true; } @@ -399,7 +399,7 @@ bool GDBRemoteRegisterContext::ReadAllRegisterValues (lldb::DataBufferSP &data_sp) { - GDBRemoteCommunication &gdb_comm = GetGDBProcess().GetGDBRemote(); + GDBRemoteCommunicationClient &gdb_comm (GetGDBProcess().GetGDBRemote()); StringExtractorGDBRemote response; Mutex::Locker locker; @@ -418,7 +418,7 @@ if (gdb_comm.SendPacketAndWaitForResponse(packet, packet_len, response, false)) { - if (response.IsErrorPacket()) + if (response.IsErrorResponse()) return false; response.GetStringRef().insert(0, 1, 'G'); @@ -443,7 +443,7 @@ if (!data_sp || data_sp->GetBytes() == NULL || data_sp->GetByteSize() == 0) return false; - GDBRemoteCommunication &gdb_comm = GetGDBProcess().GetGDBRemote(); + GDBRemoteCommunicationClient &gdb_comm (GetGDBProcess().GetGDBRemote()); StringExtractorGDBRemote response; Mutex::Locker locker; if (gdb_comm.GetSequenceMutex (locker)) @@ -456,7 +456,7 @@ response, false)) { - if (response.IsOKPacket()) + if (response.IsOKResponse()) return true; } } Modified: lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp?rev=128070&r1=128069&r2=128070&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Mon Mar 21 23:00:09 2011 @@ -170,18 +170,20 @@ char packet[128]; m_register_info.Clear(); - StringExtractorGDBRemote::Type packet_type = StringExtractorGDBRemote::eResponse; uint32_t reg_offset = 0; uint32_t reg_num = 0; - for (; packet_type == StringExtractorGDBRemote::eResponse; ++reg_num) + StringExtractorGDBRemote::ResponseType response_type; + for (response_type = StringExtractorGDBRemote::eResponse; + response_type == StringExtractorGDBRemote::eResponse; + ++reg_num) { const int packet_len = ::snprintf (packet, sizeof(packet), "qRegisterInfo%x", reg_num); assert (packet_len < sizeof(packet)); StringExtractorGDBRemote response; if (m_gdb_comm.SendPacketAndWaitForResponse(packet, packet_len, response, false)) { - packet_type = response.GetType(); - if (packet_type == StringExtractorGDBRemote::eResponse) + response_type = response.GetResponseType(); + if (response_type == StringExtractorGDBRemote::eResponse) { std::string name; std::string value; @@ -298,7 +300,7 @@ } else { - packet_type = StringExtractorGDBRemote::eError; + response_type = StringExtractorGDBRemote::eError; } } @@ -1044,7 +1046,7 @@ Error err; StringExtractorGDBRemote response; for (m_gdb_comm.SendPacketAndWaitForResponse("qfThreadInfo", response, false); - response.IsNormalPacket(); + response.IsNormalResponse(); m_gdb_comm.SendPacketAndWaitForResponse("qsThreadInfo", response, false)) { char ch = response.GetChar(); @@ -1460,7 +1462,7 @@ StringExtractorGDBRemote response; if (m_gdb_comm.SendPacketAndWaitForResponse("qShlibInfoAddr", ::strlen ("qShlibInfoAddr"), response, false)) { - if (response.IsNormalPacket()) + if (response.IsNormalResponse()) return response.GetHexMaxU64(false, LLDB_INVALID_ADDRESS); } } @@ -1487,14 +1489,14 @@ StringExtractorGDBRemote response; if (m_gdb_comm.SendPacketAndWaitForResponse(packet, packet_len, response, true)) { - if (response.IsNormalPacket()) + if (response.IsNormalResponse()) { error.Clear(); return response.GetHexBytes(buf, size, '\xdd'); } - else if (response.IsErrorPacket()) + else if (response.IsErrorResponse()) error.SetErrorStringWithFormat("gdb remote returned an error: %s", response.GetStringRef().c_str()); - else if (response.IsUnsupportedPacket()) + else if (response.IsUnsupportedResponse()) error.SetErrorStringWithFormat("'%s' packet unsupported", packet); else error.SetErrorStringWithFormat("unexpected response to '%s': '%s'", packet, response.GetStringRef().c_str()); @@ -1515,14 +1517,14 @@ StringExtractorGDBRemote response; if (m_gdb_comm.SendPacketAndWaitForResponse(packet.GetData(), packet.GetSize(), response, true)) { - if (response.IsOKPacket()) + if (response.IsOKResponse()) { error.Clear(); return size; } - else if (response.IsErrorPacket()) + else if (response.IsErrorResponse()) error.SetErrorStringWithFormat("gdb remote returned an error: %s", response.GetStringRef().c_str()); - else if (response.IsUnsupportedPacket()) + else if (response.IsUnsupportedResponse()) error.SetErrorStringWithFormat("'%s' packet unsupported", packet.GetString().c_str()); else error.SetErrorStringWithFormat("unexpected response to '%s': '%s'", packet.GetString().c_str(), response.GetStringRef().c_str()); @@ -1640,13 +1642,13 @@ StringExtractorGDBRemote response; if (m_gdb_comm.SendPacketAndWaitForResponse(packet, packet_len, response, true)) { - if (response.IsUnsupportedPacket()) + if (response.IsUnsupportedResponse()) { // Disable z packet support and try again m_z0_supported = 0; return EnableBreakpoint (bp_site); } - else if (response.IsOKPacket()) + else if (response.IsOKResponse()) { bp_site->SetEnabled(true); bp_site->SetType (BreakpointSite::eExternal); @@ -1708,11 +1710,11 @@ StringExtractorGDBRemote response; if (m_gdb_comm.SendPacketAndWaitForResponse(packet, packet_len, response, true)) { - if (response.IsUnsupportedPacket()) + if (response.IsUnsupportedResponse()) { error.SetErrorString("Breakpoint site was set with Z packet, yet remote debugserver states z packets are not supported."); } - else if (response.IsOKPacket()) + else if (response.IsOKResponse()) { if (log) log->Printf ("ProcessGDBRemote::DisableBreakpoint (site_id = %d) addr = 0x%8.8llx -- SUCCESS", site_id, (uint64_t)addr); @@ -2121,7 +2123,7 @@ StringExtractorGDBRemote response; if (m_gdb_comm.SendPacketAndWaitForResponse(packet, packet_len, response, false)) { - if (response.IsOKPacket()) + if (response.IsOKResponse()) { m_curr_tid = tid; return true; @@ -2147,7 +2149,7 @@ StringExtractorGDBRemote response; if (m_gdb_comm.SendPacketAndWaitForResponse(packet, packet_len, response, false)) { - if (response.IsOKPacket()) + if (response.IsOKResponse()) { m_curr_tid_run = tid; return true; Modified: lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h?rev=128070&r1=128069&r2=128070&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h Mon Mar 21 23:00:09 2011 @@ -27,7 +27,7 @@ #include "lldb/Target/Process.h" #include "lldb/Target/Thread.h" -#include "GDBRemoteCommunication.h" +#include "GDBRemoteCommunicationClient.h" #include "Utility/StringExtractor.h" #include "GDBRemoteRegisterContext.h" @@ -212,7 +212,7 @@ protected: friend class ThreadGDBRemote; - friend class GDBRemoteCommunication; + friend class GDBRemoteCommunicationClient; friend class GDBRemoteRegisterContext; bool @@ -289,7 +289,7 @@ void BuildDynamicRegisterInfo (bool force); - GDBRemoteCommunication & + GDBRemoteCommunicationClient & GetGDBRemote() { return m_gdb_comm; @@ -306,7 +306,7 @@ lldb_private::Flags m_flags; // Process specific flags (see eFlags enums) lldb_private::Mutex m_stdio_mutex; // Multithreaded protection for stdio - GDBRemoteCommunication m_gdb_comm; + GDBRemoteCommunicationClient m_gdb_comm; lldb::pid_t m_debugserver_pid; lldb::thread_t m_debugserver_thread; StringExtractor m_last_stop_packet; Modified: lldb/trunk/source/Utility/StringExtractorGDBRemote.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Utility/StringExtractorGDBRemote.cpp?rev=128070&r1=128069&r2=128070&view=diff ============================================================================== --- lldb/trunk/source/Utility/StringExtractorGDBRemote.cpp (original) +++ lldb/trunk/source/Utility/StringExtractorGDBRemote.cpp Mon Mar 21 23:00:09 2011 @@ -16,8 +16,8 @@ -StringExtractorGDBRemote::Type -StringExtractorGDBRemote::GetType () const +StringExtractorGDBRemote::ResponseType +StringExtractorGDBRemote::GetResponseType () const { if (m_packet.empty()) return eUnsupported; @@ -49,29 +49,57 @@ return eResponse; } +StringExtractorGDBRemote::ServerPacketType +StringExtractorGDBRemote::GetServerPacketType () const +{ + // Empty is not a supported packet... + if (m_packet.empty()) + return eServerPacketType_invalid; + + const char *packet_cstr = m_packet.c_str(); + switch (m_packet[0]) + { + case '-': + if (m_packet.size() == 1) + return eServerPacketType_nack; + break; + + case '+': + if (m_packet.size() == 1) + return eServerPacketType_ack; + break; + + case 'q': + if (strcmp (packet_cstr, "qHostInfo") == 0) + return eServerPacketType_qHostInfo; + break; + } + return eServerPacketType_unimplemented; +} + bool -StringExtractorGDBRemote::IsOKPacket() const +StringExtractorGDBRemote::IsOKResponse() const { - return GetType () == eOK; + return GetResponseType () == eOK; } bool -StringExtractorGDBRemote::IsUnsupportedPacket() const +StringExtractorGDBRemote::IsUnsupportedResponse() const { - return GetType () == eUnsupported; + return GetResponseType () == eUnsupported; } bool -StringExtractorGDBRemote::IsNormalPacket() const +StringExtractorGDBRemote::IsNormalResponse() const { - return GetType () == eResponse; + return GetResponseType () == eResponse; } bool -StringExtractorGDBRemote::IsErrorPacket() const +StringExtractorGDBRemote::IsErrorResponse() const { - return GetType () == eError && + return GetResponseType () == eError && m_packet.size() == 3 && isxdigit(m_packet[1]) && isxdigit(m_packet[2]); @@ -80,7 +108,7 @@ uint8_t StringExtractorGDBRemote::GetError () { - if (GetType() == eError) + if (GetResponseType() == eError) { SetFilePos(1); return GetHexU8(255); Modified: lldb/trunk/source/Utility/StringExtractorGDBRemote.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Utility/StringExtractorGDBRemote.h?rev=128070&r1=128069&r2=128070&view=diff ============================================================================== --- lldb/trunk/source/Utility/StringExtractorGDBRemote.h (original) +++ lldb/trunk/source/Utility/StringExtractorGDBRemote.h Mon Mar 21 23:00:09 2011 @@ -39,30 +39,42 @@ { } - enum Type + enum ServerPacketType + { + eServerPacketType_nack = 0, + eServerPacketType_ack, + eServerPacketType_invalid, + eServerPacketType_unimplemented, + eServerPacketType_qHostInfo + }; + + ServerPacketType + GetServerPacketType () const; + + enum ResponseType { eUnsupported = 0, eAck, eNack, eError, eOK, - eResponse + eResponse, }; - StringExtractorGDBRemote::Type - GetType () const; + ResponseType + GetResponseType () const; bool - IsOKPacket() const; + IsOKResponse() const; bool - IsUnsupportedPacket() const; + IsUnsupportedResponse() const; bool - IsNormalPacket () const; + IsNormalResponse () const; bool - IsErrorPacket() const; + IsErrorResponse() const; // Returns zero if the packet isn't a EXX packet where XX are two hex // digits. Otherwise the error encoded in XX is returned. Modified: lldb/trunk/tools/lldb-platform/lldb-platform.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-platform/lldb-platform.cpp?rev=128070&r1=128069&r2=128070&view=diff ============================================================================== --- lldb/trunk/tools/lldb-platform/lldb-platform.cpp (original) +++ lldb/trunk/tools/lldb-platform/lldb-platform.cpp Mon Mar 21 23:00:09 2011 @@ -15,7 +15,7 @@ #include #include -#include "GDBRemoteCommunication.h" +#include "GDBRemoteCommunicationServer.h" //---------------------------------------------------------------------- // option descriptors for getopt_long() @@ -106,7 +106,7 @@ argv += optind; - GDBRemoteCommunication gdb_comm; + GDBRemoteCommunicationServer gdb_comm; return 0; } From scallanan at apple.com Tue Mar 22 16:45:30 2011 From: scallanan at apple.com (Sean Callanan) Date: Tue, 22 Mar 2011 21:45:30 -0000 Subject: [Lldb-commits] [lldb] r128111 - in /lldb/trunk/tools/debugserver: debugserver.xcodeproj/project.pbxproj source/DNBDefs.h source/MacOSX/i386/DNBArchImplI386.cpp source/MacOSX/i386/DNBArchImplI386.h source/MacOSX/i386/MachRegisterStatesI386.h source/MacOSX/x86_64/DNBArchImplX86_64.cpp source/MacOSX/x86_64/DNBArchImplX86_64.h source/MacOSX/x86_64/MachRegisterStatesX86_64.h Message-ID: <20110322214530.CC73F2A6C12C@llvm.org> Author: spyffe Date: Tue Mar 22 16:45:30 2011 New Revision: 128111 URL: http://llvm.org/viewvc/llvm-project?rev=128111&view=rev Log: Added AVX support to the Intel portion of debugserver. AVX autodetection is not yet implemented, but the structures and register reading/writing code are there. Added: lldb/trunk/tools/debugserver/source/MacOSX/i386/MachRegisterStatesI386.h lldb/trunk/tools/debugserver/source/MacOSX/x86_64/MachRegisterStatesX86_64.h Modified: lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj lldb/trunk/tools/debugserver/source/DNBDefs.h lldb/trunk/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.cpp lldb/trunk/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.h lldb/trunk/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp lldb/trunk/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.h Modified: lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj?rev=128111&r1=128110&r2=128111&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj (original) +++ lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj Tue Mar 22 16:45:30 2011 @@ -125,6 +125,8 @@ 26CF99A21142EB7400011AAB /* DNBArchImplX86_64.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DNBArchImplX86_64.cpp; sourceTree = ""; }; 26CF99A31142EB7400011AAB /* DNBArchImplX86_64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DNBArchImplX86_64.h; sourceTree = ""; }; 26E6B9DA0D1329010037ECDD /* RNBDefs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RNBDefs.h; sourceTree = ""; }; + 49F530111331519C008956F6 /* MachRegisterStatesI386.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MachRegisterStatesI386.h; sourceTree = ""; }; + 49F5301213316D7F008956F6 /* MachRegisterStatesX86_64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MachRegisterStatesX86_64.h; sourceTree = ""; }; AF67ABFF0D34604D0022D128 /* PseudoTerminal.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PseudoTerminal.cpp; sourceTree = ""; }; AF67AC000D34604D0022D128 /* PseudoTerminal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PseudoTerminal.h; sourceTree = ""; }; EF88788B0D9C7558001831DA /* com.apple.debugserver.applist.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = com.apple.debugserver.applist.plist; sourceTree = ""; }; @@ -302,6 +304,7 @@ children = ( 26C637EA0C71334A0024798E /* DNBArchImplI386.cpp */, 26C637EB0C71334A0024798E /* DNBArchImplI386.h */, + 49F530111331519C008956F6 /* MachRegisterStatesI386.h */, ); path = i386; sourceTree = ""; @@ -320,6 +323,7 @@ children = ( 26CF99A21142EB7400011AAB /* DNBArchImplX86_64.cpp */, 26CF99A31142EB7400011AAB /* DNBArchImplX86_64.h */, + 49F5301213316D7F008956F6 /* MachRegisterStatesX86_64.h */, ); path = x86_64; sourceTree = ""; @@ -523,7 +527,7 @@ "$(SDKROOT)$(DEVELOPER_LIBRARY_DIR)/PrivateFrameworks", ); "FRAMEWORK_SEARCH_PATHS[sdk=macosx*][arch=*]" = "$(SDKROOT)/System/Library/PrivateFrameworks"; - GCC_PREPROCESSOR_DEFINITIONS = LLDB_DEBUGSERVER; + GCC_PREPROCESSOR_DEFINITIONS = LLDB_DEBUGSERVER_BUILDANDINTEGRATION; HEADER_SEARCH_PATHS = /System/Library/Frameworks/System.framework/PrivateHeaders; INSTALL_PATH = /Developer/usr/bin; LLDB_DEBUGSERVER = 1; @@ -565,7 +569,7 @@ "FRAMEWORK_SEARCH_PATHS[sdk=macosx*][arch=*]" = "$(SDKROOT)/System/Library/PrivateFrameworks"; GCC_DYNAMIC_NO_PIC = NO; GCC_OPTIMIZATION_LEVEL = 0; - GCC_PREPROCESSOR_DEFINITIONS = LLDB_DEBUGSERVER; + GCC_PREPROCESSOR_DEFINITIONS = LLDB_DEBUGSERVER_DEBUG; INSTALL_PATH = /Developer/usr/bin; LLDB_DEBUGSERVER = 1; OTHER_CFLAGS = "-Wparentheses"; @@ -605,7 +609,7 @@ "$(SDKROOT)$(DEVELOPER_LIBRARY_DIR)/PrivateFrameworks", ); "FRAMEWORK_SEARCH_PATHS[sdk=macosx*][arch=*]" = "$(SDKROOT)/System/Library/PrivateFrameworks"; - GCC_PREPROCESSOR_DEFINITIONS = LLDB_DEBUGSERVER; + GCC_PREPROCESSOR_DEFINITIONS = LLDB_DEBUGSERVER_RELEASE; HEADER_SEARCH_PATHS = /System/Library/Frameworks/System.framework/PrivateHeaders; INSTALL_PATH = /Developer/usr/bin; LLDB_DEBUGSERVER = 1; Modified: lldb/trunk/tools/debugserver/source/DNBDefs.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/DNBDefs.h?rev=128111&r1=128110&r2=128111&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/source/DNBDefs.h (original) +++ lldb/trunk/tools/debugserver/source/DNBDefs.h Tue Mar 22 16:45:30 2011 @@ -281,16 +281,16 @@ uint64_t uint64; float float32; double float64; - int8_t v_sint8[16]; - int16_t v_sint16[8]; - int32_t v_sint32[4]; - int64_t v_sint64[2]; - uint8_t v_uint8[16]; - uint16_t v_uint16[8]; - uint32_t v_uint32[4]; - uint64_t v_uint64[2]; - float v_float32[4]; - double v_float64[2]; + int8_t v_sint8[32]; + int16_t v_sint16[16]; + int32_t v_sint32[8]; + int64_t v_sint64[4]; + uint8_t v_uint8[32]; + uint16_t v_uint16[16]; + uint32_t v_uint32[8]; + uint64_t v_uint64[4]; + float v_float32[8]; + double v_float64[4]; void *pointer; char *c_str; } value; Modified: lldb/trunk/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.cpp?rev=128111&r1=128110&r2=128111&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.cpp (original) +++ lldb/trunk/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.cpp Tue Mar 22 16:45:30 2011 @@ -20,6 +20,49 @@ #include "MachThread.h" #include "MachProcess.h" +#if defined (LLDB_DEBUGSERVER_RELEASE) || defined (LLDB_DEBUGSERVER_DEBUG) +enum debugState { + debugStateUnknown, + debugStateOff, + debugStateOn +}; + +static debugState sFPUDebugState = debugStateUnknown; +static debugState sAVXForceState = debugStateUnknown; + +static bool DebugFPURegs () +{ + if (sFPUDebugState == debugStateUnknown) + { + if (getenv("DNB_DEBUG_FPU_REGS")) + sFPUDebugState = debugStateOn; + else + sFPUDebugState = debugStateOff; + } + + return (sFPUDebugState == debugStateOn); +} + +static bool ForceAVXRegs () +{ + if (sFPUDebugState == debugStateUnknown) + { + if (getenv("DNB_DEBUG_X86_FORCE_AVX_REGS")) + sAVXForceState = debugStateOn; + else + sAVXForceState = debugStateOff; + } + + return (sAVXForceState == debugStateOn); +} + +#define DEBUG_FPU_REGS (DebugFPURegs()) +#define FORCE_AVX_REGS (ForceAVXRegs()) +#else +#define DEBUG_FPU_REGS (0) +#define FORCE_AVX_REGS (0) +#endif + enum { gpr_eax = 0, @@ -68,6 +111,14 @@ fpu_xmm5, fpu_xmm6, fpu_xmm7, + fpu_ymm0, + fpu_ymm1, + fpu_ymm2, + fpu_ymm3, + fpu_ymm4, + fpu_ymm5, + fpu_ymm6, + fpu_ymm7, k_num_fpu_regs, // Aliases @@ -129,7 +180,15 @@ dwarf_xmm4, dwarf_xmm5, dwarf_xmm6, - dwarf_xmm7 + dwarf_xmm7, + dwarf_ymm0 = dwarf_xmm0, + dwarf_ymm1 = dwarf_xmm1, + dwarf_ymm2 = dwarf_xmm2, + dwarf_ymm3 = dwarf_xmm3, + dwarf_ymm4 = dwarf_xmm4, + dwarf_ymm5 = dwarf_xmm5, + dwarf_ymm6 = dwarf_xmm6, + dwarf_ymm7 = dwarf_xmm7, }; enum @@ -182,9 +241,19 @@ gdb_mm4 = 45, gdb_mm5 = 46, gdb_mm6 = 47, - gdb_mm7 = 48 + gdb_mm7 = 48, + gdb_ymm0 = gdb_xmm0, + gdb_ymm1 = gdb_xmm1, + gdb_ymm2 = gdb_xmm2, + gdb_ymm3 = gdb_xmm3, + gdb_ymm4 = gdb_xmm4, + gdb_ymm5 = gdb_xmm5, + gdb_ymm6 = gdb_xmm6, + gdb_ymm7 = gdb_xmm7 }; +enum DNBArchImplI386::AVXPresence DNBArchImplI386::s_has_avx = DNBArchImplI386::kAVXUnknown; + uint64_t DNBArchImplI386::GetPC(uint64_t failValue) { @@ -245,7 +314,7 @@ m_state.SetError(e_regSetGPR, Read, 0); #else mach_msg_type_number_t count = e_regSetWordSizeGPR; - m_state.SetError(e_regSetGPR, Read, ::thread_get_state(m_thread->ThreadID(), x86_THREAD_STATE32, (thread_state_t)&m_state.context.gpr, &count)); + m_state.SetError(e_regSetGPR, Read, ::thread_get_state(m_thread->ThreadID(), __i386_THREAD_STATE, (thread_state_t)&m_state.context.gpr, &count)); #endif } return m_state.GetError(e_regSetGPR, Read); @@ -259,65 +328,149 @@ { if (force || m_state.GetError(e_regSetFPU, Read)) { -#if DEBUG_FPU_VALUES - m_state.context.fpu.__fpu_reserved[0] = -1; - m_state.context.fpu.__fpu_reserved[1] = -1; - *(uint16_t *)&(m_state.context.fpu.__fpu_fcw) = 0x1234; - *(uint16_t *)&(m_state.context.fpu.__fpu_fsw) = 0x5678; - m_state.context.fpu.__fpu_ftw = 1; - m_state.context.fpu.__fpu_rsrv1 = UINT8_MAX; - m_state.context.fpu.__fpu_fop = 2; - m_state.context.fpu.__fpu_ip = 3; - m_state.context.fpu.__fpu_cs = 4; - m_state.context.fpu.__fpu_rsrv2 = 5; - m_state.context.fpu.__fpu_dp = 6; - m_state.context.fpu.__fpu_ds = 7; - m_state.context.fpu.__fpu_rsrv3 = UINT16_MAX; - m_state.context.fpu.__fpu_mxcsr = 8; - m_state.context.fpu.__fpu_mxcsrmask = 9; - int i; - for (i=0; i<16; ++i) - { - if (i<10) + if (DEBUG_FPU_REGS) { - m_state.context.fpu.__fpu_stmm0.__mmst_reg[i] = 'a'; - m_state.context.fpu.__fpu_stmm1.__mmst_reg[i] = 'b'; - m_state.context.fpu.__fpu_stmm2.__mmst_reg[i] = 'c'; - m_state.context.fpu.__fpu_stmm3.__mmst_reg[i] = 'd'; - m_state.context.fpu.__fpu_stmm4.__mmst_reg[i] = 'e'; - m_state.context.fpu.__fpu_stmm5.__mmst_reg[i] = 'f'; - m_state.context.fpu.__fpu_stmm6.__mmst_reg[i] = 'g'; - m_state.context.fpu.__fpu_stmm7.__mmst_reg[i] = 'h'; + if (HasAVX() || FORCE_AVX_REGS) + { + m_state.context.fpu.avx.__fpu_reserved[0] = -1; + m_state.context.fpu.avx.__fpu_reserved[1] = -1; + *(uint16_t *)&(m_state.context.fpu.avx.__fpu_fcw) = 0x1234; + *(uint16_t *)&(m_state.context.fpu.avx.__fpu_fsw) = 0x5678; + m_state.context.fpu.avx.__fpu_ftw = 1; + m_state.context.fpu.avx.__fpu_rsrv1 = UINT8_MAX; + m_state.context.fpu.avx.__fpu_fop = 2; + m_state.context.fpu.avx.__fpu_ip = 3; + m_state.context.fpu.avx.__fpu_cs = 4; + m_state.context.fpu.avx.__fpu_rsrv2 = 5; + m_state.context.fpu.avx.__fpu_dp = 6; + m_state.context.fpu.avx.__fpu_ds = 7; + m_state.context.fpu.avx.__fpu_rsrv3 = UINT16_MAX; + m_state.context.fpu.avx.__fpu_mxcsr = 8; + m_state.context.fpu.avx.__fpu_mxcsrmask = 9; + int i; + for (i=0; i<16; ++i) + { + if (i<10) + { + m_state.context.fpu.avx.__fpu_stmm0.__mmst_reg[i] = 'a'; + m_state.context.fpu.avx.__fpu_stmm1.__mmst_reg[i] = 'b'; + m_state.context.fpu.avx.__fpu_stmm2.__mmst_reg[i] = 'c'; + m_state.context.fpu.avx.__fpu_stmm3.__mmst_reg[i] = 'd'; + m_state.context.fpu.avx.__fpu_stmm4.__mmst_reg[i] = 'e'; + m_state.context.fpu.avx.__fpu_stmm5.__mmst_reg[i] = 'f'; + m_state.context.fpu.avx.__fpu_stmm6.__mmst_reg[i] = 'g'; + m_state.context.fpu.avx.__fpu_stmm7.__mmst_reg[i] = 'h'; + } + else + { + m_state.context.fpu.avx.__fpu_stmm0.__mmst_reg[i] = INT8_MIN; + m_state.context.fpu.avx.__fpu_stmm1.__mmst_reg[i] = INT8_MIN; + m_state.context.fpu.avx.__fpu_stmm2.__mmst_reg[i] = INT8_MIN; + m_state.context.fpu.avx.__fpu_stmm3.__mmst_reg[i] = INT8_MIN; + m_state.context.fpu.avx.__fpu_stmm4.__mmst_reg[i] = INT8_MIN; + m_state.context.fpu.avx.__fpu_stmm5.__mmst_reg[i] = INT8_MIN; + m_state.context.fpu.avx.__fpu_stmm6.__mmst_reg[i] = INT8_MIN; + m_state.context.fpu.avx.__fpu_stmm7.__mmst_reg[i] = INT8_MIN; + } + + m_state.context.fpu.avx.__fpu_xmm0.__xmm_reg[i] = '0'; + m_state.context.fpu.avx.__fpu_xmm1.__xmm_reg[i] = '1'; + m_state.context.fpu.avx.__fpu_xmm2.__xmm_reg[i] = '2'; + m_state.context.fpu.avx.__fpu_xmm3.__xmm_reg[i] = '3'; + m_state.context.fpu.avx.__fpu_xmm4.__xmm_reg[i] = '4'; + m_state.context.fpu.avx.__fpu_xmm5.__xmm_reg[i] = '5'; + m_state.context.fpu.avx.__fpu_xmm6.__xmm_reg[i] = '6'; + m_state.context.fpu.avx.__fpu_xmm7.__xmm_reg[i] = '7'; + } + for (i=0; iThreadID(), __i386_AVX_STATE, (thread_state_t)&m_state.context.fpu.avx, &count)); + } + else + { + mach_msg_type_number_t count = e_regSetWordSizeFPR; + m_state.SetError(e_regSetFPU, Read, ::thread_get_state(m_thread->ThreadID(), __i386_FLOAT_STATE, (thread_state_t)&m_state.context.fpu.no_avx, &count)); + } } - - m_state.context.fpu.__fpu_xmm0.__xmm_reg[i] = '0'; - m_state.context.fpu.__fpu_xmm1.__xmm_reg[i] = '1'; - m_state.context.fpu.__fpu_xmm2.__xmm_reg[i] = '2'; - m_state.context.fpu.__fpu_xmm3.__xmm_reg[i] = '3'; - m_state.context.fpu.__fpu_xmm4.__xmm_reg[i] = '4'; - m_state.context.fpu.__fpu_xmm5.__xmm_reg[i] = '5'; - m_state.context.fpu.__fpu_xmm6.__xmm_reg[i] = '6'; - m_state.context.fpu.__fpu_xmm7.__xmm_reg[i] = '7'; - } - for (i=0; iThreadID(), x86_FLOAT_STATE32, (thread_state_t)&m_state.context.fpu, &count)); -#endif } return m_state.GetError(e_regSetFPU, Read); } @@ -328,7 +481,7 @@ if (force || m_state.GetError(e_regSetEXC, Read)) { mach_msg_type_number_t count = e_regSetWordSizeEXC; - m_state.SetError(e_regSetEXC, Read, ::thread_get_state(m_thread->ThreadID(), x86_EXCEPTION_STATE32, (thread_state_t)&m_state.context.exc, &count)); + m_state.SetError(e_regSetEXC, Read, ::thread_get_state(m_thread->ThreadID(), __i386_EXCEPTION_STATE, (thread_state_t)&m_state.context.exc, &count)); } return m_state.GetError(e_regSetEXC, Read); } @@ -336,21 +489,32 @@ kern_return_t DNBArchImplI386::SetGPRState() { - m_state.SetError(e_regSetGPR, Write, ::thread_set_state(m_thread->ThreadID(), x86_THREAD_STATE32, (thread_state_t)&m_state.context.gpr, e_regSetWordSizeGPR)); + m_state.SetError(e_regSetGPR, Write, ::thread_set_state(m_thread->ThreadID(), __i386_THREAD_STATE, (thread_state_t)&m_state.context.gpr, e_regSetWordSizeGPR)); return m_state.GetError(e_regSetGPR, Write); } kern_return_t DNBArchImplI386::SetFPUState() { - m_state.SetError(e_regSetFPU, Write, ::thread_set_state(m_thread->ThreadID(), x86_FLOAT_STATE32, (thread_state_t)&m_state.context.fpu, e_regSetWordSizeFPR)); - return m_state.GetError(e_regSetFPU, Write); + if (DEBUG_FPU_REGS) + { + m_state.SetError(e_regSetFPU, Write, 0); + return m_state.GetError(e_regSetFPU, Write); + } + else + { + if (HasAVX() || FORCE_AVX_REGS) + m_state.SetError(e_regSetFPU, Write, ::thread_set_state(m_thread->ThreadID(), __i386_AVX_STATE, (thread_state_t)&m_state.context.fpu.avx, e_regSetWordSizeAVX)); + else + m_state.SetError(e_regSetFPU, Write, ::thread_set_state(m_thread->ThreadID(), __i386_FLOAT_STATE, (thread_state_t)&m_state.context.fpu.no_avx, e_regSetWordSizeFPR)); + return m_state.GetError(e_regSetFPU, Write); + } } kern_return_t DNBArchImplI386::SetEXCState() { - m_state.SetError(e_regSetEXC, Write, ::thread_set_state(m_thread->ThreadID(), x86_EXCEPTION_STATE32, (thread_state_t)&m_state.context.exc, e_regSetWordSizeEXC)); + m_state.SetError(e_regSetEXC, Write, ::thread_set_state(m_thread->ThreadID(), __i386_EXCEPTION_STATE, (thread_state_t)&m_state.context.exc, e_regSetWordSizeEXC)); return m_state.GetError(e_regSetEXC, Write); } @@ -467,15 +631,24 @@ #define GPR_OFFSET(reg) (offsetof (DNBArchImplI386::GPR, __##reg)) -#define FPU_OFFSET(reg) (offsetof (DNBArchImplI386::FPU, __fpu_##reg) + offsetof (DNBArchImplI386::Context, fpu)) +#define FPU_OFFSET(reg) (offsetof (DNBArchImplI386::FPU, __fpu_##reg) + offsetof (DNBArchImplI386::Context, fpu.no_avx)) +#define AVX_OFFSET(reg) (offsetof (DNBArchImplI386::AVX, __fpu_##reg) + offsetof (DNBArchImplI386::Context, fpu.avx)) #define EXC_OFFSET(reg) (offsetof (DNBArchImplI386::EXC, __##reg) + offsetof (DNBArchImplI386::Context, exc)) #define GPR_SIZE(reg) (sizeof(((DNBArchImplI386::GPR *)NULL)->__##reg)) #define FPU_SIZE_UINT(reg) (sizeof(((DNBArchImplI386::FPU *)NULL)->__fpu_##reg)) #define FPU_SIZE_MMST(reg) (sizeof(((DNBArchImplI386::FPU *)NULL)->__fpu_##reg.__mmst_reg)) #define FPU_SIZE_XMM(reg) (sizeof(((DNBArchImplI386::FPU *)NULL)->__fpu_##reg.__xmm_reg)) +#define FPU_SIZE_YMM(reg) (32) #define EXC_SIZE(reg) (sizeof(((DNBArchImplI386::EXC *)NULL)->__##reg)) +// This does not accurately identify the location of ymm0...7 in +// Context.fpu.avx. That is because there is a bunch of padding +// in Context.fpu.avx that we don't need. Offset macros lay out +// the register state that Debugserver transmits to the debugger +// -- not to interpret the thread_get_state info. +#define AVX_OFFSET_YMM(n) (AVX_OFFSET(xmm7) + FPU_SIZE_XMM(xmm7) + (32 * n)) + // These macros will auto define the register name, alt name, register size, // register offset, encoding, format and native register. This ensures that // the register state structures are defined correctly and have the correct @@ -505,7 +678,7 @@ const DNBRegisterInfo -DNBArchImplI386::g_fpu_registers[] = +DNBArchImplI386::g_fpu_registers_no_avx[] = { { e_regSetFPU, fpu_fcw , "fctrl" , NULL, Uint, Hex, FPU_SIZE_UINT(fcw) , FPU_OFFSET(fcw) , -1, -1, -1, -1 }, { e_regSetFPU, fpu_fsw , "fstat" , NULL, Uint, Hex, FPU_SIZE_UINT(fsw) , FPU_OFFSET(fsw) , -1, -1, -1, -1 }, @@ -537,7 +710,47 @@ { e_regSetFPU, fpu_xmm7, "xmm7", NULL, Vector, VectorOfUInt8, FPU_SIZE_XMM(xmm7), FPU_OFFSET(xmm7), -1, dwarf_xmm7, -1, gdb_xmm7 } }; - +const DNBRegisterInfo +DNBArchImplI386::g_fpu_registers_avx[] = +{ +{ e_regSetFPU, fpu_fcw , "fctrl" , NULL, Uint, Hex, FPU_SIZE_UINT(fcw) , AVX_OFFSET(fcw) , -1, -1, -1, -1 }, +{ e_regSetFPU, fpu_fsw , "fstat" , NULL, Uint, Hex, FPU_SIZE_UINT(fsw) , AVX_OFFSET(fsw) , -1, -1, -1, -1 }, +{ e_regSetFPU, fpu_ftw , "ftag" , NULL, Uint, Hex, FPU_SIZE_UINT(ftw) , AVX_OFFSET(ftw) , -1, -1, -1, -1 }, +{ e_regSetFPU, fpu_fop , "fop" , NULL, Uint, Hex, FPU_SIZE_UINT(fop) , AVX_OFFSET(fop) , -1, -1, -1, -1 }, +{ e_regSetFPU, fpu_ip , "fioff" , NULL, Uint, Hex, FPU_SIZE_UINT(ip) , AVX_OFFSET(ip) , -1, -1, -1, -1 }, +{ e_regSetFPU, fpu_cs , "fiseg" , NULL, Uint, Hex, FPU_SIZE_UINT(cs) , AVX_OFFSET(cs) , -1, -1, -1, -1 }, +{ e_regSetFPU, fpu_dp , "fooff" , NULL, Uint, Hex, FPU_SIZE_UINT(dp) , AVX_OFFSET(dp) , -1, -1, -1, -1 }, +{ e_regSetFPU, fpu_ds , "foseg" , NULL, Uint, Hex, FPU_SIZE_UINT(ds) , AVX_OFFSET(ds) , -1, -1, -1, -1 }, +{ e_regSetFPU, fpu_mxcsr , "mxcsr" , NULL, Uint, Hex, FPU_SIZE_UINT(mxcsr) , AVX_OFFSET(mxcsr) , -1, -1, -1, -1 }, +{ e_regSetFPU, fpu_mxcsrmask, "mxcsrmask" , NULL, Uint, Hex, FPU_SIZE_UINT(mxcsrmask) , AVX_OFFSET(mxcsrmask) , -1, -1, -1, -1 }, + +{ e_regSetFPU, fpu_stmm0, "stmm0", NULL, Vector, VectorOfUInt8, FPU_SIZE_MMST(stmm0), AVX_OFFSET(stmm0), -1, dwarf_stmm0, -1, gdb_stmm0 }, +{ e_regSetFPU, fpu_stmm1, "stmm1", NULL, Vector, VectorOfUInt8, FPU_SIZE_MMST(stmm1), AVX_OFFSET(stmm1), -1, dwarf_stmm1, -1, gdb_stmm1 }, +{ e_regSetFPU, fpu_stmm2, "stmm2", NULL, Vector, VectorOfUInt8, FPU_SIZE_MMST(stmm2), AVX_OFFSET(stmm2), -1, dwarf_stmm2, -1, gdb_stmm2 }, +{ e_regSetFPU, fpu_stmm3, "stmm3", NULL, Vector, VectorOfUInt8, FPU_SIZE_MMST(stmm3), AVX_OFFSET(stmm3), -1, dwarf_stmm3, -1, gdb_stmm3 }, +{ e_regSetFPU, fpu_stmm4, "stmm4", NULL, Vector, VectorOfUInt8, FPU_SIZE_MMST(stmm4), AVX_OFFSET(stmm4), -1, dwarf_stmm4, -1, gdb_stmm4 }, +{ e_regSetFPU, fpu_stmm5, "stmm5", NULL, Vector, VectorOfUInt8, FPU_SIZE_MMST(stmm5), AVX_OFFSET(stmm5), -1, dwarf_stmm5, -1, gdb_stmm5 }, +{ e_regSetFPU, fpu_stmm6, "stmm6", NULL, Vector, VectorOfUInt8, FPU_SIZE_MMST(stmm6), AVX_OFFSET(stmm6), -1, dwarf_stmm6, -1, gdb_stmm6 }, +{ e_regSetFPU, fpu_stmm7, "stmm7", NULL, Vector, VectorOfUInt8, FPU_SIZE_MMST(stmm7), AVX_OFFSET(stmm7), -1, dwarf_stmm7, -1, gdb_stmm7 }, + +{ e_regSetFPU, fpu_xmm0, "xmm0", NULL, Vector, VectorOfUInt8, FPU_SIZE_XMM(xmm0), AVX_OFFSET(xmm0), -1, dwarf_xmm0, -1, gdb_xmm0 }, +{ e_regSetFPU, fpu_xmm1, "xmm1", NULL, Vector, VectorOfUInt8, FPU_SIZE_XMM(xmm1), AVX_OFFSET(xmm1), -1, dwarf_xmm1, -1, gdb_xmm1 }, +{ e_regSetFPU, fpu_xmm2, "xmm2", NULL, Vector, VectorOfUInt8, FPU_SIZE_XMM(xmm2), AVX_OFFSET(xmm2), -1, dwarf_xmm2, -1, gdb_xmm2 }, +{ e_regSetFPU, fpu_xmm3, "xmm3", NULL, Vector, VectorOfUInt8, FPU_SIZE_XMM(xmm3), AVX_OFFSET(xmm3), -1, dwarf_xmm3, -1, gdb_xmm3 }, +{ e_regSetFPU, fpu_xmm4, "xmm4", NULL, Vector, VectorOfUInt8, FPU_SIZE_XMM(xmm4), AVX_OFFSET(xmm4), -1, dwarf_xmm4, -1, gdb_xmm4 }, +{ e_regSetFPU, fpu_xmm5, "xmm5", NULL, Vector, VectorOfUInt8, FPU_SIZE_XMM(xmm5), AVX_OFFSET(xmm5), -1, dwarf_xmm5, -1, gdb_xmm5 }, +{ e_regSetFPU, fpu_xmm6, "xmm6", NULL, Vector, VectorOfUInt8, FPU_SIZE_XMM(xmm6), AVX_OFFSET(xmm6), -1, dwarf_xmm6, -1, gdb_xmm6 }, +{ e_regSetFPU, fpu_xmm7, "xmm7", NULL, Vector, VectorOfUInt8, FPU_SIZE_XMM(xmm7), AVX_OFFSET(xmm7), -1, dwarf_xmm7, -1, gdb_xmm7 }, + +{ e_regSetFPU, fpu_ymm0, "ymm0", NULL, Vector, VectorOfUInt8, FPU_SIZE_YMM(ymm0), AVX_OFFSET_YMM(0), -1, dwarf_ymm0, -1, gdb_ymm0 }, +{ e_regSetFPU, fpu_ymm1, "ymm1", NULL, Vector, VectorOfUInt8, FPU_SIZE_YMM(ymm1), AVX_OFFSET_YMM(1), -1, dwarf_ymm1, -1, gdb_ymm1 }, +{ e_regSetFPU, fpu_ymm2, "ymm2", NULL, Vector, VectorOfUInt8, FPU_SIZE_YMM(ymm2), AVX_OFFSET_YMM(2), -1, dwarf_ymm2, -1, gdb_ymm2 }, +{ e_regSetFPU, fpu_ymm3, "ymm3", NULL, Vector, VectorOfUInt8, FPU_SIZE_YMM(ymm3), AVX_OFFSET_YMM(3), -1, dwarf_ymm3, -1, gdb_ymm3 }, +{ e_regSetFPU, fpu_ymm4, "ymm4", NULL, Vector, VectorOfUInt8, FPU_SIZE_YMM(ymm4), AVX_OFFSET_YMM(4), -1, dwarf_ymm4, -1, gdb_ymm4 }, +{ e_regSetFPU, fpu_ymm5, "ymm5", NULL, Vector, VectorOfUInt8, FPU_SIZE_YMM(ymm5), AVX_OFFSET_YMM(5), -1, dwarf_ymm5, -1, gdb_ymm5 }, +{ e_regSetFPU, fpu_ymm6, "ymm6", NULL, Vector, VectorOfUInt8, FPU_SIZE_YMM(ymm6), AVX_OFFSET_YMM(6), -1, dwarf_ymm6, -1, gdb_ymm6 }, +{ e_regSetFPU, fpu_ymm7, "ymm7", NULL, Vector, VectorOfUInt8, FPU_SIZE_YMM(ymm7), AVX_OFFSET_YMM(7), -1, dwarf_ymm7, -1, gdb_ymm7 }, +}; const DNBRegisterInfo DNBArchImplI386::g_exc_registers[] = @@ -549,9 +762,11 @@ // Number of registers in each register set const size_t DNBArchImplI386::k_num_gpr_registers = sizeof(g_gpr_registers)/sizeof(DNBRegisterInfo); -const size_t DNBArchImplI386::k_num_fpu_registers = sizeof(g_fpu_registers)/sizeof(DNBRegisterInfo); +const size_t DNBArchImplI386::k_num_fpu_registers_no_avx = sizeof(g_fpu_registers_no_avx)/sizeof(DNBRegisterInfo); +const size_t DNBArchImplI386::k_num_fpu_registers_avx = sizeof(g_fpu_registers_avx)/sizeof(DNBRegisterInfo); const size_t DNBArchImplI386::k_num_exc_registers = sizeof(g_exc_registers)/sizeof(DNBRegisterInfo); -const size_t DNBArchImplI386::k_num_all_registers = k_num_gpr_registers + k_num_fpu_registers + k_num_exc_registers; +const size_t DNBArchImplI386::k_num_all_registers_no_avx = k_num_gpr_registers + k_num_fpu_registers_no_avx + k_num_exc_registers; +const size_t DNBArchImplI386::k_num_all_registers_avx = k_num_gpr_registers + k_num_fpu_registers_avx + k_num_exc_registers; //---------------------------------------------------------------------- // Register set definitions. The first definitions at register set index @@ -559,16 +774,25 @@ // register information for the all register set need not be filled in. //---------------------------------------------------------------------- const DNBRegisterSetInfo -DNBArchImplI386::g_reg_sets[] = +DNBArchImplI386::g_reg_sets_no_avx[] = { - { "i386 Registers", NULL, k_num_all_registers }, - { "General Purpose Registers", g_gpr_registers, k_num_gpr_registers }, - { "Floating Point Registers", g_fpu_registers, k_num_fpu_registers }, - { "Exception State Registers", g_exc_registers, k_num_exc_registers } + { "i386 Registers", NULL, k_num_all_registers_no_avx }, + { "General Purpose Registers", g_gpr_registers, k_num_gpr_registers }, + { "Floating Point Registers", g_fpu_registers_no_avx, k_num_fpu_registers_no_avx }, + { "Exception State Registers", g_exc_registers, k_num_exc_registers } }; -// Total number of register sets for this architecture -const size_t DNBArchImplI386::k_num_register_sets = sizeof(g_reg_sets)/sizeof(DNBRegisterSetInfo); +const DNBRegisterSetInfo +DNBArchImplI386::g_reg_sets_avx[] = +{ + { "i386 Registers", NULL, k_num_all_registers_avx }, + { "General Purpose Registers", g_gpr_registers, k_num_gpr_registers }, + { "Floating Point Registers", g_fpu_registers_avx, k_num_fpu_registers_avx }, + { "Exception State Registers", g_exc_registers, k_num_exc_registers } +}; + +// Total number of register sets for this architecture +const size_t DNBArchImplI386::k_num_register_sets = sizeof(g_reg_sets_no_avx)/sizeof(DNBRegisterSetInfo); DNBArchProtocol * DNBArchImplI386::Create (MachThread *thread) @@ -589,7 +813,10 @@ DNBArchImplI386::GetRegisterSetInfo(nub_size_t *num_reg_sets) { *num_reg_sets = k_num_register_sets; - return g_reg_sets; + if (HasAVX() || FORCE_AVX_REGS) + return g_reg_sets_avx; + else + return g_reg_sets_no_avx; } @@ -659,36 +886,86 @@ break; case e_regSetFPU: - switch (reg) + if (HasAVX() || FORCE_AVX_REGS) { - case fpu_fcw: value->value.uint16 = *((uint16_t *)(&m_state.context.fpu.__fpu_fcw)); return true; - case fpu_fsw: value->value.uint16 = *((uint16_t *)(&m_state.context.fpu.__fpu_fsw)); return true; - case fpu_ftw: value->value.uint8 = m_state.context.fpu.__fpu_ftw; return true; - case fpu_fop: value->value.uint16 = m_state.context.fpu.__fpu_fop; return true; - case fpu_ip: value->value.uint32 = m_state.context.fpu.__fpu_ip; return true; - case fpu_cs: value->value.uint16 = m_state.context.fpu.__fpu_cs; return true; - case fpu_dp: value->value.uint32 = m_state.context.fpu.__fpu_dp; return true; - case fpu_ds: value->value.uint16 = m_state.context.fpu.__fpu_ds; return true; - case fpu_mxcsr: value->value.uint32 = m_state.context.fpu.__fpu_mxcsr; return true; - case fpu_mxcsrmask: value->value.uint32 = m_state.context.fpu.__fpu_mxcsrmask; return true; - - case fpu_stmm0: memcpy(&value->value.uint8, m_state.context.fpu.__fpu_stmm0.__mmst_reg, 10); return true; - case fpu_stmm1: memcpy(&value->value.uint8, m_state.context.fpu.__fpu_stmm1.__mmst_reg, 10); return true; - case fpu_stmm2: memcpy(&value->value.uint8, m_state.context.fpu.__fpu_stmm2.__mmst_reg, 10); return true; - case fpu_stmm3: memcpy(&value->value.uint8, m_state.context.fpu.__fpu_stmm3.__mmst_reg, 10); return true; - case fpu_stmm4: memcpy(&value->value.uint8, m_state.context.fpu.__fpu_stmm4.__mmst_reg, 10); return true; - case fpu_stmm5: memcpy(&value->value.uint8, m_state.context.fpu.__fpu_stmm5.__mmst_reg, 10); return true; - case fpu_stmm6: memcpy(&value->value.uint8, m_state.context.fpu.__fpu_stmm6.__mmst_reg, 10); return true; - case fpu_stmm7: memcpy(&value->value.uint8, m_state.context.fpu.__fpu_stmm7.__mmst_reg, 10); return true; - - case fpu_xmm0: memcpy(&value->value.uint8, m_state.context.fpu.__fpu_xmm0.__xmm_reg, 16); return true; - case fpu_xmm1: memcpy(&value->value.uint8, m_state.context.fpu.__fpu_xmm1.__xmm_reg, 16); return true; - case fpu_xmm2: memcpy(&value->value.uint8, m_state.context.fpu.__fpu_xmm2.__xmm_reg, 16); return true; - case fpu_xmm3: memcpy(&value->value.uint8, m_state.context.fpu.__fpu_xmm3.__xmm_reg, 16); return true; - case fpu_xmm4: memcpy(&value->value.uint8, m_state.context.fpu.__fpu_xmm4.__xmm_reg, 16); return true; - case fpu_xmm5: memcpy(&value->value.uint8, m_state.context.fpu.__fpu_xmm5.__xmm_reg, 16); return true; - case fpu_xmm6: memcpy(&value->value.uint8, m_state.context.fpu.__fpu_xmm6.__xmm_reg, 16); return true; - case fpu_xmm7: memcpy(&value->value.uint8, m_state.context.fpu.__fpu_xmm7.__xmm_reg, 16); return true; + switch (reg) + { + case fpu_fcw: value->value.uint16 = *((uint16_t *)(&m_state.context.fpu.avx.__fpu_fcw)); return true; + case fpu_fsw: value->value.uint16 = *((uint16_t *)(&m_state.context.fpu.avx.__fpu_fsw)); return true; + case fpu_ftw: value->value.uint8 = m_state.context.fpu.avx.__fpu_ftw; return true; + case fpu_fop: value->value.uint16 = m_state.context.fpu.avx.__fpu_fop; return true; + case fpu_ip: value->value.uint32 = m_state.context.fpu.avx.__fpu_ip; return true; + case fpu_cs: value->value.uint16 = m_state.context.fpu.avx.__fpu_cs; return true; + case fpu_dp: value->value.uint32 = m_state.context.fpu.avx.__fpu_dp; return true; + case fpu_ds: value->value.uint16 = m_state.context.fpu.avx.__fpu_ds; return true; + case fpu_mxcsr: value->value.uint32 = m_state.context.fpu.avx.__fpu_mxcsr; return true; + case fpu_mxcsrmask: value->value.uint32 = m_state.context.fpu.avx.__fpu_mxcsrmask; return true; + + case fpu_stmm0: memcpy(&value->value.uint8, m_state.context.fpu.avx.__fpu_stmm0.__mmst_reg, 10); return true; + case fpu_stmm1: memcpy(&value->value.uint8, m_state.context.fpu.avx.__fpu_stmm1.__mmst_reg, 10); return true; + case fpu_stmm2: memcpy(&value->value.uint8, m_state.context.fpu.avx.__fpu_stmm2.__mmst_reg, 10); return true; + case fpu_stmm3: memcpy(&value->value.uint8, m_state.context.fpu.avx.__fpu_stmm3.__mmst_reg, 10); return true; + case fpu_stmm4: memcpy(&value->value.uint8, m_state.context.fpu.avx.__fpu_stmm4.__mmst_reg, 10); return true; + case fpu_stmm5: memcpy(&value->value.uint8, m_state.context.fpu.avx.__fpu_stmm5.__mmst_reg, 10); return true; + case fpu_stmm6: memcpy(&value->value.uint8, m_state.context.fpu.avx.__fpu_stmm6.__mmst_reg, 10); return true; + case fpu_stmm7: memcpy(&value->value.uint8, m_state.context.fpu.avx.__fpu_stmm7.__mmst_reg, 10); return true; + + case fpu_xmm0: memcpy(&value->value.uint8, m_state.context.fpu.avx.__fpu_xmm0.__xmm_reg, 16); return true; + case fpu_xmm1: memcpy(&value->value.uint8, m_state.context.fpu.avx.__fpu_xmm1.__xmm_reg, 16); return true; + case fpu_xmm2: memcpy(&value->value.uint8, m_state.context.fpu.avx.__fpu_xmm2.__xmm_reg, 16); return true; + case fpu_xmm3: memcpy(&value->value.uint8, m_state.context.fpu.avx.__fpu_xmm3.__xmm_reg, 16); return true; + case fpu_xmm4: memcpy(&value->value.uint8, m_state.context.fpu.avx.__fpu_xmm4.__xmm_reg, 16); return true; + case fpu_xmm5: memcpy(&value->value.uint8, m_state.context.fpu.avx.__fpu_xmm5.__xmm_reg, 16); return true; + case fpu_xmm6: memcpy(&value->value.uint8, m_state.context.fpu.avx.__fpu_xmm6.__xmm_reg, 16); return true; + case fpu_xmm7: memcpy(&value->value.uint8, m_state.context.fpu.avx.__fpu_xmm7.__xmm_reg, 16); return true; + +#define MEMCPY_YMM(n) \ + memcpy(&value->value.uint8, m_state.context.fpu.avx.__fpu_xmm##n.__xmm_reg, 16); \ + memcpy((&value->value.uint8) + 16, m_state.context.fpu.avx.__fpu_ymmh##n.__xmm_reg, 16); + case fpu_ymm0: MEMCPY_YMM(0); return true; + case fpu_ymm1: MEMCPY_YMM(1); return true; + case fpu_ymm2: MEMCPY_YMM(2); return true; + case fpu_ymm3: MEMCPY_YMM(3); return true; + case fpu_ymm4: MEMCPY_YMM(4); return true; + case fpu_ymm5: MEMCPY_YMM(5); return true; + case fpu_ymm6: MEMCPY_YMM(6); return true; + case fpu_ymm7: MEMCPY_YMM(7); return true; +#undef MEMCPY_YMM + } + } + else + { + switch (reg) + { + case fpu_fcw: value->value.uint16 = *((uint16_t *)(&m_state.context.fpu.no_avx.__fpu_fcw)); return true; + case fpu_fsw: value->value.uint16 = *((uint16_t *)(&m_state.context.fpu.no_avx.__fpu_fsw)); return true; + case fpu_ftw: value->value.uint8 = m_state.context.fpu.no_avx.__fpu_ftw; return true; + case fpu_fop: value->value.uint16 = m_state.context.fpu.no_avx.__fpu_fop; return true; + case fpu_ip: value->value.uint32 = m_state.context.fpu.no_avx.__fpu_ip; return true; + case fpu_cs: value->value.uint16 = m_state.context.fpu.no_avx.__fpu_cs; return true; + case fpu_dp: value->value.uint32 = m_state.context.fpu.no_avx.__fpu_dp; return true; + case fpu_ds: value->value.uint16 = m_state.context.fpu.no_avx.__fpu_ds; return true; + case fpu_mxcsr: value->value.uint32 = m_state.context.fpu.no_avx.__fpu_mxcsr; return true; + case fpu_mxcsrmask: value->value.uint32 = m_state.context.fpu.no_avx.__fpu_mxcsrmask; return true; + + case fpu_stmm0: memcpy(&value->value.uint8, m_state.context.fpu.no_avx.__fpu_stmm0.__mmst_reg, 10); return true; + case fpu_stmm1: memcpy(&value->value.uint8, m_state.context.fpu.no_avx.__fpu_stmm1.__mmst_reg, 10); return true; + case fpu_stmm2: memcpy(&value->value.uint8, m_state.context.fpu.no_avx.__fpu_stmm2.__mmst_reg, 10); return true; + case fpu_stmm3: memcpy(&value->value.uint8, m_state.context.fpu.no_avx.__fpu_stmm3.__mmst_reg, 10); return true; + case fpu_stmm4: memcpy(&value->value.uint8, m_state.context.fpu.no_avx.__fpu_stmm4.__mmst_reg, 10); return true; + case fpu_stmm5: memcpy(&value->value.uint8, m_state.context.fpu.no_avx.__fpu_stmm5.__mmst_reg, 10); return true; + case fpu_stmm6: memcpy(&value->value.uint8, m_state.context.fpu.no_avx.__fpu_stmm6.__mmst_reg, 10); return true; + case fpu_stmm7: memcpy(&value->value.uint8, m_state.context.fpu.no_avx.__fpu_stmm7.__mmst_reg, 10); return true; + + case fpu_xmm0: memcpy(&value->value.uint8, m_state.context.fpu.no_avx.__fpu_xmm0.__xmm_reg, 16); return true; + case fpu_xmm1: memcpy(&value->value.uint8, m_state.context.fpu.no_avx.__fpu_xmm1.__xmm_reg, 16); return true; + case fpu_xmm2: memcpy(&value->value.uint8, m_state.context.fpu.no_avx.__fpu_xmm2.__xmm_reg, 16); return true; + case fpu_xmm3: memcpy(&value->value.uint8, m_state.context.fpu.no_avx.__fpu_xmm3.__xmm_reg, 16); return true; + case fpu_xmm4: memcpy(&value->value.uint8, m_state.context.fpu.no_avx.__fpu_xmm4.__xmm_reg, 16); return true; + case fpu_xmm5: memcpy(&value->value.uint8, m_state.context.fpu.no_avx.__fpu_xmm5.__xmm_reg, 16); return true; + case fpu_xmm6: memcpy(&value->value.uint8, m_state.context.fpu.no_avx.__fpu_xmm6.__xmm_reg, 16); return true; + case fpu_xmm7: memcpy(&value->value.uint8, m_state.context.fpu.no_avx.__fpu_xmm7.__xmm_reg, 16); return true; + } } break; @@ -756,36 +1033,86 @@ break; case e_regSetFPU: - switch (reg) + if (HasAVX() || FORCE_AVX_REGS) { - case fpu_fcw: *((uint16_t *)(&m_state.context.fpu.__fpu_fcw)) = value->value.uint16; success = true; break; - case fpu_fsw: *((uint16_t *)(&m_state.context.fpu.__fpu_fsw)) = value->value.uint16; success = true; break; - case fpu_ftw: m_state.context.fpu.__fpu_ftw = value->value.uint8; success = true; break; - case fpu_fop: m_state.context.fpu.__fpu_fop = value->value.uint16; success = true; break; - case fpu_ip: m_state.context.fpu.__fpu_ip = value->value.uint32; success = true; break; - case fpu_cs: m_state.context.fpu.__fpu_cs = value->value.uint16; success = true; break; - case fpu_dp: m_state.context.fpu.__fpu_dp = value->value.uint32; success = true; break; - case fpu_ds: m_state.context.fpu.__fpu_ds = value->value.uint16; success = true; break; - case fpu_mxcsr: m_state.context.fpu.__fpu_mxcsr = value->value.uint32; success = true; break; - case fpu_mxcsrmask: m_state.context.fpu.__fpu_mxcsrmask = value->value.uint32; success = true; break; - - case fpu_stmm0: memcpy (m_state.context.fpu.__fpu_stmm0.__mmst_reg, &value->value.uint8, 10); success = true; break; - case fpu_stmm1: memcpy (m_state.context.fpu.__fpu_stmm1.__mmst_reg, &value->value.uint8, 10); success = true; break; - case fpu_stmm2: memcpy (m_state.context.fpu.__fpu_stmm2.__mmst_reg, &value->value.uint8, 10); success = true; break; - case fpu_stmm3: memcpy (m_state.context.fpu.__fpu_stmm3.__mmst_reg, &value->value.uint8, 10); success = true; break; - case fpu_stmm4: memcpy (m_state.context.fpu.__fpu_stmm4.__mmst_reg, &value->value.uint8, 10); success = true; break; - case fpu_stmm5: memcpy (m_state.context.fpu.__fpu_stmm5.__mmst_reg, &value->value.uint8, 10); success = true; break; - case fpu_stmm6: memcpy (m_state.context.fpu.__fpu_stmm6.__mmst_reg, &value->value.uint8, 10); success = true; break; - case fpu_stmm7: memcpy (m_state.context.fpu.__fpu_stmm7.__mmst_reg, &value->value.uint8, 10); success = true; break; - - case fpu_xmm0: memcpy(m_state.context.fpu.__fpu_xmm0.__xmm_reg, &value->value.uint8, 16); success = true; break; - case fpu_xmm1: memcpy(m_state.context.fpu.__fpu_xmm1.__xmm_reg, &value->value.uint8, 16); success = true; break; - case fpu_xmm2: memcpy(m_state.context.fpu.__fpu_xmm2.__xmm_reg, &value->value.uint8, 16); success = true; break; - case fpu_xmm3: memcpy(m_state.context.fpu.__fpu_xmm3.__xmm_reg, &value->value.uint8, 16); success = true; break; - case fpu_xmm4: memcpy(m_state.context.fpu.__fpu_xmm4.__xmm_reg, &value->value.uint8, 16); success = true; break; - case fpu_xmm5: memcpy(m_state.context.fpu.__fpu_xmm5.__xmm_reg, &value->value.uint8, 16); success = true; break; - case fpu_xmm6: memcpy(m_state.context.fpu.__fpu_xmm6.__xmm_reg, &value->value.uint8, 16); success = true; break; - case fpu_xmm7: memcpy(m_state.context.fpu.__fpu_xmm7.__xmm_reg, &value->value.uint8, 16); success = true; break; + switch (reg) + { + case fpu_fcw: *((uint16_t *)(&m_state.context.fpu.avx.__fpu_fcw)) = value->value.uint16; success = true; break; + case fpu_fsw: *((uint16_t *)(&m_state.context.fpu.avx.__fpu_fsw)) = value->value.uint16; success = true; break; + case fpu_ftw: m_state.context.fpu.avx.__fpu_ftw = value->value.uint8; success = true; break; + case fpu_fop: m_state.context.fpu.avx.__fpu_fop = value->value.uint16; success = true; break; + case fpu_ip: m_state.context.fpu.avx.__fpu_ip = value->value.uint32; success = true; break; + case fpu_cs: m_state.context.fpu.avx.__fpu_cs = value->value.uint16; success = true; break; + case fpu_dp: m_state.context.fpu.avx.__fpu_dp = value->value.uint32; success = true; break; + case fpu_ds: m_state.context.fpu.avx.__fpu_ds = value->value.uint16; success = true; break; + case fpu_mxcsr: m_state.context.fpu.avx.__fpu_mxcsr = value->value.uint32; success = true; break; + case fpu_mxcsrmask: m_state.context.fpu.avx.__fpu_mxcsrmask = value->value.uint32; success = true; break; + + case fpu_stmm0: memcpy (m_state.context.fpu.avx.__fpu_stmm0.__mmst_reg, &value->value.uint8, 10); success = true; break; + case fpu_stmm1: memcpy (m_state.context.fpu.avx.__fpu_stmm1.__mmst_reg, &value->value.uint8, 10); success = true; break; + case fpu_stmm2: memcpy (m_state.context.fpu.avx.__fpu_stmm2.__mmst_reg, &value->value.uint8, 10); success = true; break; + case fpu_stmm3: memcpy (m_state.context.fpu.avx.__fpu_stmm3.__mmst_reg, &value->value.uint8, 10); success = true; break; + case fpu_stmm4: memcpy (m_state.context.fpu.avx.__fpu_stmm4.__mmst_reg, &value->value.uint8, 10); success = true; break; + case fpu_stmm5: memcpy (m_state.context.fpu.avx.__fpu_stmm5.__mmst_reg, &value->value.uint8, 10); success = true; break; + case fpu_stmm6: memcpy (m_state.context.fpu.avx.__fpu_stmm6.__mmst_reg, &value->value.uint8, 10); success = true; break; + case fpu_stmm7: memcpy (m_state.context.fpu.avx.__fpu_stmm7.__mmst_reg, &value->value.uint8, 10); success = true; break; + + case fpu_xmm0: memcpy(m_state.context.fpu.avx.__fpu_xmm0.__xmm_reg, &value->value.uint8, 16); success = true; break; + case fpu_xmm1: memcpy(m_state.context.fpu.avx.__fpu_xmm1.__xmm_reg, &value->value.uint8, 16); success = true; break; + case fpu_xmm2: memcpy(m_state.context.fpu.avx.__fpu_xmm2.__xmm_reg, &value->value.uint8, 16); success = true; break; + case fpu_xmm3: memcpy(m_state.context.fpu.avx.__fpu_xmm3.__xmm_reg, &value->value.uint8, 16); success = true; break; + case fpu_xmm4: memcpy(m_state.context.fpu.avx.__fpu_xmm4.__xmm_reg, &value->value.uint8, 16); success = true; break; + case fpu_xmm5: memcpy(m_state.context.fpu.avx.__fpu_xmm5.__xmm_reg, &value->value.uint8, 16); success = true; break; + case fpu_xmm6: memcpy(m_state.context.fpu.avx.__fpu_xmm6.__xmm_reg, &value->value.uint8, 16); success = true; break; + case fpu_xmm7: memcpy(m_state.context.fpu.avx.__fpu_xmm7.__xmm_reg, &value->value.uint8, 16); success = true; break; + +#define MEMCPY_YMM(n) \ + memcpy(m_state.context.fpu.avx.__fpu_xmm##n.__xmm_reg, &value->value.uint8, 16); \ + memcpy(m_state.context.fpu.avx.__fpu_ymmh##n.__xmm_reg, (&value->value.uint8) + 16, 16); + case fpu_ymm0: MEMCPY_YMM(0); return true; + case fpu_ymm1: MEMCPY_YMM(1); return true; + case fpu_ymm2: MEMCPY_YMM(2); return true; + case fpu_ymm3: MEMCPY_YMM(3); return true; + case fpu_ymm4: MEMCPY_YMM(4); return true; + case fpu_ymm5: MEMCPY_YMM(5); return true; + case fpu_ymm6: MEMCPY_YMM(6); return true; + case fpu_ymm7: MEMCPY_YMM(7); return true; +#undef MEMCPY_YMM + } + } + else + { + switch (reg) + { + case fpu_fcw: *((uint16_t *)(&m_state.context.fpu.no_avx.__fpu_fcw)) = value->value.uint16; success = true; break; + case fpu_fsw: *((uint16_t *)(&m_state.context.fpu.no_avx.__fpu_fsw)) = value->value.uint16; success = true; break; + case fpu_ftw: m_state.context.fpu.no_avx.__fpu_ftw = value->value.uint8; success = true; break; + case fpu_fop: m_state.context.fpu.no_avx.__fpu_fop = value->value.uint16; success = true; break; + case fpu_ip: m_state.context.fpu.no_avx.__fpu_ip = value->value.uint32; success = true; break; + case fpu_cs: m_state.context.fpu.no_avx.__fpu_cs = value->value.uint16; success = true; break; + case fpu_dp: m_state.context.fpu.no_avx.__fpu_dp = value->value.uint32; success = true; break; + case fpu_ds: m_state.context.fpu.no_avx.__fpu_ds = value->value.uint16; success = true; break; + case fpu_mxcsr: m_state.context.fpu.no_avx.__fpu_mxcsr = value->value.uint32; success = true; break; + case fpu_mxcsrmask: m_state.context.fpu.no_avx.__fpu_mxcsrmask = value->value.uint32; success = true; break; + + case fpu_stmm0: memcpy (m_state.context.fpu.no_avx.__fpu_stmm0.__mmst_reg, &value->value.uint8, 10); success = true; break; + case fpu_stmm1: memcpy (m_state.context.fpu.no_avx.__fpu_stmm1.__mmst_reg, &value->value.uint8, 10); success = true; break; + case fpu_stmm2: memcpy (m_state.context.fpu.no_avx.__fpu_stmm2.__mmst_reg, &value->value.uint8, 10); success = true; break; + case fpu_stmm3: memcpy (m_state.context.fpu.no_avx.__fpu_stmm3.__mmst_reg, &value->value.uint8, 10); success = true; break; + case fpu_stmm4: memcpy (m_state.context.fpu.no_avx.__fpu_stmm4.__mmst_reg, &value->value.uint8, 10); success = true; break; + case fpu_stmm5: memcpy (m_state.context.fpu.no_avx.__fpu_stmm5.__mmst_reg, &value->value.uint8, 10); success = true; break; + case fpu_stmm6: memcpy (m_state.context.fpu.no_avx.__fpu_stmm6.__mmst_reg, &value->value.uint8, 10); success = true; break; + case fpu_stmm7: memcpy (m_state.context.fpu.no_avx.__fpu_stmm7.__mmst_reg, &value->value.uint8, 10); success = true; break; + + case fpu_xmm0: memcpy(m_state.context.fpu.no_avx.__fpu_xmm0.__xmm_reg, &value->value.uint8, 16); success = true; break; + case fpu_xmm1: memcpy(m_state.context.fpu.no_avx.__fpu_xmm1.__xmm_reg, &value->value.uint8, 16); success = true; break; + case fpu_xmm2: memcpy(m_state.context.fpu.no_avx.__fpu_xmm2.__xmm_reg, &value->value.uint8, 16); success = true; break; + case fpu_xmm3: memcpy(m_state.context.fpu.no_avx.__fpu_xmm3.__xmm_reg, &value->value.uint8, 16); success = true; break; + case fpu_xmm4: memcpy(m_state.context.fpu.no_avx.__fpu_xmm4.__xmm_reg, &value->value.uint8, 16); success = true; break; + case fpu_xmm5: memcpy(m_state.context.fpu.no_avx.__fpu_xmm5.__xmm_reg, &value->value.uint8, 16); success = true; break; + case fpu_xmm6: memcpy(m_state.context.fpu.no_avx.__fpu_xmm6.__xmm_reg, &value->value.uint8, 16); success = true; break; + case fpu_xmm7: memcpy(m_state.context.fpu.no_avx.__fpu_xmm7.__xmm_reg, &value->value.uint8, 16); success = true; break; + } } break; @@ -886,6 +1213,4 @@ return m_state.RegsAreValid(set); } - - #endif // #if defined (__i386__) Modified: lldb/trunk/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.h?rev=128111&r1=128110&r2=128111&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.h (original) +++ lldb/trunk/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.h Tue Mar 22 16:45:30 2011 @@ -17,9 +17,7 @@ #if defined (__i386__) || defined (__x86_64__) #include "DNBArch.h" -#include -#include - +#include "MachRegisterStatesI386.h" class MachThread; @@ -55,18 +53,23 @@ protected: kern_return_t EnableHardwareSingleStep (bool enable); - typedef i386_thread_state_t GPR; - typedef i386_float_state_t FPU; - typedef i386_exception_state_t EXC; + typedef __i386_thread_state_t GPR; + typedef __i386_float_state_t FPU; + typedef __i386_exception_state_t EXC; + typedef __i386_avx_state_t AVX; static const DNBRegisterInfo g_gpr_registers[]; - static const DNBRegisterInfo g_fpu_registers[]; + static const DNBRegisterInfo g_fpu_registers_no_avx[]; + static const DNBRegisterInfo g_fpu_registers_avx[]; static const DNBRegisterInfo g_exc_registers[]; - static const DNBRegisterSetInfo g_reg_sets[]; + static const DNBRegisterSetInfo g_reg_sets_no_avx[]; + static const DNBRegisterSetInfo g_reg_sets_avx[]; static const size_t k_num_gpr_registers; - static const size_t k_num_fpu_registers; + static const size_t k_num_fpu_registers_no_avx; + static const size_t k_num_fpu_registers_avx; static const size_t k_num_exc_registers; - static const size_t k_num_all_registers; + static const size_t k_num_all_registers_no_avx; + static const size_t k_num_all_registers_avx; static const size_t k_num_register_sets; typedef enum RegisterSetTag @@ -80,9 +83,10 @@ typedef enum RegisterSetWordSizeTag { - e_regSetWordSizeGPR = i386_THREAD_STATE_COUNT, - e_regSetWordSizeFPR = i386_FLOAT_STATE_COUNT, - e_regSetWordSizeEXC = i386_EXCEPTION_STATE_COUNT + e_regSetWordSizeGPR = sizeof(GPR) / sizeof(int), + e_regSetWordSizeFPR = sizeof(FPU) / sizeof(int), + e_regSetWordSizeEXC = sizeof(EXC) / sizeof(int), + e_regSetWordSizeAVX = sizeof(AVX) / sizeof(int) } RegisterSetWordSize; enum @@ -94,9 +98,12 @@ struct Context { - i386_thread_state_t gpr; - i386_float_state_t fpu; - i386_exception_state_t exc; + __i386_thread_state_t gpr; + union { + __i386_float_state_t no_avx; + __i386_avx_state_t avx; + } fpu; + __i386_exception_state_t exc; }; struct State @@ -105,7 +112,7 @@ kern_return_t gpr_errs[2]; // Read/Write errors kern_return_t fpu_errs[2]; // Read/Write errors kern_return_t exc_errs[2]; // Read/Write errors - + State() { uint32_t i; @@ -190,9 +197,24 @@ static const DNBRegisterSetInfo * GetRegisterSetInfo(nub_size_t *num_reg_sets); + + static bool + HasAVX() + { + if (s_has_avx == kAVXUnknown) + s_has_avx = kAVXNotPresent; + + return (s_has_avx == kAVXPresent); + } MachThread *m_thread; - State m_state; + State m_state; + + static enum AVXPresence { + kAVXPresent, + kAVXNotPresent, + kAVXUnknown + } s_has_avx; }; #endif // #if defined (__i386__) || defined (__x86_64__) Added: lldb/trunk/tools/debugserver/source/MacOSX/i386/MachRegisterStatesI386.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/i386/MachRegisterStatesI386.h?rev=128111&view=auto ============================================================================== --- lldb/trunk/tools/debugserver/source/MacOSX/i386/MachRegisterStatesI386.h (added) +++ lldb/trunk/tools/debugserver/source/MacOSX/i386/MachRegisterStatesI386.h Tue Mar 22 16:45:30 2011 @@ -0,0 +1,168 @@ +//===-- MachRegisterStatesI386.h --------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// Created by Sean Callanan on 3/16/11. +// +//===----------------------------------------------------------------------===// + +#ifndef __MachRegisterStatesI386_h__ +#define __MachRegisterStatesI386_h__ + +#include + +#define __i386_THREAD_STATE 1 +#define __i386_FLOAT_STATE 2 +#define __i386_EXCEPTION_STATE 3 +#define __i386_AVX_STATE 16 + +typedef struct { + uint32_t __eax; + uint32_t __ebx; + uint32_t __ecx; + uint32_t __edx; + uint32_t __edi; + uint32_t __esi; + uint32_t __ebp; + uint32_t __esp; + uint32_t __ss; + uint32_t __eflags; + uint32_t __eip; + uint32_t __cs; + uint32_t __ds; + uint32_t __es; + uint32_t __fs; + uint32_t __gs; +} __i386_thread_state_t; + +typedef struct { + uint16_t __invalid : 1; + uint16_t __denorm : 1; + uint16_t __zdiv : 1; + uint16_t __ovrfl : 1; + uint16_t __undfl : 1; + uint16_t __precis : 1; + uint16_t __PAD1 : 2; + uint16_t __pc : 2; + uint16_t __rc : 2; + uint16_t __PAD2 : 1; + uint16_t __PAD3 : 3; +} __i386_fp_control_t; + +typedef struct { + uint16_t __invalid : 1; + uint16_t __denorm : 1; + uint16_t __zdiv : 1; + uint16_t __ovrfl : 1; + uint16_t __undfl : 1; + uint16_t __precis : 1; + uint16_t __stkflt : 1; + uint16_t __errsumm : 1; + uint16_t __c0 : 1; + uint16_t __c1 : 1; + uint16_t __c2 : 1; + uint16_t __tos : 3; + uint16_t __c3 : 1; + uint16_t __busy : 1; +} __i386_fp_status_t; + +typedef struct { + uint8_t __mmst_reg[10]; + uint8_t __mmst_rsrv[6]; +} __i386_mmst_reg; + +typedef struct { + uint8_t __xmm_reg[16]; +} __i386_xmm_reg; + +typedef struct { + uint32_t __fpu_reserved[2]; + __i386_fp_control_t __fpu_fcw; + __i386_fp_status_t __fpu_fsw; + uint8_t __fpu_ftw; + uint8_t __fpu_rsrv1; + uint16_t __fpu_fop; + uint32_t __fpu_ip; + uint16_t __fpu_cs; + uint16_t __fpu_rsrv2; + uint32_t __fpu_dp; + uint16_t __fpu_ds; + uint16_t __fpu_rsrv3; + uint32_t __fpu_mxcsr; + uint32_t __fpu_mxcsrmask; + __i386_mmst_reg __fpu_stmm0; + __i386_mmst_reg __fpu_stmm1; + __i386_mmst_reg __fpu_stmm2; + __i386_mmst_reg __fpu_stmm3; + __i386_mmst_reg __fpu_stmm4; + __i386_mmst_reg __fpu_stmm5; + __i386_mmst_reg __fpu_stmm6; + __i386_mmst_reg __fpu_stmm7; + __i386_xmm_reg __fpu_xmm0; + __i386_xmm_reg __fpu_xmm1; + __i386_xmm_reg __fpu_xmm2; + __i386_xmm_reg __fpu_xmm3; + __i386_xmm_reg __fpu_xmm4; + __i386_xmm_reg __fpu_xmm5; + __i386_xmm_reg __fpu_xmm6; + __i386_xmm_reg __fpu_xmm7; + uint8_t __fpu_rsrv4[14*16]; + uint32_t __fpu_reserved1; +} __i386_float_state_t; + +typedef struct { + uint32_t __fpu_reserved[2]; + __i386_fp_control_t __fpu_fcw; + __i386_fp_status_t __fpu_fsw; + uint8_t __fpu_ftw; + uint8_t __fpu_rsrv1; + uint16_t __fpu_fop; + uint32_t __fpu_ip; + uint16_t __fpu_cs; + uint16_t __fpu_rsrv2; + uint32_t __fpu_dp; + uint16_t __fpu_ds; + uint16_t __fpu_rsrv3; + uint32_t __fpu_mxcsr; + uint32_t __fpu_mxcsrmask; + __i386_mmst_reg __fpu_stmm0; + __i386_mmst_reg __fpu_stmm1; + __i386_mmst_reg __fpu_stmm2; + __i386_mmst_reg __fpu_stmm3; + __i386_mmst_reg __fpu_stmm4; + __i386_mmst_reg __fpu_stmm5; + __i386_mmst_reg __fpu_stmm6; + __i386_mmst_reg __fpu_stmm7; + __i386_xmm_reg __fpu_xmm0; + __i386_xmm_reg __fpu_xmm1; + __i386_xmm_reg __fpu_xmm2; + __i386_xmm_reg __fpu_xmm3; + __i386_xmm_reg __fpu_xmm4; + __i386_xmm_reg __fpu_xmm5; + __i386_xmm_reg __fpu_xmm6; + __i386_xmm_reg __fpu_xmm7; + uint8_t __fpu_rsrv4[14*16]; + uint32_t __fpu_reserved1; + uint8_t __avx_reserved1[64]; + __i386_xmm_reg __fpu_ymmh0; + __i386_xmm_reg __fpu_ymmh1; + __i386_xmm_reg __fpu_ymmh2; + __i386_xmm_reg __fpu_ymmh3; + __i386_xmm_reg __fpu_ymmh4; + __i386_xmm_reg __fpu_ymmh5; + __i386_xmm_reg __fpu_ymmh6; + __i386_xmm_reg __fpu_ymmh7; +} __i386_avx_state_t; + +typedef struct { + uint32_t __trapno; + uint32_t __err; + uint32_t __faultvaddr; +} __i386_exception_state_t; + +#endif Modified: lldb/trunk/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp?rev=128111&r1=128110&r2=128111&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp (original) +++ lldb/trunk/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp Tue Mar 22 16:45:30 2011 @@ -20,6 +20,52 @@ #include "MachThread.h" #include "MachProcess.h" #include +#include + +#if defined (LLDB_DEBUGSERVER_RELEASE) || defined (LLDB_DEBUGSERVER_DEBUG) +enum debugState { + debugStateUnknown, + debugStateOff, + debugStateOn +}; + +static debugState sFPUDebugState = debugStateUnknown; +static debugState sAVXForceState = debugStateUnknown; + +static bool DebugFPURegs () +{ + if (sFPUDebugState == debugStateUnknown) + { + if (getenv("DNB_DEBUG_FPU_REGS")) + sFPUDebugState = debugStateOn; + else + sFPUDebugState = debugStateOff; + } + + return (sFPUDebugState == debugStateOn); +} + +static bool ForceAVXRegs () +{ + if (sFPUDebugState == debugStateUnknown) + { + if (getenv("DNB_DEBUG_X86_FORCE_AVX_REGS")) + sAVXForceState = debugStateOn; + else + sAVXForceState = debugStateOff; + } + + return (sAVXForceState == debugStateOn); +} + +#define DEBUG_FPU_REGS (DebugFPURegs()) +#define FORCE_AVX_REGS (ForceAVXRegs()) +#else +#define DEBUG_FPU_REGS (0) +#define FORCE_AVX_REGS (0) +#endif + +enum DNBArchImplX86_64::AVXPresence DNBArchImplX86_64::s_has_avx = DNBArchImplX86_64::kAVXUnknown; uint64_t DNBArchImplX86_64::GetPC(uint64_t failValue) @@ -87,8 +133,8 @@ m_state.context.gpr.__gs = ('g' << 8) + 's'; m_state.SetError(e_regSetGPR, Read, 0); #else - mach_msg_type_number_t count = x86_THREAD_STATE64_COUNT; - m_state.SetError(e_regSetGPR, Read, ::thread_get_state(m_thread->ThreadID(), x86_THREAD_STATE64, (thread_state_t)&m_state.context.gpr, &count)); + mach_msg_type_number_t count = e_regSetWordSizeGPR; + m_state.SetError(e_regSetGPR, Read, ::thread_get_state(m_thread->ThreadID(), __x86_64_THREAD_STATE, (thread_state_t)&m_state.context.gpr, &count)); DNBLogThreadedIf (LOG_THREAD, "::thread_get_state (0x%4.4x, %u, &gpr, %u) => 0x%8.8x" "\n\trax = %16.16llx rbx = %16.16llx rcx = %16.16llx rdx = %16.16llx" "\n\trdi = %16.16llx rsi = %16.16llx rbp = %16.16llx rsp = %16.16llx" @@ -159,80 +205,177 @@ } // Uncomment the value below to verify the values in the debugger. -//#define DEBUG_FPU_VALUES 1 // DO NOT CHECK IN WITH THIS DEFINE ENABLED +//#define DEBUG_FPU_REGS 1 // DO NOT CHECK IN WITH THIS DEFINE ENABLED kern_return_t DNBArchImplX86_64::GetFPUState(bool force) { if (force || m_state.GetError(e_regSetFPU, Read)) { -#if DEBUG_FPU_VALUES - m_state.context.fpu.__fpu_reserved[0] = -1; - m_state.context.fpu.__fpu_reserved[1] = -1; - *(uint16_t *)&(m_state.context.fpu.__fpu_fcw) = 0x1234; - *(uint16_t *)&(m_state.context.fpu.__fpu_fsw) = 0x5678; - m_state.context.fpu.__fpu_ftw = 1; - m_state.context.fpu.__fpu_rsrv1 = UINT8_MAX; - m_state.context.fpu.__fpu_fop = 2; - m_state.context.fpu.__fpu_ip = 3; - m_state.context.fpu.__fpu_cs = 4; - m_state.context.fpu.__fpu_rsrv2 = 5; - m_state.context.fpu.__fpu_dp = 6; - m_state.context.fpu.__fpu_ds = 7; - m_state.context.fpu.__fpu_rsrv3 = UINT16_MAX; - m_state.context.fpu.__fpu_mxcsr = 8; - m_state.context.fpu.__fpu_mxcsrmask = 9; - int i; - for (i=0; i<16; ++i) - { - if (i<10) + if (DEBUG_FPU_REGS) { + if (HasAVX() || FORCE_AVX_REGS) { - m_state.context.fpu.__fpu_stmm0.__mmst_reg[i] = 'a'; - m_state.context.fpu.__fpu_stmm1.__mmst_reg[i] = 'b'; - m_state.context.fpu.__fpu_stmm2.__mmst_reg[i] = 'c'; - m_state.context.fpu.__fpu_stmm3.__mmst_reg[i] = 'd'; - m_state.context.fpu.__fpu_stmm4.__mmst_reg[i] = 'e'; - m_state.context.fpu.__fpu_stmm5.__mmst_reg[i] = 'f'; - m_state.context.fpu.__fpu_stmm6.__mmst_reg[i] = 'g'; - m_state.context.fpu.__fpu_stmm7.__mmst_reg[i] = 'h'; + m_state.context.fpu.avx.__fpu_reserved[0] = -1; + m_state.context.fpu.avx.__fpu_reserved[1] = -1; + *(uint16_t *)&(m_state.context.fpu.avx.__fpu_fcw) = 0x1234; + *(uint16_t *)&(m_state.context.fpu.avx.__fpu_fsw) = 0x5678; + m_state.context.fpu.avx.__fpu_ftw = 1; + m_state.context.fpu.avx.__fpu_rsrv1 = UINT8_MAX; + m_state.context.fpu.avx.__fpu_fop = 2; + m_state.context.fpu.avx.__fpu_ip = 3; + m_state.context.fpu.avx.__fpu_cs = 4; + m_state.context.fpu.avx.__fpu_rsrv2 = 5; + m_state.context.fpu.avx.__fpu_dp = 6; + m_state.context.fpu.avx.__fpu_ds = 7; + m_state.context.fpu.avx.__fpu_rsrv3 = UINT16_MAX; + m_state.context.fpu.avx.__fpu_mxcsr = 8; + m_state.context.fpu.avx.__fpu_mxcsrmask = 9; + int i; + for (i=0; i<16; ++i) + { + if (i<10) + { + m_state.context.fpu.avx.__fpu_stmm0.__mmst_reg[i] = 'a'; + m_state.context.fpu.avx.__fpu_stmm1.__mmst_reg[i] = 'b'; + m_state.context.fpu.avx.__fpu_stmm2.__mmst_reg[i] = 'c'; + m_state.context.fpu.avx.__fpu_stmm3.__mmst_reg[i] = 'd'; + m_state.context.fpu.avx.__fpu_stmm4.__mmst_reg[i] = 'e'; + m_state.context.fpu.avx.__fpu_stmm5.__mmst_reg[i] = 'f'; + m_state.context.fpu.avx.__fpu_stmm6.__mmst_reg[i] = 'g'; + m_state.context.fpu.avx.__fpu_stmm7.__mmst_reg[i] = 'h'; + } + else + { + m_state.context.fpu.avx.__fpu_stmm0.__mmst_reg[i] = INT8_MIN; + m_state.context.fpu.avx.__fpu_stmm1.__mmst_reg[i] = INT8_MIN; + m_state.context.fpu.avx.__fpu_stmm2.__mmst_reg[i] = INT8_MIN; + m_state.context.fpu.avx.__fpu_stmm3.__mmst_reg[i] = INT8_MIN; + m_state.context.fpu.avx.__fpu_stmm4.__mmst_reg[i] = INT8_MIN; + m_state.context.fpu.avx.__fpu_stmm5.__mmst_reg[i] = INT8_MIN; + m_state.context.fpu.avx.__fpu_stmm6.__mmst_reg[i] = INT8_MIN; + m_state.context.fpu.avx.__fpu_stmm7.__mmst_reg[i] = INT8_MIN; + } + + m_state.context.fpu.avx.__fpu_xmm0.__xmm_reg[i] = '0'; + m_state.context.fpu.avx.__fpu_xmm1.__xmm_reg[i] = '1'; + m_state.context.fpu.avx.__fpu_xmm2.__xmm_reg[i] = '2'; + m_state.context.fpu.avx.__fpu_xmm3.__xmm_reg[i] = '3'; + m_state.context.fpu.avx.__fpu_xmm4.__xmm_reg[i] = '4'; + m_state.context.fpu.avx.__fpu_xmm5.__xmm_reg[i] = '5'; + m_state.context.fpu.avx.__fpu_xmm6.__xmm_reg[i] = '6'; + m_state.context.fpu.avx.__fpu_xmm7.__xmm_reg[i] = '7'; + m_state.context.fpu.avx.__fpu_xmm8.__xmm_reg[i] = '8'; + m_state.context.fpu.avx.__fpu_xmm9.__xmm_reg[i] = '9'; + m_state.context.fpu.avx.__fpu_xmm10.__xmm_reg[i] = 'A'; + m_state.context.fpu.avx.__fpu_xmm11.__xmm_reg[i] = 'B'; + m_state.context.fpu.avx.__fpu_xmm12.__xmm_reg[i] = 'C'; + m_state.context.fpu.avx.__fpu_xmm13.__xmm_reg[i] = 'D'; + m_state.context.fpu.avx.__fpu_xmm14.__xmm_reg[i] = 'E'; + m_state.context.fpu.avx.__fpu_xmm15.__xmm_reg[i] = 'F'; + + m_state.context.fpu.avx.__fpu_ymmh0.__xmm_reg[i] = '0'; + m_state.context.fpu.avx.__fpu_ymmh1.__xmm_reg[i] = '1'; + m_state.context.fpu.avx.__fpu_ymmh2.__xmm_reg[i] = '2'; + m_state.context.fpu.avx.__fpu_ymmh3.__xmm_reg[i] = '3'; + m_state.context.fpu.avx.__fpu_ymmh4.__xmm_reg[i] = '4'; + m_state.context.fpu.avx.__fpu_ymmh5.__xmm_reg[i] = '5'; + m_state.context.fpu.avx.__fpu_ymmh6.__xmm_reg[i] = '6'; + m_state.context.fpu.avx.__fpu_ymmh7.__xmm_reg[i] = '7'; + m_state.context.fpu.avx.__fpu_ymmh8.__xmm_reg[i] = '8'; + m_state.context.fpu.avx.__fpu_ymmh9.__xmm_reg[i] = '9'; + m_state.context.fpu.avx.__fpu_ymmh10.__xmm_reg[i] = 'A'; + m_state.context.fpu.avx.__fpu_ymmh11.__xmm_reg[i] = 'B'; + m_state.context.fpu.avx.__fpu_ymmh12.__xmm_reg[i] = 'C'; + m_state.context.fpu.avx.__fpu_ymmh13.__xmm_reg[i] = 'D'; + m_state.context.fpu.avx.__fpu_ymmh14.__xmm_reg[i] = 'E'; + m_state.context.fpu.avx.__fpu_ymmh15.__xmm_reg[i] = 'F'; + } + for (i=0; iThreadID(), x86_FLOAT_STATE64, (thread_state_t)&m_state.context.fpu, &count)); -#endif + else + { + if (HasAVX() || FORCE_AVX_REGS) + { + mach_msg_type_number_t count = e_regSetWordSizeAVX; + m_state.SetError(e_regSetFPU, Read, ::thread_get_state(m_thread->ThreadID(), __x86_64_AVX_STATE, (thread_state_t)&m_state.context.fpu.avx, &count)); + } + else + { + mach_msg_type_number_t count = e_regSetWordSizeFPR; + m_state.SetError(e_regSetFPU, Read, ::thread_get_state(m_thread->ThreadID(), __x86_64_FLOAT_STATE, (thread_state_t)&m_state.context.fpu.no_avx, &count)); + } + } } return m_state.GetError(e_regSetFPU, Read); } @@ -242,8 +385,8 @@ { if (force || m_state.GetError(e_regSetEXC, Read)) { - mach_msg_type_number_t count = X86_EXCEPTION_STATE64_COUNT; - m_state.SetError(e_regSetEXC, Read, ::thread_get_state(m_thread->ThreadID(), x86_EXCEPTION_STATE64, (thread_state_t)&m_state.context.exc, &count)); + mach_msg_type_number_t count = e_regSetWordSizeEXC; + m_state.SetError(e_regSetEXC, Read, ::thread_get_state(m_thread->ThreadID(), __x86_64_EXCEPTION_STATE, (thread_state_t)&m_state.context.exc, &count)); } return m_state.GetError(e_regSetEXC, Read); } @@ -254,7 +397,7 @@ kern_return_t kret = ::thread_abort_safely(m_thread->ThreadID()); DNBLogThreaded("thread = 0x%4.4x calling thread_abort_safely (tid) => %u (SetGPRState() for stop_count = %u)", m_thread->ThreadID(), kret, m_thread->Process()->StopCount()); - m_state.SetError(e_regSetGPR, Write, ::thread_set_state(m_thread->ThreadID(), x86_THREAD_STATE64, (thread_state_t)&m_state.context.gpr, x86_THREAD_STATE64_COUNT)); + m_state.SetError(e_regSetGPR, Write, ::thread_set_state(m_thread->ThreadID(), __x86_64_THREAD_STATE, (thread_state_t)&m_state.context.gpr, e_regSetWordSizeGPR)); DNBLogThreadedIf (LOG_THREAD, "::thread_set_state (0x%4.4x, %u, &gpr, %u) => 0x%8.8x" "\n\trax = %16.16llx rbx = %16.16llx rcx = %16.16llx rdx = %16.16llx" "\n\trdi = %16.16llx rsi = %16.16llx rbp = %16.16llx rsp = %16.16llx" @@ -262,7 +405,7 @@ "\n\tr12 = %16.16llx r13 = %16.16llx r14 = %16.16llx r15 = %16.16llx" "\n\trip = %16.16llx" "\n\tflg = %16.16llx cs = %16.16llx fs = %16.16llx gs = %16.16llx", - m_thread->ThreadID(), x86_THREAD_STATE64, x86_THREAD_STATE64_COUNT, + m_thread->ThreadID(), __x86_64_THREAD_STATE, e_regSetWordSizeGPR, m_state.GetError(e_regSetGPR, Write), m_state.context.gpr.__rax,m_state.context.gpr.__rbx,m_state.context.gpr.__rcx, m_state.context.gpr.__rdx,m_state.context.gpr.__rdi,m_state.context.gpr.__rsi, @@ -277,14 +420,30 @@ kern_return_t DNBArchImplX86_64::SetFPUState() { - m_state.SetError(e_regSetFPU, Write, ::thread_set_state(m_thread->ThreadID(), x86_FLOAT_STATE64, (thread_state_t)&m_state.context.fpu, x86_FLOAT_STATE64_COUNT)); - return m_state.GetError(e_regSetFPU, Write); + if (DEBUG_FPU_REGS) + { + m_state.SetError(e_regSetFPU, Write, 0); + return m_state.GetError(e_regSetFPU, Write); + } + else + { + if (HasAVX() || FORCE_AVX_REGS) + { + m_state.SetError(e_regSetFPU, Write, ::thread_set_state(m_thread->ThreadID(), __x86_64_AVX_STATE, (thread_state_t)&m_state.context.fpu.avx, e_regSetWordSizeAVX)); + return m_state.GetError(e_regSetFPU, Write); + } + else + { + m_state.SetError(e_regSetFPU, Write, ::thread_set_state(m_thread->ThreadID(), __x86_64_FLOAT_STATE, (thread_state_t)&m_state.context.fpu.no_avx, e_regSetWordSizeFPR)); + return m_state.GetError(e_regSetFPU, Write); + } + } } kern_return_t DNBArchImplX86_64::SetEXCState() { - m_state.SetError(e_regSetEXC, Write, ::thread_set_state(m_thread->ThreadID(), x86_EXCEPTION_STATE64, (thread_state_t)&m_state.context.exc, X86_EXCEPTION_STATE64_COUNT)); + m_state.SetError(e_regSetEXC, Write, ::thread_set_state(m_thread->ThreadID(), __x86_64_EXCEPTION_STATE, (thread_state_t)&m_state.context.exc, e_regSetWordSizeEXC)); return m_state.GetError(e_regSetEXC, Write); } @@ -460,6 +619,22 @@ fpu_xmm13, fpu_xmm14, fpu_xmm15, + fpu_ymm0, + fpu_ymm1, + fpu_ymm2, + fpu_ymm3, + fpu_ymm4, + fpu_ymm5, + fpu_ymm6, + fpu_ymm7, + fpu_ymm8, + fpu_ymm9, + fpu_ymm10, + fpu_ymm11, + fpu_ymm12, + fpu_ymm13, + fpu_ymm14, + fpu_ymm15, k_num_fpu_regs, // Aliases @@ -523,7 +698,22 @@ gcc_dwarf_stmm5, gcc_dwarf_stmm6, gcc_dwarf_stmm7, - + gcc_dwarf_ymm0 = gcc_dwarf_xmm0, + gcc_dwarf_ymm1 = gcc_dwarf_xmm1, + gcc_dwarf_ymm2 = gcc_dwarf_xmm2, + gcc_dwarf_ymm3 = gcc_dwarf_xmm3, + gcc_dwarf_ymm4 = gcc_dwarf_xmm4, + gcc_dwarf_ymm5 = gcc_dwarf_xmm5, + gcc_dwarf_ymm6 = gcc_dwarf_xmm6, + gcc_dwarf_ymm7 = gcc_dwarf_xmm7, + gcc_dwarf_ymm8 = gcc_dwarf_xmm8, + gcc_dwarf_ymm9 = gcc_dwarf_xmm9, + gcc_dwarf_ymm10 = gcc_dwarf_xmm10, + gcc_dwarf_ymm11 = gcc_dwarf_xmm11, + gcc_dwarf_ymm12 = gcc_dwarf_xmm12, + gcc_dwarf_ymm13 = gcc_dwarf_xmm13, + gcc_dwarf_ymm14 = gcc_dwarf_xmm14, + gcc_dwarf_ymm15 = gcc_dwarf_xmm15 }; enum gdb_regnums @@ -585,16 +775,41 @@ gdb_xmm14 = 54, gdb_xmm15 = 55, gdb_mxcsr = 56, + gdb_ymm0 = gdb_xmm0, + gdb_ymm1 = gdb_xmm1, + gdb_ymm2 = gdb_xmm2, + gdb_ymm3 = gdb_xmm3, + gdb_ymm4 = gdb_xmm4, + gdb_ymm5 = gdb_xmm5, + gdb_ymm6 = gdb_xmm6, + gdb_ymm7 = gdb_xmm7, + gdb_ymm8 = gdb_xmm8, + gdb_ymm9 = gdb_xmm9, + gdb_ymm10 = gdb_xmm10, + gdb_ymm11 = gdb_xmm11, + gdb_ymm12 = gdb_xmm12, + gdb_ymm13 = gdb_xmm13, + gdb_ymm14 = gdb_xmm14, + gdb_ymm15 = gdb_xmm15 }; #define GPR_OFFSET(reg) (offsetof (DNBArchImplX86_64::GPR, __##reg)) -#define FPU_OFFSET(reg) (offsetof (DNBArchImplX86_64::FPU, __fpu_##reg) + offsetof (DNBArchImplX86_64::Context, fpu)) +#define FPU_OFFSET(reg) (offsetof (DNBArchImplX86_64::FPU, __fpu_##reg) + offsetof (DNBArchImplX86_64::Context, fpu.no_avx)) +#define AVX_OFFSET(reg) (offsetof (DNBArchImplX86_64::AVX, __fpu_##reg) + offsetof (DNBArchImplX86_64::Context, fpu.avx)) #define EXC_OFFSET(reg) (offsetof (DNBArchImplX86_64::EXC, __##reg) + offsetof (DNBArchImplX86_64::Context, exc)) +// This does not accurately identify the location of ymm0...7 in +// Context.fpu.avx. That is because there is a bunch of padding +// in Context.fpu.avx that we don't need. Offset macros lay out +// the register state that Debugserver transmits to the debugger +// -- not to interpret the thread_get_state info. +#define AVX_OFFSET_YMM(n) (AVX_OFFSET(xmm7) + FPU_SIZE_XMM(xmm7) + (32 * n)) + #define GPR_SIZE(reg) (sizeof(((DNBArchImplX86_64::GPR *)NULL)->__##reg)) #define FPU_SIZE_UINT(reg) (sizeof(((DNBArchImplX86_64::FPU *)NULL)->__fpu_##reg)) #define FPU_SIZE_MMST(reg) (sizeof(((DNBArchImplX86_64::FPU *)NULL)->__fpu_##reg.__mmst_reg)) #define FPU_SIZE_XMM(reg) (sizeof(((DNBArchImplX86_64::FPU *)NULL)->__fpu_##reg.__xmm_reg)) +#define FPU_SIZE_YMM(reg) (32) #define EXC_SIZE(reg) (sizeof(((DNBArchImplX86_64::EXC *)NULL)->__##reg)) // These macros will auto define the register name, alt name, register size, @@ -634,7 +849,7 @@ // Floating point registers 64 bit const DNBRegisterInfo -DNBArchImplX86_64::g_fpu_registers[] = +DNBArchImplX86_64::g_fpu_registers_no_avx[] = { { e_regSetFPU, fpu_fcw , "fctrl" , NULL, Uint, Hex, FPU_SIZE_UINT(fcw) , FPU_OFFSET(fcw) , -1, -1, -1, -1 }, { e_regSetFPU, fpu_fsw , "fstat" , NULL, Uint, Hex, FPU_SIZE_UINT(fsw) , FPU_OFFSET(fsw) , -1, -1, -1, -1 }, @@ -674,6 +889,64 @@ { e_regSetFPU, fpu_xmm15, "xmm15" , NULL, Vector, VectorOfUInt8, FPU_SIZE_XMM(xmm15) , FPU_OFFSET(xmm15), gcc_dwarf_xmm15, gcc_dwarf_xmm15, -1, gdb_xmm15 }, }; +const DNBRegisterInfo +DNBArchImplX86_64::g_fpu_registers_avx[] = +{ + { e_regSetFPU, fpu_fcw , "fctrl" , NULL, Uint, Hex, FPU_SIZE_UINT(fcw) , AVX_OFFSET(fcw) , -1, -1, -1, -1 }, + { e_regSetFPU, fpu_fsw , "fstat" , NULL, Uint, Hex, FPU_SIZE_UINT(fsw) , AVX_OFFSET(fsw) , -1, -1, -1, -1 }, + { e_regSetFPU, fpu_ftw , "ftag" , NULL, Uint, Hex, FPU_SIZE_UINT(ftw) , AVX_OFFSET(ftw) , -1, -1, -1, -1 }, + { e_regSetFPU, fpu_fop , "fop" , NULL, Uint, Hex, FPU_SIZE_UINT(fop) , AVX_OFFSET(fop) , -1, -1, -1, -1 }, + { e_regSetFPU, fpu_ip , "fioff" , NULL, Uint, Hex, FPU_SIZE_UINT(ip) , AVX_OFFSET(ip) , -1, -1, -1, -1 }, + { e_regSetFPU, fpu_cs , "fiseg" , NULL, Uint, Hex, FPU_SIZE_UINT(cs) , AVX_OFFSET(cs) , -1, -1, -1, -1 }, + { e_regSetFPU, fpu_dp , "fooff" , NULL, Uint, Hex, FPU_SIZE_UINT(dp) , AVX_OFFSET(dp) , -1, -1, -1, -1 }, + { e_regSetFPU, fpu_ds , "foseg" , NULL, Uint, Hex, FPU_SIZE_UINT(ds) , AVX_OFFSET(ds) , -1, -1, -1, -1 }, + { e_regSetFPU, fpu_mxcsr , "mxcsr" , NULL, Uint, Hex, FPU_SIZE_UINT(mxcsr) , AVX_OFFSET(mxcsr) , -1, -1, -1, -1 }, + { e_regSetFPU, fpu_mxcsrmask, "mxcsrmask" , NULL, Uint, Hex, FPU_SIZE_UINT(mxcsrmask) , AVX_OFFSET(mxcsrmask) , -1, -1, -1, -1 }, + + { e_regSetFPU, fpu_stmm0, "stmm0", NULL, Vector, VectorOfUInt8, FPU_SIZE_MMST(stmm0), AVX_OFFSET(stmm0), gcc_dwarf_stmm0, gcc_dwarf_stmm0, -1, gdb_stmm0 }, + { e_regSetFPU, fpu_stmm1, "stmm1", NULL, Vector, VectorOfUInt8, FPU_SIZE_MMST(stmm1), AVX_OFFSET(stmm1), gcc_dwarf_stmm1, gcc_dwarf_stmm1, -1, gdb_stmm1 }, + { e_regSetFPU, fpu_stmm2, "stmm2", NULL, Vector, VectorOfUInt8, FPU_SIZE_MMST(stmm2), AVX_OFFSET(stmm2), gcc_dwarf_stmm2, gcc_dwarf_stmm2, -1, gdb_stmm2 }, + { e_regSetFPU, fpu_stmm3, "stmm3", NULL, Vector, VectorOfUInt8, FPU_SIZE_MMST(stmm3), AVX_OFFSET(stmm3), gcc_dwarf_stmm3, gcc_dwarf_stmm3, -1, gdb_stmm3 }, + { e_regSetFPU, fpu_stmm4, "stmm4", NULL, Vector, VectorOfUInt8, FPU_SIZE_MMST(stmm4), AVX_OFFSET(stmm4), gcc_dwarf_stmm4, gcc_dwarf_stmm4, -1, gdb_stmm4 }, + { e_regSetFPU, fpu_stmm5, "stmm5", NULL, Vector, VectorOfUInt8, FPU_SIZE_MMST(stmm5), AVX_OFFSET(stmm5), gcc_dwarf_stmm5, gcc_dwarf_stmm5, -1, gdb_stmm5 }, + { e_regSetFPU, fpu_stmm6, "stmm6", NULL, Vector, VectorOfUInt8, FPU_SIZE_MMST(stmm6), AVX_OFFSET(stmm6), gcc_dwarf_stmm6, gcc_dwarf_stmm6, -1, gdb_stmm6 }, + { e_regSetFPU, fpu_stmm7, "stmm7", NULL, Vector, VectorOfUInt8, FPU_SIZE_MMST(stmm7), AVX_OFFSET(stmm7), gcc_dwarf_stmm7, gcc_dwarf_stmm7, -1, gdb_stmm7 }, + + { e_regSetFPU, fpu_xmm0 , "xmm0" , NULL, Vector, VectorOfUInt8, FPU_SIZE_XMM(xmm0) , AVX_OFFSET(xmm0) , gcc_dwarf_xmm0 , gcc_dwarf_xmm0 , -1, gdb_xmm0 }, + { e_regSetFPU, fpu_xmm1 , "xmm1" , NULL, Vector, VectorOfUInt8, FPU_SIZE_XMM(xmm1) , AVX_OFFSET(xmm1) , gcc_dwarf_xmm1 , gcc_dwarf_xmm1 , -1, gdb_xmm1 }, + { e_regSetFPU, fpu_xmm2 , "xmm2" , NULL, Vector, VectorOfUInt8, FPU_SIZE_XMM(xmm2) , AVX_OFFSET(xmm2) , gcc_dwarf_xmm2 , gcc_dwarf_xmm2 , -1, gdb_xmm2 }, + { e_regSetFPU, fpu_xmm3 , "xmm3" , NULL, Vector, VectorOfUInt8, FPU_SIZE_XMM(xmm3) , AVX_OFFSET(xmm3) , gcc_dwarf_xmm3 , gcc_dwarf_xmm3 , -1, gdb_xmm3 }, + { e_regSetFPU, fpu_xmm4 , "xmm4" , NULL, Vector, VectorOfUInt8, FPU_SIZE_XMM(xmm4) , AVX_OFFSET(xmm4) , gcc_dwarf_xmm4 , gcc_dwarf_xmm4 , -1, gdb_xmm4 }, + { e_regSetFPU, fpu_xmm5 , "xmm5" , NULL, Vector, VectorOfUInt8, FPU_SIZE_XMM(xmm5) , AVX_OFFSET(xmm5) , gcc_dwarf_xmm5 , gcc_dwarf_xmm5 , -1, gdb_xmm5 }, + { e_regSetFPU, fpu_xmm6 , "xmm6" , NULL, Vector, VectorOfUInt8, FPU_SIZE_XMM(xmm6) , AVX_OFFSET(xmm6) , gcc_dwarf_xmm6 , gcc_dwarf_xmm6 , -1, gdb_xmm6 }, + { e_regSetFPU, fpu_xmm7 , "xmm7" , NULL, Vector, VectorOfUInt8, FPU_SIZE_XMM(xmm7) , AVX_OFFSET(xmm7) , gcc_dwarf_xmm7 , gcc_dwarf_xmm7 , -1, gdb_xmm7 }, + { e_regSetFPU, fpu_xmm8 , "xmm8" , NULL, Vector, VectorOfUInt8, FPU_SIZE_XMM(xmm8) , AVX_OFFSET(xmm8) , gcc_dwarf_xmm8 , gcc_dwarf_xmm8 , -1, gdb_xmm8 }, + { e_regSetFPU, fpu_xmm9 , "xmm9" , NULL, Vector, VectorOfUInt8, FPU_SIZE_XMM(xmm9) , AVX_OFFSET(xmm9) , gcc_dwarf_xmm9 , gcc_dwarf_xmm9 , -1, gdb_xmm9 }, + { e_regSetFPU, fpu_xmm10, "xmm10" , NULL, Vector, VectorOfUInt8, FPU_SIZE_XMM(xmm10) , AVX_OFFSET(xmm10), gcc_dwarf_xmm10, gcc_dwarf_xmm10, -1, gdb_xmm10 }, + { e_regSetFPU, fpu_xmm11, "xmm11" , NULL, Vector, VectorOfUInt8, FPU_SIZE_XMM(xmm11) , AVX_OFFSET(xmm11), gcc_dwarf_xmm11, gcc_dwarf_xmm11, -1, gdb_xmm11 }, + { e_regSetFPU, fpu_xmm12, "xmm12" , NULL, Vector, VectorOfUInt8, FPU_SIZE_XMM(xmm12) , AVX_OFFSET(xmm12), gcc_dwarf_xmm12, gcc_dwarf_xmm12, -1, gdb_xmm12 }, + { e_regSetFPU, fpu_xmm13, "xmm13" , NULL, Vector, VectorOfUInt8, FPU_SIZE_XMM(xmm13) , AVX_OFFSET(xmm13), gcc_dwarf_xmm13, gcc_dwarf_xmm13, -1, gdb_xmm13 }, + { e_regSetFPU, fpu_xmm14, "xmm14" , NULL, Vector, VectorOfUInt8, FPU_SIZE_XMM(xmm14) , AVX_OFFSET(xmm14), gcc_dwarf_xmm14, gcc_dwarf_xmm14, -1, gdb_xmm14 }, + { e_regSetFPU, fpu_xmm15, "xmm15" , NULL, Vector, VectorOfUInt8, FPU_SIZE_XMM(xmm15) , AVX_OFFSET(xmm15), gcc_dwarf_xmm15, gcc_dwarf_xmm15, -1, gdb_xmm15 }, + + { e_regSetFPU, fpu_ymm0 , "ymm0" , NULL, Vector, VectorOfUInt8, FPU_SIZE_YMM(ymm0) , AVX_OFFSET_YMM(0) , gcc_dwarf_ymm0 , gcc_dwarf_ymm0 , -1, gdb_ymm0 }, + { e_regSetFPU, fpu_ymm1 , "ymm1" , NULL, Vector, VectorOfUInt8, FPU_SIZE_YMM(ymm1) , AVX_OFFSET_YMM(1) , gcc_dwarf_ymm1 , gcc_dwarf_ymm1 , -1, gdb_ymm1 }, + { e_regSetFPU, fpu_ymm2 , "ymm2" , NULL, Vector, VectorOfUInt8, FPU_SIZE_YMM(ymm2) , AVX_OFFSET_YMM(2) , gcc_dwarf_ymm2 , gcc_dwarf_ymm2 , -1, gdb_ymm2 }, + { e_regSetFPU, fpu_ymm3 , "ymm3" , NULL, Vector, VectorOfUInt8, FPU_SIZE_YMM(ymm3) , AVX_OFFSET_YMM(3) , gcc_dwarf_ymm3 , gcc_dwarf_ymm3 , -1, gdb_ymm3 }, + { e_regSetFPU, fpu_ymm4 , "ymm4" , NULL, Vector, VectorOfUInt8, FPU_SIZE_YMM(ymm4) , AVX_OFFSET_YMM(4) , gcc_dwarf_ymm4 , gcc_dwarf_ymm4 , -1, gdb_ymm4 }, + { e_regSetFPU, fpu_ymm5 , "ymm5" , NULL, Vector, VectorOfUInt8, FPU_SIZE_YMM(ymm5) , AVX_OFFSET_YMM(5) , gcc_dwarf_ymm5 , gcc_dwarf_ymm5 , -1, gdb_ymm5 }, + { e_regSetFPU, fpu_ymm6 , "ymm6" , NULL, Vector, VectorOfUInt8, FPU_SIZE_YMM(ymm6) , AVX_OFFSET_YMM(6) , gcc_dwarf_ymm6 , gcc_dwarf_ymm6 , -1, gdb_ymm6 }, + { e_regSetFPU, fpu_ymm7 , "ymm7" , NULL, Vector, VectorOfUInt8, FPU_SIZE_YMM(ymm7) , AVX_OFFSET_YMM(7) , gcc_dwarf_ymm7 , gcc_dwarf_ymm7 , -1, gdb_ymm7 }, + { e_regSetFPU, fpu_ymm8 , "ymm8" , NULL, Vector, VectorOfUInt8, FPU_SIZE_YMM(ymm8) , AVX_OFFSET_YMM(8) , gcc_dwarf_ymm8 , gcc_dwarf_ymm8 , -1, gdb_ymm8 }, + { e_regSetFPU, fpu_ymm9 , "ymm9" , NULL, Vector, VectorOfUInt8, FPU_SIZE_YMM(ymm9) , AVX_OFFSET_YMM(9) , gcc_dwarf_ymm9 , gcc_dwarf_ymm9 , -1, gdb_ymm9 }, + { e_regSetFPU, fpu_ymm10, "ymm10" , NULL, Vector, VectorOfUInt8, FPU_SIZE_YMM(ymm10) , AVX_OFFSET_YMM(10), gcc_dwarf_ymm10, gcc_dwarf_ymm10, -1, gdb_ymm10 }, + { e_regSetFPU, fpu_ymm11, "ymm11" , NULL, Vector, VectorOfUInt8, FPU_SIZE_YMM(ymm11) , AVX_OFFSET_YMM(11), gcc_dwarf_ymm11, gcc_dwarf_ymm11, -1, gdb_ymm11 }, + { e_regSetFPU, fpu_ymm12, "ymm12" , NULL, Vector, VectorOfUInt8, FPU_SIZE_YMM(ymm12) , AVX_OFFSET_YMM(12), gcc_dwarf_ymm12, gcc_dwarf_ymm12, -1, gdb_ymm12 }, + { e_regSetFPU, fpu_ymm13, "ymm13" , NULL, Vector, VectorOfUInt8, FPU_SIZE_YMM(ymm13) , AVX_OFFSET_YMM(13), gcc_dwarf_ymm13, gcc_dwarf_ymm13, -1, gdb_ymm13 }, + { e_regSetFPU, fpu_ymm14, "ymm14" , NULL, Vector, VectorOfUInt8, FPU_SIZE_YMM(ymm14) , AVX_OFFSET_YMM(14), gcc_dwarf_ymm14, gcc_dwarf_ymm14, -1, gdb_ymm14 }, + { e_regSetFPU, fpu_ymm15, "ymm15" , NULL, Vector, VectorOfUInt8, FPU_SIZE_YMM(ymm15) , AVX_OFFSET_YMM(15), gcc_dwarf_ymm15, gcc_dwarf_ymm15, -1, gdb_ymm15 } +}; + // Exception registers const DNBRegisterInfo @@ -686,9 +959,11 @@ // Number of registers in each register set const size_t DNBArchImplX86_64::k_num_gpr_registers = sizeof(g_gpr_registers)/sizeof(DNBRegisterInfo); -const size_t DNBArchImplX86_64::k_num_fpu_registers = sizeof(g_fpu_registers)/sizeof(DNBRegisterInfo); +const size_t DNBArchImplX86_64::k_num_fpu_registers_no_avx = sizeof(g_fpu_registers_no_avx)/sizeof(DNBRegisterInfo); +const size_t DNBArchImplX86_64::k_num_fpu_registers_avx = sizeof(g_fpu_registers_avx)/sizeof(DNBRegisterInfo); const size_t DNBArchImplX86_64::k_num_exc_registers = sizeof(g_exc_registers)/sizeof(DNBRegisterInfo); -const size_t DNBArchImplX86_64::k_num_all_registers = k_num_gpr_registers + k_num_fpu_registers + k_num_exc_registers; +const size_t DNBArchImplX86_64::k_num_all_registers_no_avx = k_num_gpr_registers + k_num_fpu_registers_no_avx + k_num_exc_registers; +const size_t DNBArchImplX86_64::k_num_all_registers_avx = k_num_gpr_registers + k_num_fpu_registers_avx + k_num_exc_registers; //---------------------------------------------------------------------- // Register set definitions. The first definitions at register set index @@ -696,15 +971,25 @@ // register information for the all register set need not be filled in. //---------------------------------------------------------------------- const DNBRegisterSetInfo -DNBArchImplX86_64::g_reg_sets[] = +DNBArchImplX86_64::g_reg_sets_no_avx[] = +{ + { "x86_64 Registers", NULL, k_num_all_registers_no_avx }, + { "General Purpose Registers", g_gpr_registers, k_num_gpr_registers }, + { "Floating Point Registers", g_fpu_registers_no_avx, k_num_fpu_registers_no_avx }, + { "Exception State Registers", g_exc_registers, k_num_exc_registers } +}; + +const DNBRegisterSetInfo +DNBArchImplX86_64::g_reg_sets_avx[] = { - { "x86_64 Registers", NULL, k_num_all_registers }, + { "x86_64 Registers", NULL, k_num_all_registers_avx }, { "General Purpose Registers", g_gpr_registers, k_num_gpr_registers }, - { "Floating Point Registers", g_fpu_registers, k_num_fpu_registers }, + { "Floating Point Registers", g_fpu_registers_avx, k_num_fpu_registers_avx }, { "Exception State Registers", g_exc_registers, k_num_exc_registers } }; + // Total number of register sets for this architecture -const size_t DNBArchImplX86_64::k_num_register_sets = sizeof(g_reg_sets)/sizeof(DNBRegisterSetInfo); +const size_t DNBArchImplX86_64::k_num_register_sets = sizeof(g_reg_sets_avx)/sizeof(DNBRegisterSetInfo); DNBArchProtocol * @@ -726,7 +1011,11 @@ DNBArchImplX86_64::GetRegisterSetInfo(nub_size_t *num_reg_sets) { *num_reg_sets = k_num_register_sets; - return g_reg_sets; + + if (HasAVX() || FORCE_AVX_REGS) + return g_reg_sets_avx; + else + return g_reg_sets_no_avx; } void @@ -795,58 +1084,127 @@ break; case e_regSetFPU: - switch (reg) - { - case fpu_fcw: value->value.uint16 = *((uint16_t *)(&m_state.context.fpu.__fpu_fcw)); return true; - case fpu_fsw: value->value.uint16 = *((uint16_t *)(&m_state.context.fpu.__fpu_fsw)); return true; - case fpu_ftw: value->value.uint8 = m_state.context.fpu.__fpu_ftw; return true; - case fpu_fop: value->value.uint16 = m_state.context.fpu.__fpu_fop; return true; - case fpu_ip: value->value.uint32 = m_state.context.fpu.__fpu_ip; return true; - case fpu_cs: value->value.uint16 = m_state.context.fpu.__fpu_cs; return true; - case fpu_dp: value->value.uint32 = m_state.context.fpu.__fpu_dp; return true; - case fpu_ds: value->value.uint16 = m_state.context.fpu.__fpu_ds; return true; - case fpu_mxcsr: value->value.uint32 = m_state.context.fpu.__fpu_mxcsr; return true; - case fpu_mxcsrmask: value->value.uint32 = m_state.context.fpu.__fpu_mxcsrmask; return true; - - case fpu_stmm0: - case fpu_stmm1: - case fpu_stmm2: - case fpu_stmm3: - case fpu_stmm4: - case fpu_stmm5: - case fpu_stmm6: - case fpu_stmm7: - memcpy(&value->value.uint8, &m_state.context.fpu.__fpu_stmm0 + (reg - fpu_stmm0), 10); - return true; - - case fpu_xmm0: - case fpu_xmm1: - case fpu_xmm2: - case fpu_xmm3: - case fpu_xmm4: - case fpu_xmm5: - case fpu_xmm6: - case fpu_xmm7: - case fpu_xmm8: - case fpu_xmm9: - case fpu_xmm10: - case fpu_xmm11: - case fpu_xmm12: - case fpu_xmm13: - case fpu_xmm14: - case fpu_xmm15: - memcpy(&value->value.uint8, &m_state.context.fpu.__fpu_xmm0 + (reg - fpu_xmm0), 16); - return true; - } + if (HasAVX() || FORCE_AVX_REGS) + { + switch (reg) + { + case fpu_fcw: value->value.uint16 = *((uint16_t *)(&m_state.context.fpu.avx.__fpu_fcw)); return true; + case fpu_fsw: value->value.uint16 = *((uint16_t *)(&m_state.context.fpu.avx.__fpu_fsw)); return true; + case fpu_ftw: value->value.uint8 = m_state.context.fpu.avx.__fpu_ftw; return true; + case fpu_fop: value->value.uint16 = m_state.context.fpu.avx.__fpu_fop; return true; + case fpu_ip: value->value.uint32 = m_state.context.fpu.avx.__fpu_ip; return true; + case fpu_cs: value->value.uint16 = m_state.context.fpu.avx.__fpu_cs; return true; + case fpu_dp: value->value.uint32 = m_state.context.fpu.avx.__fpu_dp; return true; + case fpu_ds: value->value.uint16 = m_state.context.fpu.avx.__fpu_ds; return true; + case fpu_mxcsr: value->value.uint32 = m_state.context.fpu.avx.__fpu_mxcsr; return true; + case fpu_mxcsrmask: value->value.uint32 = m_state.context.fpu.avx.__fpu_mxcsrmask; return true; + + case fpu_stmm0: + case fpu_stmm1: + case fpu_stmm2: + case fpu_stmm3: + case fpu_stmm4: + case fpu_stmm5: + case fpu_stmm6: + case fpu_stmm7: + memcpy(&value->value.uint8, &m_state.context.fpu.avx.__fpu_stmm0 + (reg - fpu_stmm0), 10); + return true; + + case fpu_xmm0: + case fpu_xmm1: + case fpu_xmm2: + case fpu_xmm3: + case fpu_xmm4: + case fpu_xmm5: + case fpu_xmm6: + case fpu_xmm7: + case fpu_xmm8: + case fpu_xmm9: + case fpu_xmm10: + case fpu_xmm11: + case fpu_xmm12: + case fpu_xmm13: + case fpu_xmm14: + case fpu_xmm15: + memcpy(&value->value.uint8, &m_state.context.fpu.avx.__fpu_xmm0 + (reg - fpu_xmm0), 16); + return true; + + case fpu_ymm0: + case fpu_ymm1: + case fpu_ymm2: + case fpu_ymm3: + case fpu_ymm4: + case fpu_ymm5: + case fpu_ymm6: + case fpu_ymm7: + case fpu_ymm8: + case fpu_ymm9: + case fpu_ymm10: + case fpu_ymm11: + case fpu_ymm12: + case fpu_ymm13: + case fpu_ymm14: + case fpu_ymm15: + memcpy(&value->value.uint8, &m_state.context.fpu.avx.__fpu_xmm0 + (reg - fpu_ymm0), 16); + memcpy((&value->value.uint8) + 16, &m_state.context.fpu.avx.__fpu_ymmh0 + (reg - fpu_ymm0), 16); + return true; + } + } + else + { + switch (reg) + { + case fpu_fcw: value->value.uint16 = *((uint16_t *)(&m_state.context.fpu.no_avx.__fpu_fcw)); return true; + case fpu_fsw: value->value.uint16 = *((uint16_t *)(&m_state.context.fpu.no_avx.__fpu_fsw)); return true; + case fpu_ftw: value->value.uint8 = m_state.context.fpu.no_avx.__fpu_ftw; return true; + case fpu_fop: value->value.uint16 = m_state.context.fpu.no_avx.__fpu_fop; return true; + case fpu_ip: value->value.uint32 = m_state.context.fpu.no_avx.__fpu_ip; return true; + case fpu_cs: value->value.uint16 = m_state.context.fpu.no_avx.__fpu_cs; return true; + case fpu_dp: value->value.uint32 = m_state.context.fpu.no_avx.__fpu_dp; return true; + case fpu_ds: value->value.uint16 = m_state.context.fpu.no_avx.__fpu_ds; return true; + case fpu_mxcsr: value->value.uint32 = m_state.context.fpu.no_avx.__fpu_mxcsr; return true; + case fpu_mxcsrmask: value->value.uint32 = m_state.context.fpu.no_avx.__fpu_mxcsrmask; return true; + + case fpu_stmm0: + case fpu_stmm1: + case fpu_stmm2: + case fpu_stmm3: + case fpu_stmm4: + case fpu_stmm5: + case fpu_stmm6: + case fpu_stmm7: + memcpy(&value->value.uint8, &m_state.context.fpu.no_avx.__fpu_stmm0 + (reg - fpu_stmm0), 10); + return true; + + case fpu_xmm0: + case fpu_xmm1: + case fpu_xmm2: + case fpu_xmm3: + case fpu_xmm4: + case fpu_xmm5: + case fpu_xmm6: + case fpu_xmm7: + case fpu_xmm8: + case fpu_xmm9: + case fpu_xmm10: + case fpu_xmm11: + case fpu_xmm12: + case fpu_xmm13: + case fpu_xmm14: + case fpu_xmm15: + memcpy(&value->value.uint8, &m_state.context.fpu.no_avx.__fpu_xmm0 + (reg - fpu_xmm0), 16); + return true; + } + } break; case e_regSetEXC: switch (reg) - { + { case exc_trapno: value->value.uint32 = m_state.context.exc.__trapno; return true; case exc_err: value->value.uint32 = m_state.context.exc.__err; return true; case exc_faultvaddr:value->value.uint64 = m_state.context.exc.__faultvaddr; return true; - } + } break; } } @@ -905,51 +1263,122 @@ break; case e_regSetFPU: - switch (reg) - { - case fpu_fcw: *((uint16_t *)(&m_state.context.fpu.__fpu_fcw)) = value->value.uint16; success = true; break; - case fpu_fsw: *((uint16_t *)(&m_state.context.fpu.__fpu_fsw)) = value->value.uint16; success = true; break; - case fpu_ftw: m_state.context.fpu.__fpu_ftw = value->value.uint8; success = true; break; - case fpu_fop: m_state.context.fpu.__fpu_fop = value->value.uint16; success = true; break; - case fpu_ip: m_state.context.fpu.__fpu_ip = value->value.uint32; success = true; break; - case fpu_cs: m_state.context.fpu.__fpu_cs = value->value.uint16; success = true; break; - case fpu_dp: m_state.context.fpu.__fpu_dp = value->value.uint32; success = true; break; - case fpu_ds: m_state.context.fpu.__fpu_ds = value->value.uint16; success = true; break; - case fpu_mxcsr: m_state.context.fpu.__fpu_mxcsr = value->value.uint32; success = true; break; - case fpu_mxcsrmask: m_state.context.fpu.__fpu_mxcsrmask = value->value.uint32; success = true; break; - - case fpu_stmm0: - case fpu_stmm1: - case fpu_stmm2: - case fpu_stmm3: - case fpu_stmm4: - case fpu_stmm5: - case fpu_stmm6: - case fpu_stmm7: - memcpy (&m_state.context.fpu.__fpu_stmm0 + (reg - fpu_stmm0), &value->value.uint8, 10); - success = true; - break; + if (HasAVX() || FORCE_AVX_REGS) + { + switch (reg) + { + case fpu_fcw: *((uint16_t *)(&m_state.context.fpu.avx.__fpu_fcw)) = value->value.uint16; success = true; break; + case fpu_fsw: *((uint16_t *)(&m_state.context.fpu.avx.__fpu_fsw)) = value->value.uint16; success = true; break; + case fpu_ftw: m_state.context.fpu.avx.__fpu_ftw = value->value.uint8; success = true; break; + case fpu_fop: m_state.context.fpu.avx.__fpu_fop = value->value.uint16; success = true; break; + case fpu_ip: m_state.context.fpu.avx.__fpu_ip = value->value.uint32; success = true; break; + case fpu_cs: m_state.context.fpu.avx.__fpu_cs = value->value.uint16; success = true; break; + case fpu_dp: m_state.context.fpu.avx.__fpu_dp = value->value.uint32; success = true; break; + case fpu_ds: m_state.context.fpu.avx.__fpu_ds = value->value.uint16; success = true; break; + case fpu_mxcsr: m_state.context.fpu.avx.__fpu_mxcsr = value->value.uint32; success = true; break; + case fpu_mxcsrmask: m_state.context.fpu.avx.__fpu_mxcsrmask = value->value.uint32; success = true; break; + + case fpu_stmm0: + case fpu_stmm1: + case fpu_stmm2: + case fpu_stmm3: + case fpu_stmm4: + case fpu_stmm5: + case fpu_stmm6: + case fpu_stmm7: + memcpy (&m_state.context.fpu.avx.__fpu_stmm0 + (reg - fpu_stmm0), &value->value.uint8, 10); + success = true; + break; + + case fpu_xmm0: + case fpu_xmm1: + case fpu_xmm2: + case fpu_xmm3: + case fpu_xmm4: + case fpu_xmm5: + case fpu_xmm6: + case fpu_xmm7: + case fpu_xmm8: + case fpu_xmm9: + case fpu_xmm10: + case fpu_xmm11: + case fpu_xmm12: + case fpu_xmm13: + case fpu_xmm14: + case fpu_xmm15: + memcpy (&m_state.context.fpu.avx.__fpu_xmm0 + (reg - fpu_xmm0), &value->value.uint8, 16); + success = true; + break; - case fpu_xmm0: - case fpu_xmm1: - case fpu_xmm2: - case fpu_xmm3: - case fpu_xmm4: - case fpu_xmm5: - case fpu_xmm6: - case fpu_xmm7: - case fpu_xmm8: - case fpu_xmm9: - case fpu_xmm10: - case fpu_xmm11: - case fpu_xmm12: - case fpu_xmm13: - case fpu_xmm14: - case fpu_xmm15: - memcpy (&m_state.context.fpu.__fpu_xmm0 + (reg - fpu_xmm0), &value->value.uint8, 16); - success = true; - break; - } + case fpu_ymm0: + case fpu_ymm1: + case fpu_ymm2: + case fpu_ymm3: + case fpu_ymm4: + case fpu_ymm5: + case fpu_ymm6: + case fpu_ymm7: + case fpu_ymm8: + case fpu_ymm9: + case fpu_ymm10: + case fpu_ymm11: + case fpu_ymm12: + case fpu_ymm13: + case fpu_ymm14: + case fpu_ymm15: + memcpy(&m_state.context.fpu.avx.__fpu_xmm0 + (reg - fpu_ymm0), &value->value.uint8, 16); + memcpy(&m_state.context.fpu.avx.__fpu_ymmh0 + (reg - fpu_ymm0), (&value->value.uint8) + 16, 16); + return true; + } + } + else + { + switch (reg) + { + case fpu_fcw: *((uint16_t *)(&m_state.context.fpu.no_avx.__fpu_fcw)) = value->value.uint16; success = true; break; + case fpu_fsw: *((uint16_t *)(&m_state.context.fpu.no_avx.__fpu_fsw)) = value->value.uint16; success = true; break; + case fpu_ftw: m_state.context.fpu.no_avx.__fpu_ftw = value->value.uint8; success = true; break; + case fpu_fop: m_state.context.fpu.no_avx.__fpu_fop = value->value.uint16; success = true; break; + case fpu_ip: m_state.context.fpu.no_avx.__fpu_ip = value->value.uint32; success = true; break; + case fpu_cs: m_state.context.fpu.no_avx.__fpu_cs = value->value.uint16; success = true; break; + case fpu_dp: m_state.context.fpu.no_avx.__fpu_dp = value->value.uint32; success = true; break; + case fpu_ds: m_state.context.fpu.no_avx.__fpu_ds = value->value.uint16; success = true; break; + case fpu_mxcsr: m_state.context.fpu.no_avx.__fpu_mxcsr = value->value.uint32; success = true; break; + case fpu_mxcsrmask: m_state.context.fpu.no_avx.__fpu_mxcsrmask = value->value.uint32; success = true; break; + + case fpu_stmm0: + case fpu_stmm1: + case fpu_stmm2: + case fpu_stmm3: + case fpu_stmm4: + case fpu_stmm5: + case fpu_stmm6: + case fpu_stmm7: + memcpy (&m_state.context.fpu.no_avx.__fpu_stmm0 + (reg - fpu_stmm0), &value->value.uint8, 10); + success = true; + break; + + case fpu_xmm0: + case fpu_xmm1: + case fpu_xmm2: + case fpu_xmm3: + case fpu_xmm4: + case fpu_xmm5: + case fpu_xmm6: + case fpu_xmm7: + case fpu_xmm8: + case fpu_xmm9: + case fpu_xmm10: + case fpu_xmm11: + case fpu_xmm12: + case fpu_xmm13: + case fpu_xmm14: + case fpu_xmm15: + memcpy (&m_state.context.fpu.no_avx.__fpu_xmm0 + (reg - fpu_xmm0), &value->value.uint8, 16); + success = true; + break; + } + } break; case e_regSetEXC: Modified: lldb/trunk/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.h?rev=128111&r1=128110&r2=128111&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.h (original) +++ lldb/trunk/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.h Tue Mar 22 16:45:30 2011 @@ -16,9 +16,7 @@ #if defined (__i386__) || defined (__x86_64__) #include "DNBArch.h" -#include -#include - +#include "MachRegisterStatesX86_64.h" class MachThread; @@ -54,18 +52,23 @@ protected: kern_return_t EnableHardwareSingleStep (bool enable); - typedef x86_thread_state64_t GPR; - typedef x86_float_state64_t FPU; - typedef x86_exception_state64_t EXC; + typedef __x86_64_thread_state_t GPR; + typedef __x86_64_float_state_t FPU; + typedef __x86_64_exception_state_t EXC; + typedef __x86_64_avx_state_t AVX; static const DNBRegisterInfo g_gpr_registers[]; - static const DNBRegisterInfo g_fpu_registers[]; + static const DNBRegisterInfo g_fpu_registers_no_avx[]; + static const DNBRegisterInfo g_fpu_registers_avx[]; static const DNBRegisterInfo g_exc_registers[]; - static const DNBRegisterSetInfo g_reg_sets[]; + static const DNBRegisterSetInfo g_reg_sets_no_avx[]; + static const DNBRegisterSetInfo g_reg_sets_avx[]; static const size_t k_num_gpr_registers; - static const size_t k_num_fpu_registers; + static const size_t k_num_fpu_registers_no_avx; + static const size_t k_num_fpu_registers_avx; static const size_t k_num_exc_registers; - static const size_t k_num_all_registers; + static const size_t k_num_all_registers_no_avx; + static const size_t k_num_all_registers_avx; static const size_t k_num_register_sets; typedef enum RegisterSetTag @@ -77,6 +80,13 @@ kNumRegisterSets } RegisterSet; + typedef enum RegisterSetWordSizeTag + { + e_regSetWordSizeGPR = sizeof(GPR) / sizeof(int), + e_regSetWordSizeFPR = sizeof(FPU) / sizeof(int), + e_regSetWordSizeEXC = sizeof(EXC) / sizeof(int), + e_regSetWordSizeAVX = sizeof(AVX) / sizeof(int) + } RegisterSetWordSize; enum { @@ -87,9 +97,12 @@ struct Context { - GPR gpr; - FPU fpu; - EXC exc; + __x86_64_thread_state_t gpr; + union { + __x86_64_float_state_t no_avx; + __x86_64_avx_state_t avx; + } fpu; + __x86_64_exception_state_t exc; }; struct State @@ -191,9 +204,24 @@ static const DNBRegisterSetInfo * GetRegisterSetInfo(nub_size_t *num_reg_sets); + + static bool + HasAVX() + { + if (s_has_avx == kAVXUnknown) + s_has_avx = kAVXNotPresent; + + return (s_has_avx == kAVXPresent); + } MachThread *m_thread; State m_state; + + static enum AVXPresence { + kAVXPresent, + kAVXNotPresent, + kAVXUnknown + } s_has_avx; }; #endif // #if defined (__i386__) || defined (__x86_64__) Added: lldb/trunk/tools/debugserver/source/MacOSX/x86_64/MachRegisterStatesX86_64.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/x86_64/MachRegisterStatesX86_64.h?rev=128111&view=auto ============================================================================== --- lldb/trunk/tools/debugserver/source/MacOSX/x86_64/MachRegisterStatesX86_64.h (added) +++ lldb/trunk/tools/debugserver/source/MacOSX/x86_64/MachRegisterStatesX86_64.h Tue Mar 22 16:45:30 2011 @@ -0,0 +1,197 @@ +//===-- MachRegisterStatesX86_64.h --------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// Created by Sean Callanan on 3/16/11. +// +//===----------------------------------------------------------------------===// + +#ifndef __MachRegisterStatesX86_64_h__ +#define __MachRegisterStatesX86_64_h__ + +#include + +#define __x86_64_THREAD_STATE 4 +#define __x86_64_FLOAT_STATE 5 +#define __x86_64_EXCEPTION_STATE 6 +#define __x86_64_AVX_STATE 17 + +typedef struct { + uint64_t __rax; + uint64_t __rbx; + uint64_t __rcx; + uint64_t __rdx; + uint64_t __rdi; + uint64_t __rsi; + uint64_t __rbp; + uint64_t __rsp; + uint64_t __r8; + uint64_t __r9; + uint64_t __r10; + uint64_t __r11; + uint64_t __r12; + uint64_t __r13; + uint64_t __r14; + uint64_t __r15; + uint64_t __rip; + uint64_t __rflags; + uint64_t __cs; + uint64_t __fs; + uint64_t __gs; +} __x86_64_thread_state_t; + +typedef struct { + uint16_t __invalid : 1; + uint16_t __denorm : 1; + uint16_t __zdiv : 1; + uint16_t __ovrfl : 1; + uint16_t __undfl : 1; + uint16_t __precis : 1; + uint16_t __PAD1 : 2; + uint16_t __pc : 2; + uint16_t __rc : 2; + uint16_t __PAD2 : 1; + uint16_t __PAD3 : 3; +} __x86_64_fp_control_t; + +typedef struct { + uint16_t __invalid : 1; + uint16_t __denorm : 1; + uint16_t __zdiv : 1; + uint16_t __ovrfl : 1; + uint16_t __undfl : 1; + uint16_t __precis : 1; + uint16_t __stkflt : 1; + uint16_t __errsumm : 1; + uint16_t __c0 : 1; + uint16_t __c1 : 1; + uint16_t __c2 : 1; + uint16_t __tos : 3; + uint16_t __c3 : 1; + uint16_t __busy : 1; +} __x86_64_fp_status_t; + +typedef struct { + uint8_t __mmst_reg[10]; + uint8_t __mmst_rsrv[6]; +} __x86_64_mmst_reg; + +typedef struct { + uint8_t __xmm_reg[16]; +} __x86_64_xmm_reg; + +typedef struct { + int32_t __fpu_reserved[2]; + __x86_64_fp_control_t __fpu_fcw; + __x86_64_fp_status_t __fpu_fsw; + uint8_t __fpu_ftw; + uint8_t __fpu_rsrv1; + uint16_t __fpu_fop; + uint32_t __fpu_ip; + uint16_t __fpu_cs; + uint16_t __fpu_rsrv2; + uint32_t __fpu_dp; + uint16_t __fpu_ds; + uint16_t __fpu_rsrv3; + uint32_t __fpu_mxcsr; + uint32_t __fpu_mxcsrmask; + __x86_64_mmst_reg __fpu_stmm0; + __x86_64_mmst_reg __fpu_stmm1; + __x86_64_mmst_reg __fpu_stmm2; + __x86_64_mmst_reg __fpu_stmm3; + __x86_64_mmst_reg __fpu_stmm4; + __x86_64_mmst_reg __fpu_stmm5; + __x86_64_mmst_reg __fpu_stmm6; + __x86_64_mmst_reg __fpu_stmm7; + __x86_64_xmm_reg __fpu_xmm0; + __x86_64_xmm_reg __fpu_xmm1; + __x86_64_xmm_reg __fpu_xmm2; + __x86_64_xmm_reg __fpu_xmm3; + __x86_64_xmm_reg __fpu_xmm4; + __x86_64_xmm_reg __fpu_xmm5; + __x86_64_xmm_reg __fpu_xmm6; + __x86_64_xmm_reg __fpu_xmm7; + __x86_64_xmm_reg __fpu_xmm8; + __x86_64_xmm_reg __fpu_xmm9; + __x86_64_xmm_reg __fpu_xmm10; + __x86_64_xmm_reg __fpu_xmm11; + __x86_64_xmm_reg __fpu_xmm12; + __x86_64_xmm_reg __fpu_xmm13; + __x86_64_xmm_reg __fpu_xmm14; + __x86_64_xmm_reg __fpu_xmm15; + uint8_t __fpu_rsrv4[6*16]; + int32_t __fpu_reserved1; +} __x86_64_float_state_t; + +typedef struct { + uint32_t __fpu_reserved[2]; + __x86_64_fp_control_t __fpu_fcw; + __x86_64_fp_status_t __fpu_fsw; + uint8_t __fpu_ftw; + uint8_t __fpu_rsrv1; + uint16_t __fpu_fop; + uint32_t __fpu_ip; + uint16_t __fpu_cs; + uint16_t __fpu_rsrv2; + uint32_t __fpu_dp; + uint16_t __fpu_ds; + uint16_t __fpu_rsrv3; + uint32_t __fpu_mxcsr; + uint32_t __fpu_mxcsrmask; + __x86_64_mmst_reg __fpu_stmm0; + __x86_64_mmst_reg __fpu_stmm1; + __x86_64_mmst_reg __fpu_stmm2; + __x86_64_mmst_reg __fpu_stmm3; + __x86_64_mmst_reg __fpu_stmm4; + __x86_64_mmst_reg __fpu_stmm5; + __x86_64_mmst_reg __fpu_stmm6; + __x86_64_mmst_reg __fpu_stmm7; + __x86_64_xmm_reg __fpu_xmm0; + __x86_64_xmm_reg __fpu_xmm1; + __x86_64_xmm_reg __fpu_xmm2; + __x86_64_xmm_reg __fpu_xmm3; + __x86_64_xmm_reg __fpu_xmm4; + __x86_64_xmm_reg __fpu_xmm5; + __x86_64_xmm_reg __fpu_xmm6; + __x86_64_xmm_reg __fpu_xmm7; + __x86_64_xmm_reg __fpu_xmm8; + __x86_64_xmm_reg __fpu_xmm9; + __x86_64_xmm_reg __fpu_xmm10; + __x86_64_xmm_reg __fpu_xmm11; + __x86_64_xmm_reg __fpu_xmm12; + __x86_64_xmm_reg __fpu_xmm13; + __x86_64_xmm_reg __fpu_xmm14; + __x86_64_xmm_reg __fpu_xmm15; + uint8_t __fpu_rsrv4[6*16]; + uint32_t __fpu_reserved1; + uint8_t __avx_reserved1[64]; + __x86_64_xmm_reg __fpu_ymmh0; + __x86_64_xmm_reg __fpu_ymmh1; + __x86_64_xmm_reg __fpu_ymmh2; + __x86_64_xmm_reg __fpu_ymmh3; + __x86_64_xmm_reg __fpu_ymmh4; + __x86_64_xmm_reg __fpu_ymmh5; + __x86_64_xmm_reg __fpu_ymmh6; + __x86_64_xmm_reg __fpu_ymmh7; + __x86_64_xmm_reg __fpu_ymmh8; + __x86_64_xmm_reg __fpu_ymmh9; + __x86_64_xmm_reg __fpu_ymmh10; + __x86_64_xmm_reg __fpu_ymmh11; + __x86_64_xmm_reg __fpu_ymmh12; + __x86_64_xmm_reg __fpu_ymmh13; + __x86_64_xmm_reg __fpu_ymmh14; + __x86_64_xmm_reg __fpu_ymmh15; +} __x86_64_avx_state_t; + +typedef struct { + uint32_t __trapno; + uint32_t __err; + uint64_t __faultvaddr; +} __x86_64_exception_state_t; + +#endif From ctice at apple.com Tue Mar 22 17:38:29 2011 From: ctice at apple.com (Caroline Tice) Date: Tue, 22 Mar 2011 22:38:29 -0000 Subject: [Lldb-commits] [lldb] r128115 - /lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp Message-ID: <20110322223829.388002A6C12C@llvm.org> Author: ctice Date: Tue Mar 22 17:38:28 2011 New Revision: 128115 URL: http://llvm.org/viewvc/llvm-project?rev=128115&view=rev Log: More fixes for ARM instruction emulation code: - Remove duplicate write from EmulateLDRRtPCRelative. - Add a missing encoding to EmulateADDSPImm. - Fix minor problems in Thumb instruction tables. Modified: lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp Modified: lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp?rev=128115&r1=128114&r2=128115&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp (original) +++ lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp Tue Mar 22 17:38:28 2011 @@ -1107,8 +1107,6 @@ else // We don't handle ARM for now. return false; - if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_r0 + Rt, data)) - return false; } return true; } @@ -1147,12 +1145,28 @@ if (!success) return false; uint32_t imm32; // the immediate operand - switch (encoding) { - case eEncodingT2: - imm32 = ThumbImm7Scaled(opcode); // imm32 = ZeroExtend(imm7:'00', 32) - break; - default: - return false; + uint32_t d; + bool setflags; + switch (encoding) + { + case eEncodingT1: + // d = UInt(Rd); setflags = FALSE; imm32 = ZeroExtend(imm8:???00???, 32); + d = Bits32 (opcode, 10, 8); + setflags = false; + imm32 = (Bits32 (opcode, 7, 0) << 2); + + break; + + case eEncodingT2: + // d = 13; setflags = FALSE; imm32 = ZeroExtend(imm7:???00???, 32); + d = 13; + setflags = false; + imm32 = ThumbImm7Scaled(opcode); // imm32 = ZeroExtend(imm7:'00', 32) + + break; + + default: + return false; } addr_t sp_offset = imm32; addr_t addr = sp + sp_offset; // the adjusted stack pointer value @@ -1161,8 +1175,16 @@ context.type = EmulateInstruction::eContextAdjustStackPointer; context.SetImmediateSigned (sp_offset); - if (!WriteRegisterUnsigned (context, eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP, addr)) - return false; + if (d == 15) + { + if (!ALUWritePC (context, addr)) + return false; + } + else + { + if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_r0 + d, addr)) + return false; + } } return true; } @@ -9567,6 +9589,7 @@ // Epilogue instructions //---------------------------------------------------------------------- + { 0xfffff800, 0x0000a800, ARMV4T_ABOVE, eEncodingT1, eSize16, &EmulateInstructionARM::EmulateADDSPImm, "add , sp, #imm"}, { 0xffffff80, 0x0000b000, ARMvAll, eEncodingT2, eSize16, &EmulateInstructionARM::EmulateADDSPImm, "add sp, #imm"}, { 0xfffffe00, 0x0000bc00, ARMvAll, eEncodingT1, eSize16, &EmulateInstructionARM::EmulatePOP, "pop "}, { 0xffff0000, 0xe8bd0000, ARMV6T2_ABOVE, eEncodingT2, eSize32, &EmulateInstructionARM::EmulatePOP, "pop.w " }, @@ -9589,13 +9612,13 @@ //---------------------------------------------------------------------- // To resolve ambiguity, "b #imm8" should come after "svc #imm8". { 0xfffff000, 0x0000d000, ARMvAll, eEncodingT1, eSize16, &EmulateInstructionARM::EmulateB, "b #imm8 (outside IT)"}, - { 0xffff8000, 0x0000e000, ARMvAll, eEncodingT2, eSize16, &EmulateInstructionARM::EmulateB, "b #imm11 (outside or last in IT)"}, + { 0xfffff800, 0x0000e000, ARMvAll, eEncodingT2, eSize16, &EmulateInstructionARM::EmulateB, "b #imm11 (outside or last in IT)"}, { 0xf800d000, 0xf0008000, ARMV6T2_ABOVE, eEncodingT3, eSize32, &EmulateInstructionARM::EmulateB, "b.w #imm8 (outside IT)"}, { 0xf800d000, 0xf0009000, ARMV6T2_ABOVE, eEncodingT4, eSize32, &EmulateInstructionARM::EmulateB, "b.w #imm8 (outside or last in IT)"}, // J1 == J2 == 1 - { 0xf800f800, 0xf000f800, ARMV4T_ABOVE, eEncodingT1, eSize32, &EmulateInstructionARM::EmulateBLXImmediate, "bl