DNB.h revision bd666017403e102e0ca435d6da585ff979f83598
1ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com//===-- DNB.h ---------------------------------------------------*- C++ -*-===// 2a6260ff5696e3ae45f295463eaeada2cd75a8b85reed@android.com// 3ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com// The LLVM Compiler Infrastructure 4a6260ff5696e3ae45f295463eaeada2cd75a8b85reed@android.com// 5ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com// This file is distributed under the University of Illinois Open Source 6ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com// License. See LICENSE.TXT for details. 7a6260ff5696e3ae45f295463eaeada2cd75a8b85reed@android.com// 88a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com//===----------------------------------------------------------------------===// 9ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com// 1064a0ec36555352ec31aa7c5a7630a5d042b010badjsollen@google.com// Created by Greg Clayton on 3/23/07. 118b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org// 128b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org//===----------------------------------------------------------------------===// 138a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 148a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#ifndef __DNB_h__ 158a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#define __DNB_h__ 162999f789c7e66a31066414f4b8fffb3148b677c5reed@google.com 172999f789c7e66a31066414f4b8fffb3148b677c5reed@google.com#include "DNBDefs.h" 182999f789c7e66a31066414f4b8fffb3148b677c5reed@google.com#include <mach/thread_info.h> 19f9ab99aaade8c451c0e9309b4c61a448373019e3weita@google.com 200a6151d66cc32d91eca037c91e557158cf8a2be2reed@google.com#ifdef __cplusplus 21f9ab99aaade8c451c0e9309b4c61a448373019e3weita@google.comextern "C" { 22f9ab99aaade8c451c0e9309b4c61a448373019e3weita@google.com#endif 23a6260ff5696e3ae45f295463eaeada2cd75a8b85reed@android.com 24a6260ff5696e3ae45f295463eaeada2cd75a8b85reed@android.com#define DNB_EXPORT __attribute__((visibility("default"))) 25f9ab99aaade8c451c0e9309b4c61a448373019e3weita@google.com 26f9ab99aaade8c451c0e9309b4c61a448373019e3weita@google.comtypedef bool (*DNBShouldCancelCallback) (void *); 278a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 288a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comvoid DNBInitialize (); 298a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comvoid DNBTerminate (); 308a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 310a6151d66cc32d91eca037c91e557158cf8a2be2reed@google.comnub_bool_t DNBSetArchitecture (const char *arch); 320a6151d66cc32d91eca037c91e557158cf8a2be2reed@google.com 338a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com//---------------------------------------------------------------------- 340a6151d66cc32d91eca037c91e557158cf8a2be2reed@google.com// Process control 350a6151d66cc32d91eca037c91e557158cf8a2be2reed@google.com//---------------------------------------------------------------------- 360a6151d66cc32d91eca037c91e557158cf8a2be2reed@google.comnub_process_t DNBProcessLaunch (const char *path, char const *argv[], const char *envp[], const char *stdio_path, bool no_stdio, nub_launch_flavor_t launch_flavor, int disable_aslr, char *err_str, size_t err_len) DNB_EXPORT; 378a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comnub_process_t DNBProcessAttach (nub_process_t pid, struct timespec *timeout, char *err_str, size_t err_len) DNB_EXPORT; 380a6151d66cc32d91eca037c91e557158cf8a2be2reed@google.comnub_process_t DNBProcessAttachByName (const char *name, struct timespec *timeout, char *err_str, size_t err_len) DNB_EXPORT; 398a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comnub_process_t DNBProcessAttachWait (const char *wait_name, nub_launch_flavor_t launch_flavor, struct timespec *timeout, useconds_t interval, char *err_str, size_t err_len, DNBShouldCancelCallback should_cancel = NULL, void *callback_data = NULL) DNB_EXPORT; 400a6151d66cc32d91eca037c91e557158cf8a2be2reed@google.com// Resume a process with exact instructions on what to do with each thread: 41f9ab99aaade8c451c0e9309b4c61a448373019e3weita@google.com// - If no thread actions are supplied (actions is NULL or num_actions is zero), 428a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com// then all threads are continued. 43a6260ff5696e3ae45f295463eaeada2cd75a8b85reed@android.com// - If any thread actions are supplied, then each thread will do as it is told 44a6260ff5696e3ae45f295463eaeada2cd75a8b85reed@android.com// by the action. A default actions for any threads that don't have an 45f9ab99aaade8c451c0e9309b4c61a448373019e3weita@google.com// explicit thread action can be made by making a thread action with a tid of 460a6151d66cc32d91eca037c91e557158cf8a2be2reed@google.com// INVALID_NUB_THREAD. If there is no default action, those threads will 47f9ab99aaade8c451c0e9309b4c61a448373019e3weita@google.com// remain stopped. 488a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comnub_bool_t DNBProcessResume (nub_process_t pid, const DNBThreadResumeAction *actions, size_t num_actions) DNB_EXPORT; 498a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comnub_bool_t DNBProcessHalt (nub_process_t pid) DNB_EXPORT; 508a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comnub_bool_t DNBProcessDetach (nub_process_t pid) DNB_EXPORT; 518a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comnub_bool_t DNBProcessSignal (nub_process_t pid, int signal) DNB_EXPORT; 528a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comnub_bool_t DNBProcessKill (nub_process_t pid) DNB_EXPORT; 538a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comnub_size_t DNBProcessMemoryRead (nub_process_t pid, nub_addr_t addr, nub_size_t size, void *buf) DNB_EXPORT; 548a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comnub_size_t DNBProcessMemoryWrite (nub_process_t pid, nub_addr_t addr, nub_size_t size, const void *buf) DNB_EXPORT; 558a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comnub_addr_t DNBProcessMemoryAllocate (nub_process_t pid, nub_size_t size, uint32_t permissions) DNB_EXPORT; 568a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comnub_bool_t DNBProcessMemoryDeallocate (nub_process_t pid, nub_addr_t addr) DNB_EXPORT; 578a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com//---------------------------------------------------------------------- 588a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com// Process status 598a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com//---------------------------------------------------------------------- 608a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comnub_bool_t DNBProcessIsAlive (nub_process_t pid) DNB_EXPORT; 610a6151d66cc32d91eca037c91e557158cf8a2be2reed@google.comnub_state_t DNBProcessGetState (nub_process_t pid) DNB_EXPORT; 628a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comnub_bool_t DNBProcessGetExitStatus (nub_process_t pid, int *status) DNB_EXPORT; 63c9ab987efcb7e8b69237d565f73c28c137610232djsollen@google.comnub_bool_t DNBProcessSetExitStatus (nub_process_t pid, int status) DNB_EXPORT; 648a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comnub_size_t DNBProcessGetNumThreads (nub_process_t pid) DNB_EXPORT; 658a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comnub_thread_t DNBProcessGetCurrentThread (nub_process_t pid) DNB_EXPORT; 668a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comnub_thread_t DNBProcessSetCurrentThread (nub_process_t pid, nub_thread_t tid) DNB_EXPORT; 678a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comnub_thread_t DNBProcessGetThreadAtIndex (nub_process_t pid, nub_size_t thread_idx) DNB_EXPORT; 680a6151d66cc32d91eca037c91e557158cf8a2be2reed@google.comnub_addr_t DNBProcessGetSharedLibraryInfoAddress (nub_process_t pid) DNB_EXPORT; 690a6151d66cc32d91eca037c91e557158cf8a2be2reed@google.comnub_bool_t DNBProcessSharedLibrariesUpdated (nub_process_t pid) DNB_EXPORT; 700a6151d66cc32d91eca037c91e557158cf8a2be2reed@google.comnub_size_t DNBProcessGetSharedLibraryInfo (nub_process_t pid, nub_bool_t only_changed, DNBExecutableImageInfo **image_infos) DNB_EXPORT; 718a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comnub_bool_t DNBProcessSetNameToAddressCallback (nub_process_t pid, DNBCallbackNameToAddress callback, void *baton) DNB_EXPORT; 720a6151d66cc32d91eca037c91e557158cf8a2be2reed@google.comnub_bool_t DNBProcessSetSharedLibraryInfoCallback (nub_process_t pid, DNBCallbackCopyExecutableImageInfos callback, void *baton) DNB_EXPORT; 738a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comnub_addr_t DNBProcessLookupAddress (nub_process_t pid, const char *name, const char *shlib) DNB_EXPORT; 748a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comnub_size_t DNBProcessGetAvailableSTDOUT (nub_process_t pid, char *buf, nub_size_t buf_size) DNB_EXPORT; 750a6151d66cc32d91eca037c91e557158cf8a2be2reed@google.comnub_size_t DNBProcessGetAvailableSTDERR (nub_process_t pid, char *buf, nub_size_t buf_size) DNB_EXPORT; 76daf9e11adea46246c825cf621781157da6ca4aeadjsollennub_size_t DNBProcessGetStopCount (nub_process_t pid) DNB_EXPORT; 77daf9e11adea46246c825cf621781157da6ca4aeadjsollen//---------------------------------------------------------------------- 78daf9e11adea46246c825cf621781157da6ca4aeadjsollen// Process executable and arguments 79daf9e11adea46246c825cf621781157da6ca4aeadjsollen//---------------------------------------------------------------------- 800a6151d66cc32d91eca037c91e557158cf8a2be2reed@google.comconst char * DNBProcessGetExecutablePath (nub_process_t pid) DNB_EXPORT; 810a6151d66cc32d91eca037c91e557158cf8a2be2reed@google.comconst char * DNBProcessGetArgumentAtIndex (nub_process_t pid, nub_size_t idx) DNB_EXPORT; 828a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comnub_size_t DNBProcessGetArgumentCount (nub_process_t pid) DNB_EXPORT; 838a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 848a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com//---------------------------------------------------------------------- 858a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com// Process events 868a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com//---------------------------------------------------------------------- 878a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comnub_event_t DNBProcessWaitForEvents (nub_process_t pid, nub_event_t event_mask, bool wait_for_set, struct timespec* timeout) DNB_EXPORT; 888a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comvoid DNBProcessResetEvents (nub_process_t pid, nub_event_t event_mask) DNB_EXPORT; 898a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comvoid DNBProcessInterruptEvents (nub_process_t pid) DNB_EXPORT; 908b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org 918a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com//---------------------------------------------------------------------- 928a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com// Thread functions 938a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com//---------------------------------------------------------------------- 948a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comconst char * DNBThreadGetName (nub_process_t pid, nub_thread_t tid) DNB_EXPORT; 950a6151d66cc32d91eca037c91e557158cf8a2be2reed@google.comnub_bool_t DNBThreadGetIdentifierInfo (nub_process_t pid, nub_thread_t tid, thread_identifier_info_data_t *ident_info) DNB_EXPORT; 96c73dd5c6880739f26216f198c757028fd28df1a4djsollen@google.comnub_state_t DNBThreadGetState (nub_process_t pid, nub_thread_t tid) DNB_EXPORT; 97ef74fa189b738e13295d6a96f86a6e10223505a8commit-bot@chromium.orgnub_bool_t DNBThreadGetRegisterValueByID (nub_process_t pid, nub_thread_t tid, uint32_t set, uint32_t reg, DNBRegisterValue *value) DNB_EXPORT; 98ef74fa189b738e13295d6a96f86a6e10223505a8commit-bot@chromium.orgnub_bool_t DNBThreadSetRegisterValueByID (nub_process_t pid, nub_thread_t tid, uint32_t set, uint32_t reg, const DNBRegisterValue *value) DNB_EXPORT; 99ef74fa189b738e13295d6a96f86a6e10223505a8commit-bot@chromium.orgnub_size_t DNBThreadGetRegisterContext (nub_process_t pid, nub_thread_t tid, void *buf, size_t buf_len) DNB_EXPORT; 100ef74fa189b738e13295d6a96f86a6e10223505a8commit-bot@chromium.orgnub_size_t DNBThreadSetRegisterContext (nub_process_t pid, nub_thread_t tid, const void *buf, size_t buf_len) DNB_EXPORT; 101ef74fa189b738e13295d6a96f86a6e10223505a8commit-bot@chromium.orgnub_bool_t DNBThreadGetRegisterValueByName (nub_process_t pid, nub_thread_t tid, uint32_t set, const char *name, DNBRegisterValue *value) DNB_EXPORT; 102ef74fa189b738e13295d6a96f86a6e10223505a8commit-bot@chromium.orgnub_bool_t DNBThreadGetStopReason (nub_process_t pid, nub_thread_t tid, DNBThreadStopInfo *stop_info) DNB_EXPORT; 103ef74fa189b738e13295d6a96f86a6e10223505a8commit-bot@chromium.orgconst char * DNBThreadGetInfo (nub_process_t pid, nub_thread_t tid) DNB_EXPORT; 104ef74fa189b738e13295d6a96f86a6e10223505a8commit-bot@chromium.org//---------------------------------------------------------------------- 105ef74fa189b738e13295d6a96f86a6e10223505a8commit-bot@chromium.org// Breakpoint functions 10657313f6472684b14570562e43e84f5e2d6fcf278bsalomon@google.com//---------------------------------------------------------------------- 107c73dd5c6880739f26216f198c757028fd28df1a4djsollen@google.comnub_break_t DNBBreakpointSet (nub_process_t pid, nub_addr_t addr, nub_size_t size, nub_bool_t hardware) DNB_EXPORT; 108025128811219dc45fd99b6c4d1d14f833cf7a26ecommit-bot@chromium.orgnub_bool_t DNBBreakpointClear (nub_process_t pid, nub_break_t breakID) DNB_EXPORT; 10957313f6472684b14570562e43e84f5e2d6fcf278bsalomon@google.comnub_ssize_t DNBBreakpointGetHitCount (nub_process_t pid, nub_break_t breakID) DNB_EXPORT; 1108a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comnub_ssize_t DNBBreakpointGetIgnoreCount (nub_process_t pid, nub_break_t breakID) DNB_EXPORT; 1118a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comnub_bool_t DNBBreakpointSetIgnoreCount (nub_process_t pid, nub_break_t breakID, nub_size_t ignore_count) DNB_EXPORT; 1128b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.orgnub_bool_t DNBBreakpointSetCallback (nub_process_t pid, nub_break_t breakID, DNBCallbackBreakpointHit callback, void *baton) DNB_EXPORT; 1130a6151d66cc32d91eca037c91e557158cf8a2be2reed@google.comvoid DNBBreakpointPrint (nub_process_t pid, nub_break_t breakID) DNB_EXPORT; 114c73dd5c6880739f26216f198c757028fd28df1a4djsollen@google.com 1158a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com//---------------------------------------------------------------------- 116// Watchpoint functions 117//---------------------------------------------------------------------- 118nub_watch_t DNBWatchpointSet (nub_process_t pid, nub_addr_t addr, nub_size_t size, uint32_t watch_flags, nub_bool_t hardware) DNB_EXPORT; 119nub_bool_t DNBWatchpointClear (nub_process_t pid, nub_watch_t watchID) DNB_EXPORT; 120nub_ssize_t DNBWatchpointGetHitCount (nub_process_t pid, nub_watch_t watchID) DNB_EXPORT; 121nub_ssize_t DNBWatchpointGetIgnoreCount (nub_process_t pid, nub_watch_t watchID) DNB_EXPORT; 122nub_bool_t DNBWatchpointSetIgnoreCount (nub_process_t pid, nub_watch_t watchID, nub_size_t ignore_count) DNB_EXPORT; 123nub_bool_t DNBWatchpointSetCallback (nub_process_t pid, nub_watch_t watchID, DNBCallbackBreakpointHit callback, void *baton) DNB_EXPORT; 124void DNBWatchpointPrint (nub_process_t pid, nub_watch_t watchID) DNB_EXPORT; 125 126const DNBRegisterSetInfo * 127 DNBGetRegisterSetInfo (nub_size_t *num_reg_sets) DNB_EXPORT; 128nub_bool_t DNBGetRegisterInfoByName (const char *reg_name, DNBRegisterInfo* info) DNB_EXPORT; 129 130//---------------------------------------------------------------------- 131// Printf style formatting for printing values in the inferior memory 132// space and registers. 133//---------------------------------------------------------------------- 134nub_size_t DNBPrintf (nub_process_t pid, nub_thread_t tid, nub_addr_t addr, FILE *file, const char *format) DNB_EXPORT; 135 136//---------------------------------------------------------------------- 137// Other static nub information calls. 138//---------------------------------------------------------------------- 139const char * DNBStateAsString (nub_state_t state) DNB_EXPORT; 140nub_bool_t DNBResolveExecutablePath (const char *path, char *resolved_path, size_t resolved_path_size) DNB_EXPORT; 141 142#ifdef __cplusplus 143} 144#endif 145 146#endif 147