blob: 83523df831dbff1a15ff5dd92e4057ca6fe6c57e [file] [log] [blame]
jln@chromium.org80359652012-06-05 10:03:32 +09001// Copyright (c) 2012 The Chromium Authors. All rights reserved.
sgk@google.come1f4a242009-04-22 02:20:10 +09002// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
thestig@chromium.orgb6ba9432010-04-03 10:05:39 +09005#ifndef BASE_LINUX_UTIL_H_
6#define BASE_LINUX_UTIL_H_
sgk@google.come1f4a242009-04-22 02:20:10 +09007
8#include <stdint.h>
craig.schlenter@chromium.orgfd4599a2009-10-30 03:21:30 +09009#include <sys/types.h>
sgk@google.come1f4a242009-04-22 02:20:10 +090010
thestig@chromium.orga5a2b6e2009-07-17 14:55:51 +090011#include <string>
12
darin@chromium.orge585bed2011-08-06 00:34:00 +090013#include "base/base_export.h"
evan@chromium.org3e208892011-05-03 02:54:14 +090014
sgk@google.come1f4a242009-04-22 02:20:10 +090015namespace base {
16
mnissler@chromium.org8584b6d2010-08-26 17:55:22 +090017// This is declared here so the crash reporter can access the memory directly
18// in compromised context without going through the standard library.
darin@chromium.orge585bed2011-08-06 00:34:00 +090019BASE_EXPORT extern char g_linux_distro[];
mnissler@chromium.org8584b6d2010-08-26 17:55:22 +090020
brettw@google.comf4fe79b2011-01-01 02:18:50 +090021// Get the Linux Distro if we can, or return "Unknown".
darin@chromium.orge585bed2011-08-06 00:34:00 +090022BASE_EXPORT std::string GetLinuxDistro();
thestig@chromium.orga5a2b6e2009-07-17 14:55:51 +090023
mnissler@chromium.org8584b6d2010-08-26 17:55:22 +090024// Set the Linux Distro string.
darin@chromium.orge585bed2011-08-06 00:34:00 +090025BASE_EXPORT void SetLinuxDistro(const std::string& distro);
mnissler@chromium.org8584b6d2010-08-26 17:55:22 +090026
thestig@chromium.org44836d42010-07-17 04:28:17 +090027// For a given process |pid|, look through all its threads and find the first
28// thread with /proc/[pid]/task/[thread_id]/syscall whose first N bytes matches
29// |expected_data|, where N is the length of |expected_data|.
kmixter@chromium.orge406ed72011-06-21 13:21:06 +090030// Returns the thread id or -1 on error. If |syscall_supported| is
31// set to false the kernel does not support syscall in procfs.
darin@chromium.orge585bed2011-08-06 00:34:00 +090032BASE_EXPORT pid_t FindThreadIDWithSyscall(pid_t pid,
33 const std::string& expected_data,
34 bool* syscall_supported);
thestig@chromium.org44836d42010-07-17 04:28:17 +090035
sgk@google.come1f4a242009-04-22 02:20:10 +090036} // namespace base
37
thestig@chromium.orgb6ba9432010-04-03 10:05:39 +090038#endif // BASE_LINUX_UTIL_H_