aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
AgeCommit message (Collapse)AuthorFilesLines
2025-06-11[doc] Use ISO nomenclature for 1024 byte units (#133148)Alexander Ziaee1-1/+1
Increase specificity by using the correct unit sizes. KBytes is an abbreviation for kB, 1000 bytes, and the hardware industry as well as several operating systems have now switched to using 1000 byte kBs. If this change is acceptable, sometimes GitHub mangles merges to use the original email of the account. $dayjob asks contributions have my work email. Thanks!
2025-02-08[lldb] Upstream a few remaining Triple::XROS patches (#126335)Jason Molenda1-0/+2
Recognize the visionOS Triple::OSType::XROS os type. Some of these have already been landed on main, but I reviewed the downstream sources and there were a few that still needed to be landed upstream.
2024-12-13[lldb][Process] Introduce LoongArch64 hw break/watchpoint supportwanglei1-1/+2
This patch adds support for setting/clearing hardware watchpoints and breakpoints on LoongArch 64-bit hardware. Refer to the following document for the hw break/watchpoint: https://loongson.github.io/LoongArch-Documentation/LoongArch-Vol1-EN.html#control-and-status-registers-related-to-watchpoints Fix Failed Tests: lldb-shell :: Subprocess/clone-follow-child-wp.test lldb-shell :: Subprocess/clone-follow-parent-wp.test lldb-shell :: Subprocess/fork-follow-child-wp.test lldb-shell :: Subprocess/fork-follow-parent-wp.test lldb-shell :: Subprocess/vfork-follow-child-wp.test lldb-shell :: Subprocess/vfork-follow-parent-wp.test lldb-shell :: Watchpoint/ExpressionLanguage.test Depends on: #118043 Reviewed By: SixWeining Pull Request: https://github.com/llvm/llvm-project/pull/118770
2024-09-25[lldb] fix vFile:open, vFile:unlink error codes (#106950)dlav-sc1-15/+14
This patch makes gdb-server sends only GDB RSP supported error codes during vFile:open and vFile:unlink handling.
2024-05-16[lldb] Use operator==(StringRef, StringRef) instead of StringRef::equals ↵Kazu Hirata1-11/+11
(NFC) (#92476) Note that StringRef::equals has been deprecated in favor of operator==(StringRef, StringRef).
2023-06-20[lldb][Android] Support zip .so fileKazuki Sakamoto1-5/+38
In Android API level 23 and above, dynamic loader is able to load .so file directly from APK, which is zip file. https://android.googlesource.com/platform/bionic/+/master/ android-changes-for-ndk-developers.md# opening-shared-libraries-directly-from-an-apk The .so file is page aligned and uncompressed, so ObjectFileELF::GetModuleSpecifications works with .so file offset and size directly from zip file without extracting it. (D152757) GDBRemoteCommunicationServerCommon::GetModuleInfo returns a module spec to LLDB with "zip_path!/so_path" file spec, which is passed through from Android dynamic loader, and the .so file offset and size. PlatformAndroid::DownloadModuleSlice uses 'shell dd' to download the .so file slice from the zip file with the .so file offset and size. Differential Revision: https://reviews.llvm.org/D152759
2023-05-03[lldb] Remove distribution_id from ArchSpecAlex Langford1-2/+2
The qHostInfo packet in the gdb-remote communication protocol specifies that distribution_id can be set, so lldb handles that. But we store that in the ArchSpec representing the "Host" platform (whatever platform the debug server is running on). This field is otherwise unused in ArchSpec, so it would be a lot easier if we stored that information at the gdb-remote communication layer. Sidenote: The distribution_id field is currently unused but I did not want to remove it in case some folks found it useful (e.g. in downstream forks). Differential Revision: https://reviews.llvm.org/D149697
2023-02-07[NFC][TargetParser] Remove llvm/ADT/Triple.hArchibald Elliott1-1/+1
I also ran `git clang-format` to get the headers in the right order for the new location, which has changed the order of other headers in two files.
2023-01-07[lldb] Use std::optional instead of llvm::Optional (NFC)Kazu Hirata1-4/+4
This patch replaces (llvm::|)Optional< with std::optional<. I'll post a separate patch to clean up the "using" declarations, #include "llvm/ADT/Optional.h", etc. This is part of an effort to migrate from llvm::Optional to std::optional: https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
2023-01-07[lldb] Add #include <optional> (NFC)Kazu Hirata1-0/+1
This patch adds #include <optional> to those files containing llvm::Optional<...> or Optional<...>. I'll post a separate patch to actually replace llvm::Optional with std::optional. This is part of an effort to migrate from llvm::Optional to std::optional: https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
2022-12-19Revert "[lldb] Remove redundant .c_str() and .get() calls"Muhammad Omair Javaid1-4/+6
This reverts commit fbaf48be0ff6fb24b9aa8fe9c2284fe88a8798dd. This has broken all LLDB buildbots: https://lab.llvm.org/buildbot/#/builders/68/builds/44990 https://lab.llvm.org/buildbot/#/builders/96/builds/33160
2022-12-18[lldb] Remove redundant .c_str() and .get() callsFangrui Song1-6/+4
Removing .c_str() has a semantics difference, but the use scenarios likely do not matter as we don't have NUL in the strings.
2022-09-18Use std::make_unsigned_t (NFC)Kazu Hirata1-1/+1
2022-09-09[gdb-remote] Move broadcasting logic down to GDBRemoteClientBaseMichał Górny1-5/+3
Move the broadcasting support from GDBRemoteCommunication to GDBRemoteClientBase since this is where it is actually used. Remove GDBRemoteCommunication and subclass constructor arguments left over after Communication cleanup. Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.llvm.org/D133427
2022-08-17[LLDB][NFC] Suppress spurious static inspection warningsSlava Gurevich1-1/+1
Suppress coverity false positives. This diff contains comments only, including the hints for Coverity static code inspection to suppress the warning originating at the next line after the comment. Differential Revision: https://reviews.llvm.org/D131998
2022-07-28[NFC] Improve FileSpec internal APIs and usage in preparation for adding ↵Greg Clayton1-2/+3
caching of resolved/absolute. Resubmission of https://reviews.llvm.org/D130309 with the 2 patches that fixed the linux buildbot, and new windows fixes. The FileSpec APIs allow users to modify instance variables directly by getting a non const reference to the directory and filename instance variables. This makes it impossible to control all of the times the FileSpec object is modified so we can clear cached member variables like m_resolved and with an upcoming patch caching if the file is relative or absolute. This patch modifies the APIs of FileSpec so no one can modify the directory or filename instance variables directly by adding set accessors and by removing the get accessors that are non const. Many clients were using FileSpec::GetCString(...) which returned a unique C string from a ConstString'ified version of the result of GetPath() which returned a std::string. This caused many locations to use this convenient function incorrectly and could cause many strings to be added to the constant string pool that didn't need to. Most clients were converted to using FileSpec::GetPath().c_str() when possible. Other clients were modified to use the newly renamed version of this function which returns an actualy ConstString: ConstString FileSpec::GetPathAsConstString(bool denormalize = true) const; This avoids the issue where people were getting an already uniqued "const char *" that came from a ConstString only to put the "const char *" back into a "ConstString" object. By returning the ConstString instead of a "const char *" clients can be more efficient with the result. The patch: - Removes the non const GetDirectory() and GetFilename() get accessors - Adds set accessors to replace the above functions: SetDirectory() and SetFilename(). - Adds ClearDirectory() and ClearFilename() to replace usage of the FileSpec::GetDirectory().Clear()/FileSpec::GetFilename().Clear() call sites - Fixed all incorrect usage of FileSpec::GetCString() to use FileSpec::GetPath().c_str() where appropriate, and updated other call sites that wanted a ConstString to use the newly returned ConstString appropriately and efficiently. Differential Revision: https://reviews.llvm.org/D130549
2022-07-23Revert "[NFC] Improve FileSpec internal APIs and usage in preparation for ↵Nico Weber1-3/+2
adding caching of resolved/absolute." and follow-ups This reverts commit 9429b67b8e300e638d7828bbcb95585f85c4df4d. It broke the build on Windows, see comments on https://reviews.llvm.org/D130309 It also reverts these follow-ups: Revert "Fix buildbot breakage after https://reviews.llvm.org/D130309." This reverts commit f959d815f4637890ebbacca379f1c38ab47e4e14. Revert "Fix buildbot breakage after https://reviews.llvm.org/D130309." This reverts commit 0bbce7a4c2d2bff622bdadd4323f93f5d90e6d24. Revert "Cache the value for absolute path in FileSpec." This reverts commit dabe877248b85b34878e75d5510339325ee087d0.
2022-07-22[NFC] Improve FileSpec internal APIs and usage in preparation for adding ↵Greg Clayton1-2/+3
caching of resolved/absolute. The FileSpect APIs allow users to modify instance variables directly by getting a non const reference to the directory and filename instance variables. This makes it impossibly to control all of the times the FileSpec object is modified so we can clear the cache. This patch modifies the APIs of FileSpec so no one can modify the directory or filename directly by adding set accessors and by removing the get accessors that are non const. Many clients were using FileSpec::GetCString(...) which returned a unique C string from a ConstString'ified version of the result of GetPath() which returned a std::string. This caused many locations to use this convenient function incorrectly and could cause many strings to be added to the constant string pool that didn't need to. Most clients were converted to using FileSpec::GetPath().c_str() when possible. Other clients were modified to use the newly renamed version of this function which returns an actualy ConstString: ConstString FileSpec::GetPathAsConstString(bool denormalize = true) const; This avoids the issue where people were getting an already uniqued "const char *" that came from a ConstString only to put the "const char *" back into a "ConstString" object. By returning the ConstString instead of a "const char *" clients can be more efficient with the result. The patch: - Removes the non const GetDirectory() and GetFilename() get accessors - Adds set accessors to replace the above functions: SetDirectory() and SetFilename(). - Adds ClearDirectory() and ClearFilename() to replace usage of the FileSpec::GetDirectory().Clear()/FileSpec::GetFilename().Clear() call sites - Fixed all incorrect usage of FileSpec::GetCString() to use FileSpec::GetPath().c_str() where appropriate, and updated other call sites that wanted a ConstString to use the newly returned ConstString appropriately and efficiently. Differential Revision: https://reviews.llvm.org/D130309
2022-02-03[lldb] Rename Logging.h to LLDBLog.h and clean up includesPavel Labath1-0/+1
Most of our code was including Log.h even though that is not where the "lldb" log channel is defined (Log.h defines the generic logging infrastructure). This worked because Log.h included Logging.h, even though it should. After the recent refactor, it became impossible the two files include each other in this direction (the opposite inclusion is needed), so this patch removes the workaround that was put in place and cleans up all files to include the right thing. It also renames the file to LLDBLog to better reflect its purpose.
2022-02-02[lldb] Convert "LLDB" log channel to the new APIPavel Labath1-2/+2
2021-11-10[lldb] [gdb-server] Fix fill_clamp to handle signed src typesMichał Górny1-2/+5
Fix the fill_clamp() function to handle signed source types. Make sure that the source value is always non-negative, and cast it to unsigned when verifying the upper bound. This fixes compiler warnings about comparing unsigned and signed types. Differential Revision: https://reviews.llvm.org/D113519
2021-11-10[lldb] Support gdbserver signalsMichał Górny1-0/+1
GDB and LLDB use different signal models. GDB uses a predefined set of signal codes, and maps platform's signos to them. On the other hand, LLDB has historically simply passed native signos. In order to improve compatibility between LLDB and gdbserver, the GDB signal model should be used. However, GDB does not provide a mapping for all existing signals on Linux and unsupported signals are passed as 'unknown'. Limiting LLDB to this behavior could be considered a regression. To get the best of both worlds, use the LLDB signal model when talking to lldb-server, and the GDB signal model otherwise. For this purpose, new versions of lldb-server indicate "native-signals+" via qSupported. At the same time, we also detect older versions of lldb-server via QThreadSuffixSupported for backwards compatibility. If neither test succeeds, we assume gdbserver or another implementation using GDB model. Differential Revision: https://reviews.llvm.org/D108078
2021-10-26Modernize and simplify HostInfo::GetOSKernelDescriptionPavel Labath1-3/+3
Replace bool+by-ref argument with llvm::Optional, and move the common implementation into HostInfoPOSIX. Based on my (simple) experiment, the uname and the sysctl approach return the same value on MacOS, so there's no need for a mac-specific implementation of this functionality. Differential Revision: https://reviews.llvm.org/D112457
2021-10-22Host::GetOSBuildStringPavel Labath1-3/+3
2021-09-10[lldb] [gdb-remote] Use standardized GDB errno valuesMichał Górny1-4/+15
GDB uses normalized errno values for vFile errors. Implement the translation between them and system errno values in the gdb-remote plugin. Differential Revision: https://reviews.llvm.org/D108148
2021-09-10[lldb] Add new commands and tests for getting file perms & existsMichał Górny1-3/+4
Add two new commands 'platform get-file-permissions' and 'platform file-exists' for the respective bits of LLDB protocol. Add tests for them. Fix error handling in GetFilePermissions(). Differential Revision: https://reviews.llvm.org/D107809
2021-09-10[lldb] [gdb-server] Zero-initialize fields on WIN32Michał Górny1-0/+3
2021-09-10Reland "[lldb] [gdb-server] Implement the vFile:fstat packet"Michał Górny1-0/+45
Now with an #ifdef for WIN32. Differential Revision: https://reviews.llvm.org/D107840
2021-09-10Revert "[lldb] [gdb-server] Implement the vFile:fstat packet"Michał Górny1-43/+0
This reverts commit 9e886fbb18b525c080c04f4a12bd481c9aa849c0. It breaks on Windows.
2021-09-10[lldb] [gdb-server] Implement the vFile:fstat packetMichał Górny1-0/+43
Differential Revision: https://reviews.llvm.org/D107840
2021-08-09[lldb] [gdb-remote] Use hexadecimal numbers in vFile packats for GDB complianceMichał Górny1-33/+36
Use hexadecimal numbers rather than decimal in various vFile packets in order to fix compatibility with gdbserver. This also changes the few custom LLDB packets -- while technically they do not have to be changed, it is easier to use the same syntax consistently across LLDB. Differential Revision: https://reviews.llvm.org/D107475
2021-08-09[lldb] [gdb-remote] Sync vFile:open mode constants with GDBMichał Górny1-4/+0
Sync the mode constants used to drive vFile:open requests with these used by GDB and defined for the gdb remote protocol. This makes it possible to use 'platform file open' after connecting to gdbremote server (and to some degree to operate on the open file modulo other incompatibilities). Differential Revision: https://reviews.llvm.org/D106985
2021-08-09[lldb] [gdb-remote] Add eOpenOptionReadWrite for future gdb compatMichał Górny1-2/+2
Modify OpenOptions enum to open the future path into synchronizing vFile:open bits with GDB. Currently, LLDB and GDB use different flag models effectively making it impossible to match bits. Notably, LLDB uses two bits to indicate read and write status, and uses union of both for read/write. GDB uses a value of 0 for read-only, 1 for write-only and 2 for read/write. In order to future-proof the code for the GDB variant: 1. Add a distinct eOpenOptionReadWrite constant to be used instead of (eOpenOptionRead | eOpenOptionWrite) when R/W access is required. 2. Rename eOpenOptionRead and eOpenOptionWrite to eOpenOptionReadOnly and eOpenOptionWriteOnly respectively, to make it clear that they do not mean to be combined and require update to all call sites. 3. Use the intersection of all three flags when matching against the three possible values. This commit does not change the actual bits used by LLDB. Differential Revision: https://reviews.llvm.org/D106984
2021-07-02[lldb] Replace default bodies of special member functions with = default;Jonas Devlieghere1-1/+2
Replace default bodies of special member functions with = default; $ run-clang-tidy.py -header-filter='lldb' -checks='-*,modernize-use-equals-default' -fix , https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-equals-default.html Differential revision: https://reviews.llvm.org/D104041
2021-05-26[lldb][NFC] Use C++ versions of the deprecated C standard library headersRaphael Isemann1-1/+1
The C headers are deprecated so as requested in D102845, this is replacing them all with their (not deprecated) C++ equivalent. Reviewed By: shafik Differential Revision: https://reviews.llvm.org/D103084
2021-04-14[lldb] Move QThreadSuffixSupported and QListThreadsInStopReply into llgsPavel Labath1-24/+1
These were in the shared llgs+platform code, but they only make sense for llgs (as they deal with how the server reports information about debugged processes).
2021-04-13[lldb] [gdb-remote server] Refactor handling qSupportedMichał Górny1-20/+19
Refactor handling qSupported to use a virtual HandleFeatures() method. The client-provided features are split into an array and passed to the method. The method returns an array of server features that are concatenated into the qSupported response to the server. The base implementation of HandleFeatures() in GDBRemoteCommunicationServerCommon now includes only flags common to both platform server and llgs, while llgs-specific flags are inserted in GDBRemoteCommunicationServerLLGS. Differential Revision: https://reviews.llvm.org/D100140
2021-03-30[lldb] [server] Support for multiprocess extensionMichał Górny1-0/+1
Add a minimal support for the multiprocess extension in lldb-server. The server indicates support for it via qSupported, and accepts thread-ids containing a PID. However, it still does not support debugging more than one inferior, so any other PID value results in an error. Differential Revision: https://reviews.llvm.org/D98482
2020-10-08[lldb] Initial version of FreeBSD remote process pluginMichał Górny1-1/+1
Add a new FreeBSD Process plugin using client/server model. This plugin is based on the one used by NetBSD. It currently supports a subset of functionality for amd64. It is automatically used when spawning lldb-server. It can also be used by lldb client by setting FREEBSD_REMOTE_PLUGIN environment variable (to any value). The code is capable of debugging simple single-threaded programs. It supports general purpose, debug and FPU registers (up to XMM) of amd64, basic signalling, software breakpoints. Adding the support for the plugin involves removing some dead code from FreeBSDPlatform plugin (that was not ever used because CanDebugProcess() returned false), and replacing it with appropriate code from NetBSD platform support. Differential Revision: https://reviews.llvm.org/D88796
2020-03-12[lldb/Utility] Replace ProcessInstanceInfoList with std::vector. (NFCI)Jonas Devlieghere1-4/+3
Replace ProcessInstanceInfoList with std::vector<ProcessInstanceInfo> and update the call sites.
2020-02-20Add target.xml support for qXfer request.Muhammad Omair Javaid1-0/+1
Summary: Requesting registers one by one takes a while in our project. We want to get rid of it by using target.xml. Reviewers: jarin, labath, omjavaid Reviewed By: labath, omjavaid Subscribers: omjavaid, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D74217
2020-02-18Revert "[lldb/lldb-server] Add target.xml support for qXfer request."Muhammad Omair Javaid1-1/+0
This patch cause floating point registers to fail on LLDB aarch64-linux buildbot. http://lab.llvm.org:8011/builders/lldb-aarch64-ubuntu/builds/1713 This reverts commit aedc196101e33bd58f7443c5b93398418ce55edf.
2020-02-17[lldb/lldb-server] Add target.xml support for qXfer request.Levon Ter-Grigoryan1-0/+1
Summary: Synthesize target.xml in lldb-server to avoid a long chain of qRegisterInfo packets, which can be slow over low-latency links. Reviewers: jarin, labath Reviewed By: labath Subscribers: lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D74217
2020-01-28[lldb/Plugin] Fix implicit conversion in GDBRemoteJonas Devlieghere1-1/+1
2020-01-28Make llvm::StringRef to std::string conversions explicit.Benjamin Kramer1-1/+1
This is how it should've been and brings it more in line with std::string_view. There should be no functional change here. This is mostly mechanical from a custom clang-tidy check, with a lot of manual fixups. It uncovers a lot of minor inefficiencies. This doesn't actually modify StringRef yet, I'll do that in a follow-up.
2020-01-24[lldb][NFC] Fix all formatting errors in .cpp file headersRaphael Isemann1-1/+1
Summary: A *.cpp file header in LLDB (and in LLDB) should like this: ``` //===-- TestUtilities.cpp -------------------------------------------------===// ``` However in LLDB most of our source files have arbitrary changes to this format and these changes are spreading through LLDB as folks usually just use the existing source files as templates for their new files (most notably the unnecessary editor language indicator `-*- C++ -*-` is spreading and in every review someone is pointing out that this is wrong, resulting in people pointing out that this is done in the same way in other files). This patch removes most of these inconsistencies including the editor language indicators, all the different missing/additional '-' characters, files that center the file name, missing trailing `===//` (mostly caused by clang-format breaking the line). Reviewers: aprantl, espindola, jfb, shafik, JDevlieghere Reviewed By: JDevlieghere Subscribers: dexonsmith, wuzish, emaste, sdardis, nemanjai, kbarton, MaskRay, atanasyan, arphaman, jfb, abidh, jsji, JDevlieghere, usaxena95, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D73258
2019-12-13[lldb/Host] Use cmakedefine01 for LLDB_ENABLE_POSIXJonas Devlieghere1-2/+2
Rename LLDB_DISABLE_POSIX to LLDB_ENABLE_POSIX and use cmakedefine01 for consistency.
2019-10-16Add arm64_32 support to lldb, an ILP32 codegen Jason Molenda1-0/+2
that runs on arm64 ISA targets, specifically Apple watches. Differential Revision: https://reviews.llvm.org/D68858 llvm-svn: 375032
2019-10-16[android/process list] support showing process argumentsWalter Erquinigo1-0/+9
Summary: The qfProcessInfo and qsProcessInfo packets currently don't set the processes' arguments, however the platform process list -v command tries to print it. In this diff I'm adding the arguments as part of the packet, and now the command shows the arguments just like on mac. On Mac: 507 1 wallace 1876110778 wallace 1876110778 x86_64-apple-macosx /usr/libexec/secd 503 1 wallace 1876110778 wallace 1876110778 x86_64-apple-macosx /usr/libexec/secinitd 501 1 wallace 1876110778 wallace 1876110778 x86_64-apple-macosx /usr/libexec/languageassetd --firstLogin 497 1 wallace 1876110778 wallace 1876110778 x86_64-apple-macosx /usr/libexec/trustd --agent 496 1 wallace 1876110778 wallace 1876110778 x86_64-apple-macosx /usr/libexec/lsd 494 1 wallace 1876110778 wallace 1876110778 x86_64-apple-macosx /System/Library/Frameworks/CoreTelephony.framework/Support/CommCenter -L 491 1 wallace 1876110778 wallace 1876110778 x86_64-apple-macosx /usr/sbin/distnoted agent 489 1 wallace 1876110778 wallace 1876110778 x86_64-apple-macosx /usr/libexec/UserEventAgent (Aqua) 484 1 wallace 1876110778 wallace 1876110778 x86_64-apple-macosx /usr/sbin/cfprefsd agent 483 1 wallace 1876110778 wallace 1876110778 x86_64-apple-macosx /System/Library/Frameworks/LocalAuthentication.framework/Support/coreauthd On android: 1561 1016 root 0 0 aarch64-unknown-linux-android /system/bin/ip6tables-restore--noflush -w -v 1805 982 1000 1000 1000 android:drmService 1811 982 10189 10189 10189 com.qualcomm.embms:remote 1999 1 1000 1000 1000 aarch64-unknown-linux-android /system/bin/tlc_serverCCM 2332 982 10038 10038 10038 com.android.systemui 2378 983 1053 1053 1053 webview_zygote 2448 982 5013 5013 5013 com.sec.location.nsflp2 2465 982 10027 10027 10027 com.google.android.gms.persistent Differential Revision: https://reviews.llvm.org/D68293 llvm-svn: 375029
2019-10-14uint32_t options -> File::OpenOptions optionsLawrence D'Anna1-2/+6
Summary: This patch re-types everywhere that passes a File::OpenOptions as a uint32_t so it actually uses File::OpenOptions. It also converts some OpenOptions related functions that fail by returning 0 or NULL into llvm::Expected split off from https://reviews.llvm.org/D68737 Reviewers: JDevlieghere, jasonmolenda, labath Reviewed By: labath Subscribers: lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D68853 llvm-svn: 374817