hp.com!davidm | e9e4e5f | 2003-01-28 03:40:06 +0000 | [diff] [blame] | 1 | /* libunwind - a platform-independent unwind library |
| 2 | Copyright (C) 2003 Hewlett-Packard Co |
| 3 | Contributed by David Mosberger-Tang <davidm@hpl.hp.com> |
| 4 | |
| 5 | This file is part of libunwind. |
| 6 | |
| 7 | Permission is hereby granted, free of charge, to any person obtaining |
| 8 | a copy of this software and associated documentation files (the |
| 9 | "Software"), to deal in the Software without restriction, including |
| 10 | without limitation the rights to use, copy, modify, merge, publish, |
| 11 | distribute, sublicense, and/or sell copies of the Software, and to |
| 12 | permit persons to whom the Software is furnished to do so, subject to |
| 13 | the following conditions: |
| 14 | |
| 15 | The above copyright notice and this permission notice shall be |
| 16 | included in all copies or substantial portions of the Software. |
| 17 | |
| 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
| 19 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 20 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
| 21 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE |
| 22 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION |
| 23 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION |
| 24 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ |
| 25 | |
| 26 | #include "_UPT_internal.h" |
| 27 | |
| 28 | int |
| 29 | _UPT_access_mem (unw_addr_space_t as, unw_word_t addr, unw_word_t *val, |
| 30 | int write, void *arg) |
| 31 | { |
| 32 | struct UPT_info *ui = arg; |
| 33 | pid_t pid = ui->pid; |
| 34 | |
| 35 | errno = 0; |
| 36 | if (write) |
| 37 | { |
mostang.com!davidm | 1d8de85 | 2003-02-08 10:10:59 +0000 | [diff] [blame] | 38 | debug (100, "%s: mem[%lx] <- %lx\n", __FUNCTION__, addr, *val); |
mostang.com!davidm | 0456a08 | 2003-03-19 19:25:18 +0000 | [diff] [blame] | 39 | #ifdef HAVE_TTRACE |
| 40 | # warning No support for ttrace() yet. |
| 41 | #else |
hp.com!davidm | e9e4e5f | 2003-01-28 03:40:06 +0000 | [diff] [blame] | 42 | ptrace (PTRACE_POKEDATA, pid, addr, *val); |
| 43 | if (errno) |
| 44 | return -UNW_EINVAL; |
mostang.com!davidm | 0456a08 | 2003-03-19 19:25:18 +0000 | [diff] [blame] | 45 | #endif |
hp.com!davidm | e9e4e5f | 2003-01-28 03:40:06 +0000 | [diff] [blame] | 46 | } |
| 47 | else |
| 48 | { |
mostang.com!davidm | 0456a08 | 2003-03-19 19:25:18 +0000 | [diff] [blame] | 49 | #ifdef HAVE_TTRACE |
| 50 | # warning No support for ttrace() yet. |
| 51 | #else |
hp.com!davidm | e9e4e5f | 2003-01-28 03:40:06 +0000 | [diff] [blame] | 52 | *val = ptrace (PTRACE_PEEKDATA, pid, addr, 0); |
| 53 | if (errno) |
| 54 | return -UNW_EINVAL; |
mostang.com!davidm | 0456a08 | 2003-03-19 19:25:18 +0000 | [diff] [blame] | 55 | #endif |
hp.com!davidm | e9e4e5f | 2003-01-28 03:40:06 +0000 | [diff] [blame] | 56 | debug (100, "%s: mem[%lx] -> %lx\n", __FUNCTION__, addr, *val); |
| 57 | } |
| 58 | return 0; |
| 59 | } |