Path: blob/master/src/jdk.hotspot.agent/linux/native/libsaproc/libproc.h
41149 views
/*1* Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22*/2324#ifndef _LIBPROC_H_25#define _LIBPROC_H_2627#include <jni.h>28#include <unistd.h>29#include <stdint.h>3031#include <sys/procfs.h>32#include <sys/ptrace.h>333435#if defined(ppc64) || defined(ppc64le)36#include <asm/ptrace.h>37#define user_regs_struct pt_regs38#endif39#if defined(aarch64) || defined(arm64)40#include <asm/ptrace.h>41#define user_regs_struct user_pt_regs42#elif defined(arm)43#include <asm/ptrace.h>44#define user_regs_struct pt_regs45#endif4647// This C bool type must be int for compatibility with Linux calls and48// it would be a mistake to equivalence it to C++ bool on many platforms49#ifndef __cplusplus50typedef int bool;51#define true 152#define false 053#endif5455struct ps_prochandle;56struct lib_info;5758#ifdef __cplusplus59extern "C" {60#endif6162// attach to a process63JNIEXPORT struct ps_prochandle* JNICALL64Pgrab(pid_t pid, char* err_buf, size_t err_buf_len);6566// attach to a core dump67JNIEXPORT struct ps_prochandle* JNICALL68Pgrab_core(const char* execfile, const char* corefile);6970// release a process or core71JNIEXPORT void JNICALL72Prelease(struct ps_prochandle* ph);7374// functions not directly available in Solaris libproc7576// initialize libproc (call this only once per app)77// pass true to make library verbose78JNIEXPORT bool JNICALL79init_libproc(bool verbose);8081// get number of threads82int get_num_threads(struct ps_prochandle* ph);8384// get lwp_id of n'th thread85lwpid_t get_lwp_id(struct ps_prochandle* ph, int index);8687// get regs for a given lwp88bool get_lwp_regs(struct ps_prochandle* ph, lwpid_t lid, struct user_regs_struct* regs);8990// get number of shared objects91int get_num_libs(struct ps_prochandle* ph);9293// get name of n'th lib94const char* get_lib_name(struct ps_prochandle* ph, int index);9596// get base of lib97uintptr_t get_lib_base(struct ps_prochandle* ph, int index);9899// get address range of lib100void get_lib_addr_range(struct ps_prochandle* ph, int index, uintptr_t* base, uintptr_t* memsz);101102// returns true if given library is found in lib list103bool find_lib(struct ps_prochandle* ph, const char *lib_name);104105// returns lib which contains pc106struct lib_info *find_lib_by_address(struct ps_prochandle* ph, uintptr_t pc);107108// symbol lookup109uintptr_t lookup_symbol(struct ps_prochandle* ph, const char* object_name,110const char* sym_name);111112// address->nearest symbol lookup. return NULL for no symbol113const char* symbol_for_pc(struct ps_prochandle* ph, uintptr_t addr, uintptr_t* poffset);114115struct ps_prochandle* get_proc_handle(JNIEnv* env, jobject this_obj);116117void throw_new_debugger_exception(JNIEnv* env, const char* errMsg);118119#ifdef __cplusplus120}121#endif122123#endif //__LIBPROC_H_124125126