1
1
/* General utility routines for GDB, the GNU debugger.
3
Copyright (C) 1986, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995,
4
1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006
3
Copyright (C) 1986, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996,
4
1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007
5
5
Free Software Foundation, Inc.
7
7
This file is part of GDB.
9
9
This program is free software; you can redistribute it and/or modify
10
10
it under the terms of the GNU General Public License as published by
11
the Free Software Foundation; either version 2 of the License, or
11
the Free Software Foundation; either version 3 of the License, or
12
12
(at your option) any later version.
14
14
This program is distributed in the hope that it will be useful,
17
17
GNU General Public License for more details.
19
19
You should have received a copy of the GNU General Public License
20
along with this program; if not, write to the Free Software
21
Foundation, Inc., 51 Franklin Street, Fifth Floor,
22
Boston, MA 02110-1301, USA. */
20
along with this program. If not, see <http://www.gnu.org/licenses/>. */
25
23
#include "gdb_assert.h"
909
/* Control C comes here */
911
request_quit (int signo)
914
/* Restore the signal handler. Harmless with BSD-style signals,
915
needed for System V-style signals. */
916
signal (signo, request_quit);
922
908
/* Called when a memory allocation fails, with the number of bytes of
923
909
memory requested in SIZE. */
2456
static void pagination_on_command (char *arg, int from_tty);
2458
2442
pagination_on_command (char *arg, int from_tty)
2460
2444
pagination_enabled = 1;
2463
static void pagination_on_command (char *arg, int from_tty);
2465
2448
pagination_off_command (char *arg, int from_tty)
2551
2534
strlen_paddr (void)
2553
return (TARGET_ADDR_BIT / 8 * 2);
2536
return (gdbarch_addr_bit (current_gdbarch) / 8 * 2);
2557
2540
paddr (CORE_ADDR addr)
2559
return phex (addr, TARGET_ADDR_BIT / 8);
2542
return phex (addr, gdbarch_addr_bit (current_gdbarch) / 8);
2563
2546
paddr_nz (CORE_ADDR addr)
2565
return phex_nz (addr, TARGET_ADDR_BIT / 8);
2548
return phex_nz (addr, gdbarch_addr_bit (current_gdbarch) / 8);
2574
2557
when it won't occur. */
2575
2558
/* NOTE: This assumes that the significant address information is
2576
2559
kept in the least significant bits of ADDR - the upper bits were
2577
either zero or sign extended. Should ADDRESS_TO_POINTER() or
2560
either zero or sign extended. Should gdbarch_address_to_pointer or
2578
2561
some ADDRESS_TO_PRINTABLE() be used to do the conversion? */
2580
int addr_bit = TARGET_ADDR_BIT;
2563
int addr_bit = gdbarch_addr_bit (current_gdbarch);
2582
2565
if (addr_bit < (sizeof (CORE_ADDR) * HOST_CHAR_BIT))
2583
2566
addr &= ((CORE_ADDR) 1 << addr_bit) - 1;
3197
/* Simple, portable version of dirname that does not modify its
3201
ldirname (const char *filename)
3203
const char *base = lbasename (filename);
3206
while (base > filename && IS_DIR_SEPARATOR (base[-1]))
3209
if (base == filename)
3212
dirname = xmalloc (base - filename + 2);
3213
memcpy (dirname, filename, base - filename);
3215
/* On DOS based file systems, convert "d:foo" to "d:.", so that we
3216
create "d:./bar" later instead of the (different) "d:/bar". */
3217
if (base - filename == 2 && IS_ABSOLUTE_PATH (base)
3218
&& !IS_DIR_SEPARATOR (filename[0]))
3219
dirname[base++ - filename] = '.';
3221
dirname[base - filename] = '\0';