180814287SRaphael Isemann //===-- PlatformLinux.cpp -------------------------------------------------===//
2e996fd30SGreg Clayton //
32946cd70SChandler Carruth // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
42946cd70SChandler Carruth // See https://llvm.org/LICENSE.txt for license information.
52946cd70SChandler Carruth // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6e996fd30SGreg Clayton //
7e996fd30SGreg Clayton //===----------------------------------------------------------------------===//
8e996fd30SGreg Clayton 
9e996fd30SGreg Clayton #include "PlatformLinux.h"
10b2f1fb29SVirgile Bello #include "lldb/Host/Config.h"
11e996fd30SGreg Clayton 
12ecc11474SStephen Wilson #include <stdio.h>
133011d55fSJonas Devlieghere #if LLDB_ENABLE_POSIX
14ecc11474SStephen Wilson #include <sys/utsname.h>
15b2f1fb29SVirgile Bello #endif
16ecc11474SStephen Wilson 
1728041352SGreg Clayton #include "lldb/Core/Debugger.h"
18ecc11474SStephen Wilson #include "lldb/Core/PluginManager.h"
1913b18261SZachary Turner #include "lldb/Host/HostInfo.h"
20e996fd30SGreg Clayton #include "lldb/Target/Process.h"
21b9c1b51eSKate Stone #include "lldb/Target/Target.h"
225713a05bSZachary Turner #include "lldb/Utility/FileSpec.h"
236f9e6901SZachary Turner #include "lldb/Utility/Log.h"
24d821c997SPavel Labath #include "lldb/Utility/State.h"
2597206d57SZachary Turner #include "lldb/Utility/Status.h"
26bf9a7730SZachary Turner #include "lldb/Utility/StreamString.h"
27e996fd30SGreg Clayton 
2805097246SAdrian Prantl // Define these constants from Linux mman.h for use when targeting remote linux
2905097246SAdrian Prantl // systems even when host has different values.
3096ad3de5SRobert Flack #define MAP_PRIVATE 2
3196ad3de5SRobert Flack #define MAP_ANON 0x20
3296ad3de5SRobert Flack 
33e996fd30SGreg Clayton using namespace lldb;
34e996fd30SGreg Clayton using namespace lldb_private;
35db264a6dSTamas Berghammer using namespace lldb_private::platform_linux;
36e996fd30SGreg Clayton 
37*fbb4d1e4SJonas Devlieghere LLDB_PLUGIN(PlatformLinux);
38*fbb4d1e4SJonas Devlieghere 
3928041352SGreg Clayton static uint32_t g_initialize_count = 0;
4028041352SGreg Clayton 
41281961a8STodd Fiala 
42b9c1b51eSKate Stone PlatformSP PlatformLinux::CreateInstance(bool force, const ArchSpec *arch) {
43db264a6dSTamas Berghammer   Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PLATFORM));
440e92fbb5SPavel Labath   LLDB_LOG(log, "force = {0}, arch=({1}, {2})", force,
450e92fbb5SPavel Labath            arch ? arch->GetArchitectureName() : "<null>",
460e92fbb5SPavel Labath            arch ? arch->GetTriple().getTriple() : "<null>");
47015d818bSTodd Fiala 
48b3a40ba8SGreg Clayton   bool create = force;
49a6682a41SJonas Devlieghere   if (!create && arch && arch->IsValid()) {
50b3a40ba8SGreg Clayton     const llvm::Triple &triple = arch->GetTriple();
51b9c1b51eSKate Stone     switch (triple.getOS()) {
5270512317SGreg Clayton     case llvm::Triple::Linux:
53b1da257aSTed Woodward       create = true;
5470512317SGreg Clayton       break;
5570512317SGreg Clayton 
56dbc6c0bbSGreg Clayton #if defined(__linux__)
5705097246SAdrian Prantl     // Only accept "unknown" for the OS if the host is linux and it "unknown"
5805097246SAdrian Prantl     // wasn't specified (it was just returned because it was NOT specified)
59015d818bSTodd Fiala     case llvm::Triple::OSType::UnknownOS:
6070512317SGreg Clayton       create = !arch->TripleOSWasSpecified();
6170512317SGreg Clayton       break;
62dbc6c0bbSGreg Clayton #endif
6370512317SGreg Clayton     default:
6470512317SGreg Clayton       break;
6570512317SGreg Clayton     }
6670512317SGreg Clayton   }
67015d818bSTodd Fiala 
680e92fbb5SPavel Labath   LLDB_LOG(log, "create = {0}", create);
69b9c1b51eSKate Stone   if (create) {
70615eb7e6SGreg Clayton     return PlatformSP(new PlatformLinux(false));
71015d818bSTodd Fiala   }
72615eb7e6SGreg Clayton   return PlatformSP();
73ecc11474SStephen Wilson }
74ecc11474SStephen Wilson 
75b9c1b51eSKate Stone ConstString PlatformLinux::GetPluginNameStatic(bool is_host) {
76b9c1b51eSKate Stone   if (is_host) {
7757abc5d6SGreg Clayton     static ConstString g_host_name(Platform::GetHostPlatformName());
7857abc5d6SGreg Clayton     return g_host_name;
79b9c1b51eSKate Stone   } else {
8057abc5d6SGreg Clayton     static ConstString g_remote_name("remote-linux");
8157abc5d6SGreg Clayton     return g_remote_name;
8257abc5d6SGreg Clayton   }
8328041352SGreg Clayton }
8428041352SGreg Clayton 
85b9c1b51eSKate Stone const char *PlatformLinux::GetPluginDescriptionStatic(bool is_host) {
8628041352SGreg Clayton   if (is_host)
8728041352SGreg Clayton     return "Local Linux user platform plug-in.";
8828041352SGreg Clayton   else
8928041352SGreg Clayton     return "Remote Linux user platform plug-in.";
90ecc11474SStephen Wilson }
91ecc11474SStephen Wilson 
92b9c1b51eSKate Stone ConstString PlatformLinux::GetPluginName() {
9357abc5d6SGreg Clayton   return GetPluginNameStatic(IsHost());
9457abc5d6SGreg Clayton }
9557abc5d6SGreg Clayton 
96b9c1b51eSKate Stone void PlatformLinux::Initialize() {
973c4f89d7STamas Berghammer   PlatformPOSIX::Initialize();
983c4f89d7STamas Berghammer 
99b9c1b51eSKate Stone   if (g_initialize_count++ == 0) {
1001c6a1ea9STamas Berghammer #if defined(__linux__) && !defined(__ANDROID__)
10128041352SGreg Clayton     PlatformSP default_platform_sp(new PlatformLinux(true));
10213b18261SZachary Turner     default_platform_sp->SetSystemArchitecture(HostInfo::GetArchitecture());
103615eb7e6SGreg Clayton     Platform::SetHostPlatform(default_platform_sp);
10428041352SGreg Clayton #endif
105b9c1b51eSKate Stone     PluginManager::RegisterPlugin(
106b9c1b51eSKate Stone         PlatformLinux::GetPluginNameStatic(false),
10728041352SGreg Clayton         PlatformLinux::GetPluginDescriptionStatic(false),
108d65ac229SPavel Labath         PlatformLinux::CreateInstance, nullptr);
109ecc11474SStephen Wilson   }
110e996fd30SGreg Clayton }
111e996fd30SGreg Clayton 
112b9c1b51eSKate Stone void PlatformLinux::Terminate() {
113b9c1b51eSKate Stone   if (g_initialize_count > 0) {
114b9c1b51eSKate Stone     if (--g_initialize_count == 0) {
11528041352SGreg Clayton       PluginManager::UnregisterPlugin(PlatformLinux::CreateInstance);
116e996fd30SGreg Clayton     }
11728041352SGreg Clayton   }
1183c4f89d7STamas Berghammer 
1193c4f89d7STamas Berghammer   PlatformPOSIX::Terminate();
12028041352SGreg Clayton }
121e996fd30SGreg Clayton 
122e996fd30SGreg Clayton /// Default Constructor
123b9c1b51eSKate Stone PlatformLinux::PlatformLinux(bool is_host)
124b9c1b51eSKate Stone     : PlatformPOSIX(is_host) // This is the local host platform
125b9c1b51eSKate Stone {}
126e996fd30SGreg Clayton 
127222b937cSEugene Zelenko PlatformLinux::~PlatformLinux() = default;
128e996fd30SGreg Clayton 
129b9c1b51eSKate Stone bool PlatformLinux::GetSupportedArchitectureAtIndex(uint32_t idx,
130b9c1b51eSKate Stone                                                     ArchSpec &arch) {
131b9c1b51eSKate Stone   if (IsHost()) {
132e49b8e06SRobert Flack     ArchSpec hostArch = HostInfo::GetArchitecture(HostInfo::eArchKindDefault);
133b9c1b51eSKate Stone     if (hostArch.GetTriple().isOSLinux()) {
134b9c1b51eSKate Stone       if (idx == 0) {
135e49b8e06SRobert Flack         arch = hostArch;
136e49b8e06SRobert Flack         return arch.IsValid();
137b9c1b51eSKate Stone       } else if (idx == 1) {
13805097246SAdrian Prantl         // If the default host architecture is 64-bit, look for a 32-bit
13905097246SAdrian Prantl         // variant
140b9c1b51eSKate Stone         if (hostArch.IsValid() && hostArch.GetTriple().isArch64Bit()) {
141e49b8e06SRobert Flack           arch = HostInfo::GetArchitecture(HostInfo::eArchKind32);
142e49b8e06SRobert Flack           return arch.IsValid();
143e49b8e06SRobert Flack         }
144e49b8e06SRobert Flack       }
145e49b8e06SRobert Flack     }
146b9c1b51eSKate Stone   } else {
147e49b8e06SRobert Flack     if (m_remote_platform_sp)
148e49b8e06SRobert Flack       return m_remote_platform_sp->GetSupportedArchitectureAtIndex(idx, arch);
149bb1e283cSTed Woodward 
150bb1e283cSTed Woodward     llvm::Triple triple;
151bb1e283cSTed Woodward     // Set the OS to linux
152bb1e283cSTed Woodward     triple.setOS(llvm::Triple::Linux);
153bb1e283cSTed Woodward     // Set the architecture
154b9c1b51eSKate Stone     switch (idx) {
155b9c1b51eSKate Stone     case 0:
156b9c1b51eSKate Stone       triple.setArchName("x86_64");
157b9c1b51eSKate Stone       break;
158b9c1b51eSKate Stone     case 1:
159b9c1b51eSKate Stone       triple.setArchName("i386");
160b9c1b51eSKate Stone       break;
161b9c1b51eSKate Stone     case 2:
162b9c1b51eSKate Stone       triple.setArchName("arm");
163b9c1b51eSKate Stone       break;
164b9c1b51eSKate Stone     case 3:
165b9c1b51eSKate Stone       triple.setArchName("aarch64");
166b9c1b51eSKate Stone       break;
167b9c1b51eSKate Stone     case 4:
168b9c1b51eSKate Stone       triple.setArchName("mips64");
169b9c1b51eSKate Stone       break;
170b9c1b51eSKate Stone     case 5:
171b9c1b51eSKate Stone       triple.setArchName("hexagon");
172b9c1b51eSKate Stone       break;
173b9c1b51eSKate Stone     case 6:
174b9c1b51eSKate Stone       triple.setArchName("mips");
175b9c1b51eSKate Stone       break;
176b9c1b51eSKate Stone     case 7:
177b9c1b51eSKate Stone       triple.setArchName("mips64el");
178b9c1b51eSKate Stone       break;
179b9c1b51eSKate Stone     case 8:
180b9c1b51eSKate Stone       triple.setArchName("mipsel");
181b9c1b51eSKate Stone       break;
182b9c1b51eSKate Stone     case 9:
183b9c1b51eSKate Stone       triple.setArchName("s390x");
184b9c1b51eSKate Stone       break;
185b9c1b51eSKate Stone     default:
186b9c1b51eSKate Stone       return false;
187bb1e283cSTed Woodward     }
188b9c1b51eSKate Stone     // Leave the vendor as "llvm::Triple:UnknownVendor" and don't specify the
18905097246SAdrian Prantl     // vendor by calling triple.SetVendorName("unknown") so that it is a
19005097246SAdrian Prantl     // "unspecified unknown". This means when someone calls
19105097246SAdrian Prantl     // triple.GetVendorName() it will return an empty string which indicates
19205097246SAdrian Prantl     // that the vendor can be set when two architectures are merged
193bb1e283cSTed Woodward 
194bb1e283cSTed Woodward     // Now set the triple into "arch" and return true
195bb1e283cSTed Woodward     arch.SetTriple(triple);
196bb1e283cSTed Woodward     return true;
197e49b8e06SRobert Flack   }
198e996fd30SGreg Clayton   return false;
199e996fd30SGreg Clayton }
200ecc11474SStephen Wilson 
201b9c1b51eSKate Stone void PlatformLinux::GetStatus(Stream &strm) {
2023be69dacSDaniel Malea   Platform::GetStatus(strm);
203ecc11474SStephen Wilson 
2043011d55fSJonas Devlieghere #if LLDB_ENABLE_POSIX
205b743a803SStephane Sezer   // Display local kernel information only when we are running in host mode.
20605097246SAdrian Prantl   // Otherwise, we would end up printing non-Linux information (when running on
20705097246SAdrian Prantl   // Mac OS for example).
208b9c1b51eSKate Stone   if (IsHost()) {
209b2f1fb29SVirgile Bello     struct utsname un;
210b2f1fb29SVirgile Bello 
2113be69dacSDaniel Malea     if (uname(&un))
2123be69dacSDaniel Malea       return;
2133be69dacSDaniel Malea 
2143be69dacSDaniel Malea     strm.Printf("    Kernel: %s\n", un.sysname);
2153be69dacSDaniel Malea     strm.Printf("   Release: %s\n", un.release);
2163be69dacSDaniel Malea     strm.Printf("   Version: %s\n", un.version);
217b743a803SStephane Sezer   }
218b2f1fb29SVirgile Bello #endif
219ecc11474SStephen Wilson }
220ecc11474SStephen Wilson 
221348fb385STodd Fiala int32_t
222b9c1b51eSKate Stone PlatformLinux::GetResumeCountForLaunchInfo(ProcessLaunchInfo &launch_info) {
223348fb385STodd Fiala   int32_t resume_count = 0;
22428041352SGreg Clayton 
225348fb385STodd Fiala   // Always resume past the initial stop when we use eLaunchFlagDebug
226b9c1b51eSKate Stone   if (launch_info.GetFlags().Test(eLaunchFlagDebug)) {
227348fb385STodd Fiala     // Resume past the stop for the final exec into the true inferior.
228348fb385STodd Fiala     ++resume_count;
229348fb385STodd Fiala   }
230015d818bSTodd Fiala 
231348fb385STodd Fiala   // If we're not launching a shell, we're done.
23210687b0eSZachary Turner   const FileSpec &shell = launch_info.GetShell();
23310687b0eSZachary Turner   if (!shell)
234348fb385STodd Fiala     return resume_count;
235348fb385STodd Fiala 
23610687b0eSZachary Turner   std::string shell_string = shell.GetPath();
237348fb385STodd Fiala   // We're in a shell, so for sure we have to resume past the shell exec.
238348fb385STodd Fiala   ++resume_count;
239348fb385STodd Fiala 
240348fb385STodd Fiala   // Figure out what shell we're planning on using.
24110687b0eSZachary Turner   const char *shell_name = strrchr(shell_string.c_str(), '/');
242248a1305SKonrad Kleine   if (shell_name == nullptr)
24310687b0eSZachary Turner     shell_name = shell_string.c_str();
24428041352SGreg Clayton   else
245348fb385STodd Fiala     shell_name++;
246348fb385STodd Fiala 
247b9c1b51eSKate Stone   if (strcmp(shell_name, "csh") == 0 || strcmp(shell_name, "tcsh") == 0 ||
248b9c1b51eSKate Stone       strcmp(shell_name, "zsh") == 0 || strcmp(shell_name, "sh") == 0) {
249348fb385STodd Fiala     // These shells seem to re-exec themselves.  Add another resume.
250348fb385STodd Fiala     ++resume_count;
251ecc11474SStephen Wilson   }
25213e8e1c3SJohnny Chen 
253348fb385STodd Fiala   return resume_count;
254348fb385STodd Fiala }
255348fb385STodd Fiala 
256b9c1b51eSKate Stone bool PlatformLinux::CanDebugProcess() {
257b9c1b51eSKate Stone   if (IsHost()) {
258b36f9178SPavel Labath     return true;
259b9c1b51eSKate Stone   } else {
260015d818bSTodd Fiala     // If we're connected, we can debug.
261015d818bSTodd Fiala     return IsConnected();
262015d818bSTodd Fiala   }
263348fb385STodd Fiala }
264015d818bSTodd Fiala 
265b9c1b51eSKate Stone // For local debugging, Linux will override the debug logic to use llgs-launch
26605097246SAdrian Prantl // rather than lldb-launch, llgs-attach.  This differs from current lldb-
26705097246SAdrian Prantl // launch, debugserver-attach approach on MacOSX.
26813e8e1c3SJohnny Chen lldb::ProcessSP
269b9c1b51eSKate Stone PlatformLinux::DebugProcess(ProcessLaunchInfo &launch_info, Debugger &debugger,
270b9c1b51eSKate Stone                             Target *target, // Can be NULL, if NULL create a new
271b9c1b51eSKate Stone                                             // target, else use existing one
27297206d57SZachary Turner                             Status &error) {
273db264a6dSTamas Berghammer   Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PLATFORM));
2740e92fbb5SPavel Labath   LLDB_LOG(log, "target {0}", target);
27528041352SGreg Clayton 
276348fb385STodd Fiala   // If we're a remote host, use standard behavior from parent class.
277348fb385STodd Fiala   if (!IsHost())
2788012cadbSGreg Clayton     return PlatformPOSIX::DebugProcess(launch_info, debugger, target, error);
279348fb385STodd Fiala 
280348fb385STodd Fiala   //
281b9c1b51eSKate Stone   // For local debugging, we'll insist on having ProcessGDBRemote create the
282b9c1b51eSKate Stone   // process.
283348fb385STodd Fiala   //
284348fb385STodd Fiala 
285348fb385STodd Fiala   ProcessSP process_sp;
286348fb385STodd Fiala 
287348fb385STodd Fiala   // Make sure we stop at the entry point
288348fb385STodd Fiala   launch_info.GetFlags().Set(eLaunchFlagDebug);
289348fb385STodd Fiala 
290348fb385STodd Fiala   // We always launch the process we are going to debug in a separate process
29105097246SAdrian Prantl   // group, since then we can handle ^C interrupts ourselves w/o having to
29205097246SAdrian Prantl   // worry about the target getting them as well.
293348fb385STodd Fiala   launch_info.SetLaunchInSeparateProcessGroup(true);
294348fb385STodd Fiala 
295348fb385STodd Fiala   // Ensure we have a target.
296b9c1b51eSKate Stone   if (target == nullptr) {
2970e92fbb5SPavel Labath     LLDB_LOG(log, "creating new target");
298348fb385STodd Fiala     TargetSP new_target_sp;
299f9a07e9fSJonas Devlieghere     error = debugger.GetTargetList().CreateTarget(
300f9a07e9fSJonas Devlieghere         debugger, "", "", eLoadDependentsNo, nullptr, new_target_sp);
301b9c1b51eSKate Stone     if (error.Fail()) {
3020e92fbb5SPavel Labath       LLDB_LOG(log, "failed to create new target: {0}", error);
303348fb385STodd Fiala       return process_sp;
304348fb385STodd Fiala     }
305348fb385STodd Fiala 
30628041352SGreg Clayton     target = new_target_sp.get();
307b9c1b51eSKate Stone     if (!target) {
308348fb385STodd Fiala       error.SetErrorString("CreateTarget() returned nullptr");
3090e92fbb5SPavel Labath       LLDB_LOG(log, "error: {0}", error);
310348fb385STodd Fiala       return process_sp;
311348fb385STodd Fiala     }
312348fb385STodd Fiala   }
313348fb385STodd Fiala 
314348fb385STodd Fiala   // Mark target as currently selected target.
31528041352SGreg Clayton   debugger.GetTargetList().SetSelectedTarget(target);
31628041352SGreg Clayton 
317348fb385STodd Fiala   // Now create the gdb-remote process.
3180e92fbb5SPavel Labath   LLDB_LOG(log, "having target create process with gdb-remote plugin");
319cb8c6998SPavel Labath   process_sp =
320cb8c6998SPavel Labath       target->CreateProcess(launch_info.GetListener(), "gdb-remote", nullptr);
32128041352SGreg Clayton 
322b9c1b51eSKate Stone   if (!process_sp) {
323348fb385STodd Fiala     error.SetErrorString("CreateProcess() failed for gdb-remote process");
3240e92fbb5SPavel Labath     LLDB_LOG(log, "error: {0}", error);
325348fb385STodd Fiala     return process_sp;
326348fb385STodd Fiala   }
327348fb385STodd Fiala 
3280e92fbb5SPavel Labath   LLDB_LOG(log, "successfully created process");
329348fb385STodd Fiala   // Adjust launch for a hijacker.
330348fb385STodd Fiala   ListenerSP listener_sp;
331b9c1b51eSKate Stone   if (!launch_info.GetHijackListener()) {
3320e92fbb5SPavel Labath     LLDB_LOG(log, "setting up hijacker");
333b9c1b51eSKate Stone     listener_sp =
334b9c1b51eSKate Stone         Listener::MakeListener("lldb.PlatformLinux.DebugProcess.hijack");
335348fb385STodd Fiala     launch_info.SetHijackListener(listener_sp);
336583bbb1dSJim Ingham     process_sp->HijackProcessEvents(listener_sp);
337348fb385STodd Fiala   }
338348fb385STodd Fiala 
339348fb385STodd Fiala   // Log file actions.
340b9c1b51eSKate Stone   if (log) {
3410e92fbb5SPavel Labath     LLDB_LOG(log, "launching process with the following file actions:");
342348fb385STodd Fiala     StreamString stream;
343348fb385STodd Fiala     size_t i = 0;
344348fb385STodd Fiala     const FileAction *file_action;
345b9c1b51eSKate Stone     while ((file_action = launch_info.GetFileActionAtIndex(i++)) != nullptr) {
346348fb385STodd Fiala       file_action->Dump(stream);
3470e92fbb5SPavel Labath       LLDB_LOG(log, "{0}", stream.GetData());
348348fb385STodd Fiala       stream.Clear();
349348fb385STodd Fiala     }
350348fb385STodd Fiala   }
351348fb385STodd Fiala 
352348fb385STodd Fiala   // Do the launch.
353348fb385STodd Fiala   error = process_sp->Launch(launch_info);
354b9c1b51eSKate Stone   if (error.Success()) {
355348fb385STodd Fiala     // Handle the hijacking of process events.
356b9c1b51eSKate Stone     if (listener_sp) {
357b9c1b51eSKate Stone       const StateType state = process_sp->WaitForProcessToStop(
358248a1305SKonrad Kleine           llvm::None, nullptr, false, listener_sp);
359348fb385STodd Fiala 
3600e92fbb5SPavel Labath       LLDB_LOG(log, "pid {0} state {0}", process_sp->GetID(), state);
361348fb385STodd Fiala     }
362348fb385STodd Fiala 
363b9c1b51eSKate Stone     // Hook up process PTY if we have one (which we should for local debugging
364b9c1b51eSKate Stone     // with llgs).
365348fb385STodd Fiala     int pty_fd = launch_info.GetPTY().ReleaseMasterFileDescriptor();
36607d6f881SPavel Labath     if (pty_fd != PseudoTerminal::invalid_fd) {
367348fb385STodd Fiala       process_sp->SetSTDIOFileDescriptor(pty_fd);
3680e92fbb5SPavel Labath       LLDB_LOG(log, "hooked up STDIO pty to process");
3690e92fbb5SPavel Labath     } else
3700e92fbb5SPavel Labath       LLDB_LOG(log, "not using process STDIO pty");
371b9c1b51eSKate Stone   } else {
3720e92fbb5SPavel Labath     LLDB_LOG(log, "process launch failed: {0}", error);
373b9c1b51eSKate Stone     // FIXME figure out appropriate cleanup here.  Do we delete the target? Do
374b9c1b51eSKate Stone     // we delete the process?  Does our caller do that?
37528041352SGreg Clayton   }
376348fb385STodd Fiala 
37728041352SGreg Clayton   return process_sp;
37813e8e1c3SJohnny Chen }
3792094dbf4SJason Molenda 
380b9c1b51eSKate Stone void PlatformLinux::CalculateTrapHandlerSymbolNames() {
3812094dbf4SJason Molenda   m_trap_handlers.push_back(ConstString("_sigtramp"));
3823fd917d8SJoseph Tremoulet   m_trap_handlers.push_back(ConstString("__kernel_rt_sigreturn"));
3833fd917d8SJoseph Tremoulet   m_trap_handlers.push_back(ConstString("__restore_rt"));
3842094dbf4SJason Molenda }
385af245d11STodd Fiala 
38637c40af7SEd Maste MmapArgList PlatformLinux::GetMmapArgumentList(const ArchSpec &arch,
38737c40af7SEd Maste                                                addr_t addr, addr_t length,
38837c40af7SEd Maste                                                unsigned prot, unsigned flags,
38937c40af7SEd Maste                                                addr_t fd, addr_t offset) {
39096ad3de5SRobert Flack   uint64_t flags_platform = 0;
391ddb93b63SFangrui Song   uint64_t map_anon = arch.IsMIPS() ? 0x800 : MAP_ANON;
392e0d8c422SMohit K. Bhakkad 
39396ad3de5SRobert Flack   if (flags & eMmapFlagsPrivate)
39496ad3de5SRobert Flack     flags_platform |= MAP_PRIVATE;
39596ad3de5SRobert Flack   if (flags & eMmapFlagsAnon)
396e0d8c422SMohit K. Bhakkad     flags_platform |= map_anon;
39737c40af7SEd Maste 
39837c40af7SEd Maste   MmapArgList args({addr, length, prot, flags_platform, fd, offset});
39937c40af7SEd Maste   return args;
40096ad3de5SRobert Flack }
4016e25aeeaSEnrico Granata 
402