summaryrefslogtreecommitdiffstats
path: root/lldb/source/Plugins/ObjectFile/Mach-O
Commit message (Collapse)AuthorAgeFilesLines
* [lldb/DWARF] Move location list sections into DWARFContextPavel Labath2020-01-141-0/+2
| | | | | | These are the last sections not managed by the DWARFContext object. I also introduce separate SectionType enums for dwo section variants, as this is necessary for proper handling of single-file split dwarf.
* make err msg in MachSymtabSectionInfo::GetSection clear about the fileJason Molenda2019-12-181-2/+8
| | | | | | This error message didn't specify which file was malformed, so there's some hunting-around required if it comes up. We have the filename; include it in the error message.
* [lldb/MachO] "Fix" intentional out-of-bounds error (NFC)Jonas Devlieghere2019-12-181-4/+5
| | | | | | | Remove the hack that populates the cpsr register in the gpr struct by writing past the end of the array. This was tripping up ASan. Patch by: Reva Cuthbertson
* [lldb] Add boilerplate to recognize the .debug_rnglists.dwo sectionPavel Labath2019-11-261-0/+1
|
* [ObjectFileMachO] Fix the build for __arm64__.Davide Italiano2019-11-121-2/+1
| | | | Catch up with an API change.
* Fix compilation error in ObjectFileMachO::ParseSymtabVedant Kumar2019-10-251-2/+5
|
* Modernize the rest of the Find.* API (NFC)Adrian Prantl2019-10-171-2/+3
| | | | | | | | | | | | This patch removes the size_t return value and the append parameter from the remainder of the Find.* functions in LLDB's internal API. As in the previous patches, this is motivated by the fact that these parameters aren't really used, and in the case of the append parameter were frequently implemented incorrectly. Differential Revision: https://reviews.llvm.org/D69119 llvm-svn: 375160
* Add arm64_32 support to lldb, an ILP32 codegen Jason Molenda2019-10-161-0/+4
| | | | | | | | | | that runs on arm64 ISA targets, specifically Apple watches. Differential Revision: https://reviews.llvm.org/D68858 llvm-svn: 375032
* ObjectFileMachO: Replace std::map with llvm::DenseMap (NFC)Adrian Prantl2019-10-081-18/+10
| | | | | | | | This makes parsing the symbol table of clang marginally faster. (Hashtable versus tree). Differential Revision: https://reviews.llvm.org/D68605 llvm-svn: 374084
* Replace static const StringRef with StringRef (NFC)Adrian Prantl2019-10-081-11/+11
| | | | | | Differential Revision: https://reviews.llvm.org/D68597 llvm-svn: 374081
* Remove constructor and unused method (NFC).Adrian Prantl2019-10-081-15/+3
| | | | | | Differential Revision: https://reviews.llvm.org/D68595 llvm-svn: 374080
* [MachO] Fix symbol merging during symtab parsing.Jonas Devlieghere2019-10-081-23/+55
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The symtab parser in ObjectFileMachO has logic to coalesce debug (STAB) and non-debug symbols, based on the address and the symbol name for static (STSYM) and global symbols (GSYM) respectively. It makes the assumption that the debug variant is always encountered first. Rather than creating a second entry in the symbol table for the non-debug symbol, the latter gets merged into the existing debug symbol. This breaks when the linker emits the non-debug symbol first. We'd end up with two entries in the symbol table, each containing part of the information LLDB relies on. Indeed, commenting out the merging logic breaks the test suite spectacularly. This patch solves that problem by always parsing the debug symbols first. This guarantees that the assumption for merging holds. I'm not particularly happy with adding a lambda, but after numerous attempts this is the best solution I could come up with. The symtab parsing logic is pretty complex in that it touches a lot of things. I've experienced first hand that it's very easy to break things. I believe this approach strikes a balance between fixing the issue while limiting the risk of regressions. Differential revision: https://reviews.llvm.org/D68536 llvm-svn: 373994
* [MachO] Shuffle some things around in ParseSymtab (NFC)Jonas Devlieghere2019-10-071-5/+4
| | | | llvm-svn: 373954
* [MachO] Reduce indentation further in ParseSymtab (NFC)Jonas Devlieghere2019-10-041-176/+177
| | | | llvm-svn: 373810
* [MachO] Move nlist parsing into helper function (NFC)Jonas Devlieghere2019-10-041-21/+14
| | | | llvm-svn: 373803
* [MachO] Add early returns to save some indentation.Jonas Devlieghere2019-10-041-2828/+2776
| | | | | | | This file really suffered from the Great Reformat. I'm adding a few early returns to give the deeply nested code some more breathing room. llvm-svn: 373778
* [MachO] Reformat before making changes to this file (NFC)Jonas Devlieghere2019-10-041-200/+206
| | | | llvm-svn: 373777
* [ObjectFileMachO] FileSpec::SetFile() now takes the style as arg.Davide Italiano2019-10-021-1/+1
| | | | | | | | | Another block that's only compiled on __arm64__ and wasn't updated. <rdar://problem/55916729> llvm-svn: 373508
* [ObjectFileMachO] Catch up with FileDesc changes.Davide Italiano2019-10-021-3/+3
| | | | | | | | This didn't show up because nobody built __arm64__ in a while. <rdar://problem/55916729> llvm-svn: 373507
* Convert FileSystem::Open() to return Expected<FileUP>Lawrence D'Anna2019-09-261-10/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This patch converts FileSystem::Open from this prototype: Status Open(File &File, const FileSpec &file_spec, ...); to this one: llvm::Expected<std::unique_ptr<File>> Open(const FileSpec &file_spec, ...); This is beneficial on its own, as llvm::Expected is a more modern and recommended error type than Status. It is also a necessary step towards https://reviews.llvm.org/D67891, and further developments for lldb_private::File. Reviewers: JDevlieghere, jasonmolenda, labath Reviewed By: labath Subscribers: mgorny, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D67996 llvm-svn: 373003
* [lldb][NFC] Rename ReadRegisterValue to PrintRegisterValueRaphael Isemann2019-09-041-95/+95
| | | | | | | That was the actual name I had in mind, but it seems git didn't pick that change up when committing my previous commit. llvm-svn: 370856
* [lldb][NFC] Remove WriteRegister copy-pasta from ObjectFileMachORaphael Isemann2019-09-041-198/+119
| | | | | | | | | | | | The function had the same name as one of the member function, so it was just copied to all classes so that the lookup works. We could also give the function a more better and unique name (because it's actually printing the register value and writing to the stream, not writing to the register). Also removes the unused return value. llvm-svn: 370854
* Upstream support for macCatalyst Mach-O binaries.Adrian Prantl2019-08-232-144/+225
| | | | | | | | | | | | On macOS one Mach-O slice can contain multiple load commands: One load command for being loaded into a macOS process and one load command for being loaded into a macCatalyst process. This patch adds support for the new load command and makes sure ObjectFileMachO returns the Architecture that matches the Module. Differential Revision: https://reviews.llvm.org/D66626 llvm-svn: 369814
* [LLDB] Migrate llvm::make_unique to std::make_uniqueJonas Devlieghere2019-08-141-1/+1
| | | | | | | | | | Now that we've moved to C++14, we no longer need the llvm::make_unique implementation from STLExtras.h. This patch is a mechanical replacement of (hopefully) all the llvm::make_unique instances across the monorepo. Differential revision: https://reviews.llvm.org/D66259 llvm-svn: 368933
* Add llvm-style RTTI to ObjectFile hierarchyPavel Labath2019-07-312-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: On the heels of D62934, this patch uses the same approach to introduce llvm RTTI support to the ObjectFile hierarchy. It also replaces the existing uses of GetPluginName doing run-time type checks with llvm::dyn_cast and friends. This formally introduces new dependencies from some other plugins to ObjectFile plugins. However, I believe this is fine because: - these dependencies were already kind of there, and the only reason we could get away with not modeling them explicitly was because the code was relying on magically knowing what will GetPluginName() return for a particular kind of object files. - the dependencies themselves are logical (it makes sense for SymbolVendorELF to depend on ObjectFileELF), or at least don't actively get in the way (the JitLoaderGDB->MachO thing). - they don't introduce any new dependency loops as ObjectFile plugins don't depend on any other plugins Reviewers: xiaobai, JDevlieghere, espindola Subscribers: emaste, mgorny, arichardson, MaskRay, lldb-commits Differential Revision: https://reviews.llvm.org/D65450 llvm-svn: 367413
* [Logging] Replace Log::Printf with LLDB_LOG macro (NFC)Jonas Devlieghere2019-07-241-7/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | This patch replaces explicit calls to log::Printf with the new LLDB_LOGF macro. The macro is similar to LLDB_LOG but supports printf-style format strings, instead of formatv-style format strings. So instead of writing: if (log) log->Printf("%s\n", str); You'd write: LLDB_LOG(log, "%s\n", str); This change was done mechanically with the command below. I replaced the spurious if-checks with vim, since I know how to do multi-line replacements with it. find . -type f -name '*.cpp' -exec \ sed -i '' -E 's/log->Printf\(/LLDB_LOGF\(log, /g' "{}" + Differential revision: https://reviews.llvm.org/D65128 llvm-svn: 366936
* Fall back to dyld's _dyld_start when no LC_MAIN / main() func can be foundJason Molenda2019-07-182-1/+20
| | | | | | | | | | | | | | | | | | | | | | | | | The new DriverKit user-land kernel drivers in macOS 10.15 / Catalina do not have a main() function or an LC_MAIN load command. lldb uses the address of main() as the return address for inferior function calls; it puts a breakpoint on main, runs the inferior function call, and when the main() breakpoint is hit, lldb knows unambiguously that the inferior function call ran to completion - no other function calls main. This change hoists the logic for finding the "entry address" from ThreadPlanCallFunction to Target. It changes the logic to first try to get the entry address from the main executable module, but if that module does not have one, it will iterate through all modules looking for an entry address. The patch also adds code to ObjectFileMachO to use dyld's _dyld_start function as an entry address. <rdar://problem/52343958> Differential Revision: https://reviews.llvm.org/D64897 llvm-svn: 366493
* Refactor ObjectFile::GetSDKVersionRaphael Isemann2019-07-032-40/+14
| | | | | | | | | | | | | | | | Summary: This patch modernizes the GetSDKVersion API and hopefully prevents problems such as the ones discovered in D61218. Reviewers: aprantl, jasonmolenda, clayborg Reviewed By: aprantl, clayborg Subscribers: clayborg, labath, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D61233 llvm-svn: 365090
* Get the expression parser to handle missing weak symbols.Jim Ingham2019-06-281-0/+2
| | | | | | | | | | MachO only for this patch. Differential Revision: https://reviews.llvm.org/D63914 <rdar://problem/51463642> llvm-svn: 364686
* Recognise debug_types.dwo as a debug info sectionPavel Labath2019-06-121-0/+1
| | | | | | This is a preparatory patch to allow reading type units from dwo files. llvm-svn: 363146
* Fix integer literals which are cast to boolJonas Devlieghere2019-05-241-1/+1
| | | | | | | | | This change replaces built-in types that are implicitly converted to booleans. Differential revision: https://reviews.llvm.org/D62284 llvm-svn: 361580
* [lldb] NFC modernize codebase with modernize-use-nullptrKonrad Kleine2019-05-231-149/+149
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: NFC = [[ https://llvm.org/docs/Lexicon.html#nfc | Non functional change ]] This commit is the result of modernizing the LLDB codebase by using `nullptr` instread of `0` or `NULL`. See https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-nullptr.html for more information. This is the command I ran and I to fix and format the code base: ``` run-clang-tidy.py \ -header-filter='.*' \ -checks='-*,modernize-use-nullptr' \ -fix ~/dev/llvm-project/lldb/.* \ -format \ -style LLVM \ -p ~/llvm-builds/debug-ninja-gcc ``` NOTE: There were also changes to `llvm/utils/unittest` but I did not include them because I felt that maybe this library shall be updated in isolation somehow. NOTE: I know this is a rather large commit but it is a nobrainer in most parts. Reviewers: martong, espindola, shafik, #lldb, JDevlieghere Reviewed By: JDevlieghere Subscribers: arsenm, jvesely, nhaehnle, hiraditya, JDevlieghere, teemperor, rnkovacs, emaste, kubamracek, nemanjai, ki.stfu, javed.absar, arichardson, kbarton, jrtc27, MaskRay, atanasyan, dexonsmith, arphaman, jfb, jsji, jdoerfert, lldb-commits, llvm-commits Tags: #lldb, #llvm Differential Revision: https://reviews.llvm.org/D61847 llvm-svn: 361484
* [NFC] Remove ASCII lines from commentsJonas Devlieghere2019-04-102-22/+0
| | | | | | | | | | | | | | | | | | | | | | | A lot of comments in LLDB are surrounded by an ASCII line to delimit the begging and end of the comment. Its use is not really consistent across the code base, sometimes the lines are longer, sometimes they are shorter and sometimes they are omitted. Furthermore, it looks kind of weird with the 80 column limit, where the comment actually extends past the line, but not by much. Furthermore, when /// is used for Doxygen comments, it looks particularly odd. And when // is used, it incorrectly gives the impression that it's actually a Doxygen comment. I assume these lines were added to improve distinguishing between comments and code. However, given that todays editors and IDEs do a great job at highlighting comments, I think it's worth to drop this for the sake of consistency. The alternative is fixing all the inconsistencies, which would create a lot more churn. Differential revision: https://reviews.llvm.org/D60508 llvm-svn: 358135
* [ObjectFileMachO] Remove another debugging aid.Davide Italiano2019-03-281-7/+0
| | | | | | Pointed out by Jason. llvm-svn: 357135
* [ObjectFileMachO] Disable memory caching for savecore.Davide Italiano2019-03-281-13/+6
| | | | | | | | | | | | | | | | | Summary: It's not really useful, and largely increases the footprint. <rdar://problem/49293525> Reviewers: jasonmolenda Subscribers: llvm-commits, lldb-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D59896 llvm-svn: 357134
* Pass ConstString by value (NFC)Adrian Prantl2019-03-062-22/+22
| | | | | | | | | | | | | | | | | My apologies for the large patch. With the exception of ConstString.h itself it was entirely produced by sed. ConstString has exactly one const char * data member, so passing a ConstString by reference is not any more efficient than copying it by value. In both cases a single pointer is passed. But passing it by value makes it harder to accidentally return the address of a local object. (This fixes rdar://problem/48640859 for the Apple folks) Differential Revision: https://reviews.llvm.org/D59030 llvm-svn: 355553
* Move RangeMap.h into UtilityPavel Labath2019-03-062-2/+2
| | | | | | | | | | | | | | Summary: This file implements some general purpose data structures, and so it belongs to the Utility module. Reviewers: zturner, jingham, JDevlieghere, clayborg, espindola Subscribers: emaste, mgorny, javed.absar, arichardson, MaskRay, lldb-commits Differential Revision: https://reviews.llvm.org/D58970 llvm-svn: 355509
* Replace 'ap' with 'up' suffix in variable names. (NFC)Jonas Devlieghere2019-02-131-19/+19
| | | | | | | | | | | | | | | | | The `ap` suffix is a remnant of lldb's former use of auto pointers, before they got deprecated. Although all their uses were replaced by unique pointers, some variables still carried the suffix. In r353795 I removed another auto_ptr remnant, namely redundant calls to ::get for unique_pointers. Jim justly noted that this is a good opportunity to clean up the variable names as well. I went over all the changes to ensure my find-and-replace didn't have any undesired side-effects. I hope I didn't miss any, but if you end up at this commit doing a git blame on a weirdly named variable, please know that the change was unintentional. llvm-svn: 353912
* Remove redundant ::get() for smart pointer. (NFC)Jonas Devlieghere2019-02-121-2/+2
| | | | | | | | This commit removes redundant calls to smart pointer’s ::get() method. https://clang.llvm.org/extra/clang-tidy/checks/readability-redundant-smartptr-get.html llvm-svn: 353795
* Define _ENABLE_EXTENDED_ALIGNED_STORAGE on Windows.Jonas Devlieghere2019-02-121-8/+14
| | | | | | | | | | Apparently there are multiple places where MSVC complains about instantiations with extended aligment. I think it's better to define `_ENABLE_EXTENDED_ALIGNED_STORAGE` as suggested by the error message. I don't have access to a Windows machine so this is all speculative. llvm-svn: 353778
* [ObjectFileMachO] Revert std::make_sharedJonas Devlieghere2019-02-111-14/+8
| | | | | | | This caused a rather interesting error message on MSVC: error C2338 and I'm not sure how to properly fix it. llvm-svn: 353769
* Use std::make_shared in LLDB (NFC)Jonas Devlieghere2019-02-111-8/+14
| | | | | | | | | | | Unlike std::make_unique, which is only available since C++14, std::make_shared is available since C++11. Not only is std::make_shared a lot more readable compared to ::reset(new), it also performs a single heap allocation for the object and control block. Differential revision: https://reviews.llvm.org/D57990 llvm-svn: 353764
* Simplify ObjectFile::GetUUIDPavel Labath2019-02-112-20/+15
| | | | | | | | | instead of returning the UUID through by-ref argument and a boolean value indicating success, we can just return it directly. Since the UUID class already has an invalid state, it can be used to denote the failure without the additional bool. llvm-svn: 353714
* Fix strlen() of unbound array undefined behaviorJan Kratochvil2019-02-061-4/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | LLDB testsuite fails when built by GCC8 on: LLDB :: SymbolFile/DWARF/find-basic-namespace.cpp This is because this code in LLDB codebase has undefined behavior: #include <algorithm> #include <string.h> // lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp:1731 static struct section_64 { char sectname[16]; char segname[16]; } sect64 = { {'_','_','a','p','p','l','e','_','n','a','m','e','s','p','a','c'}, "__DWARF" }; int main() { return std::min<size_t>(strlen(sect64.sectname), sizeof(sect64.sectname)); } It has been discussed as a (false) bugreport to GCC: wrong-code: LLDB testcase fails: SymbolFile/DWARF/find-basic-namespace.cpp https://bugzilla.redhat.com/show_bug.cgi?id=1672436 Differential Revision: https://reviews.llvm.org/D57781 llvm-svn: 353280
* Update the file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-192-8/+6
| | | | | | | | | | | | | | | | | to reflect the new license. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351636
* Simplify ObjectFile::GetArchitecturePavel Labath2019-01-032-27/+25
| | | | | | | | | | | | | | | | Summary: instead of returning the architecture through by-ref argument and a boolean value indicating success, we can just return the ArchSpec directly. Since the ArchSpec already has an invalid state, it can be used to denote the failure without the additional bool. Reviewers: clayborg, zturner, espindola Subscribers: emaste, arichardson, JDevlieghere, lldb-commits Differential Revision: https://reviews.llvm.org/D56129 llvm-svn: 350291
* Don't duplicate the logic that detects if a section can/should be loaded (NFC)Greg Clayton2018-12-212-51/+48
| | | | | | Prior to this there were 3 places that were duplicating the logic to detect if a section can/should be loaded and some were doing things a bit differently. Now it is all centralized in one place and it is done correctly. llvm-svn: 349926
* Simplify Boolean expressionsJonas Devlieghere2018-12-151-47/+45
| | | | | | | | | | | This patch simplifies boolean expressions acorss LLDB. It was generated using clang-tidy with the following command: run-clang-tidy.py -checks='-*,readability-simplify-boolean-expr' -format -fix $PWD Differential revision: https://reviews.llvm.org/D55584 llvm-svn: 349215
* Rename ObjectFile::GetHeaderAddress to GetBaseAddressPavel Labath2018-12-112-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | Summary: This function was named such because in the case of MachO files, the mach header is located at this address. However all (most?) usages of this function were not interested in that fact, but the fact that this address is used as the base address for expressing various relative addresses in the object file. For other object file formats, this name is not appropriate (and it's probably the reason why this function was not implemented in these classes). In the ELF case the ELF header will usually end up at this address, but this is a result of the linker optimizing the file layout and not a requirement of the spec. For COFF files, I believe the is no header located at this address either. Reviewers: clayborg, jasonmolenda, amccarth, lemo, stella.stamenova Subscribers: lldb-commits Differential Revision: https://reviews.llvm.org/D55422 llvm-svn: 348849
* [LLDB] - Recommit r346848 "[LLDB] - Support the single file split DWARF.".George Rimar2018-11-141-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | Test cases were updated to not use the local compilation dir which is different between development pc and build bots. Original commit message: [LLDB] - Support the single file split DWARF. DWARF5 spec describes a single file split dwarf case (when .dwo sections are in the .o files). Problem is that LLDB does not work correctly in that case. The issue is that, for example, both .debug_info and .debug_info.dwo has the same type: eSectionTypeDWARFDebugInfo. And when code searches section by type it might find the regular debug section and not the .dwo one. The patch fixes that. With it, LLDB is able to work with output compiled with -gsplit-dwarf=single flag correctly. Differential revision: https://reviews.llvm.org/D52403 llvm-svn: 346855
OpenPOWER on IntegriCloud