From: DJ Delorie <dj@delorie.com>
To: fnasser@cygnus.com
Cc: Eliz@is.elta.co.il, gdb-patches@sourceware.cygnus.com, shebs@cygnus.com
Subject: Re: Shell escape in the DJGPP port of GDB
Date: Fri, 20 Aug 1999 12:20:00 -0000 [thread overview]
Message-ID: <199908201917.PAA26278@envy.delorie.com> (raw)
In-Reply-To: <37BDA912.4AA1190D@cygnus.com>
DOS-based programs don't get a separate working directory per process;
the current working directory is a global resource. Thus, if the
child process changes the directory for itself, it changes the
directory for gdb also. Thus, the chdir() back to the original
directory is a safety for all dos-like environments.
In unix it should be completely unneeded, because unix itself isolates
such changes within the child process.
From dj@delorie.com Fri Aug 20 13:06:00 1999
From: DJ Delorie <dj@delorie.com>
To: fnasser@cygnus.com
Cc: Eliz@is.elta.co.il, gdb-patches@sourceware.cygnus.com, shebs@cygnus.com
Subject: Re: Shell escape in the DJGPP port of GDB
Date: Fri, 20 Aug 1999 13:06:00 -0000
Message-id: <199908202005.QAA26613@envy.delorie.com>
References: <37BDA912.4AA1190D@cygnus.com> <199908201917.PAA26278@envy.delorie.com> <37BDAD71.510A96A1@cygnus.com>
X-SW-Source: 1999-q3/msg00193.html
Content-length: 260
Oh, in that case, leaving it in for non-djgpp systems is OK as it only
sets the cwd to what gdb thinks the cwd is anyway. It's safe (but
wasteful) to run it on the CAN_FORK side too, for example. The ifdef
was probably just for performance on other systems.
From jtc@redback.com Fri Aug 20 16:38:00 1999
From: jtc@redback.com (J.T. Conklin)
To: gdb-patches@sourceware.cygnus.com
Subject: remote.c run-length encoding patch
Date: Fri, 20 Aug 1999 16:38:00 -0000
Message-id: <5mr9kyhvln.fsf@jtc.redbacknetworks.com>
X-SW-Source: 1999-q3/msg00194.html
Content-length: 4316
The Cisco remote protocol varient (notice that I didn't say mutant
remote protocol this time :-) uses two hex characters instead of a
ASCII encoding for the run length but is otherwise the same as the
standard protocol.
However, the code implementing the decoding is quite different for the
two encodings. The standard encoding is expanded as the packet is
read, while the Cisco varient reads the entire packet and then expands
it in place (actually it expands it to another buffer, and the copies
that buffer into the first). Unlike the code implementing the
standard encoding, the Cisco varient does not detect a packet that
would expand to larger than the buffer size, which could lead to
corruption within GDB.
In this patch, I decided to handle both encodings in the same manner.
--jtc
1999-08-20 J.T. Conklin <jtc@redback.com>
* remote.c (read_frame): expand cisco run-length encoding variant
inline as is done for the standard encoding.
(remote_cisco_expand): Removed.
Index: remote.c
===================================================================
RCS file: /home/jtc/CVSROOT/gdb/gdb/remote.c,v
retrieving revision 1.1.1.12
diff -c -r1.1.1.12 remote.c
*** remote.c 1999/08/11 04:07:51 1.1.1.12
--- remote.c 1999/08/20 22:35:48
***************
*** 3530,3562 ****
static int remote_cisco_mode;
- static void
- remote_cisco_expand (src, dest)
- char *src;
- char *dest;
- {
- int i;
- int repeat;
-
- do
- {
- if (*src == '*')
- {
- repeat = (fromhex (src[1]) << 4) + fromhex (src[2]);
- for (i = 0; i < repeat; i++)
- {
- *dest++ = *(src - 1);
- }
- src += 2;
- }
- else
- {
- *dest++ = *src;
- }
- }
- while (*src++);
- }
-
/* Come here after finding the start of the frame. Collect the rest
into BUF, verifying the checksum, length, and handling run-length
compression. Returns 0 on any error, 1 on success. */
--- 3530,3535 ----
***************
*** 3597,3612 ****
pktcsum |= fromhex (readchar (remote_timeout));
if (csum == pktcsum)
! {
! if (remote_cisco_mode) /* variant run-length-encoding */
! {
! char *tmp_buf = alloca (PBUFSIZ);
!
! remote_cisco_expand (buf, tmp_buf);
! strcpy (buf, tmp_buf);
! }
! return 1;
! }
if (remote_debug)
{
--- 3570,3576 ----
pktcsum |= fromhex (readchar (remote_timeout));
if (csum == pktcsum)
! return 1;
if (remote_debug)
{
***************
*** 3619,3645 ****
return 0;
}
case '*': /* Run length encoding */
! if (remote_cisco_mode == 0) /* variant run-length-encoding */
! {
! csum += c;
! c = readchar (remote_timeout);
! csum += c;
! c = c - ' ' + 3; /* Compute repeat count */
!
! if (c > 0 && c < 255 && bp + c - 1 < buf + PBUFSIZ - 1)
! {
! memset (bp, *(bp - 1), c);
! bp += c;
! continue;
! }
!
! *bp = '\0';
! printf_filtered ("Repeat count %d too large for buffer: ", c);
! puts_filtered (buf);
! puts_filtered ("\n");
! return 0;
! }
! /* else fall thru to treat like default */
default:
if (bp < buf + PBUFSIZ - 1)
{
--- 3583,3625 ----
return 0;
}
case '*': /* Run length encoding */
! {
! int repeat;
! csum += c;
!
! if (remote_cisco_mode == 0)
! {
! c = readchar (remote_timeout);
! csum += c;
! repeat = c - ' ' + 3; /* Compute repeat count */
! }
! else
! {
! /* Cisco's run-length encoding variant uses two
! hex chars to represent the repeat count. */
!
! c = readchar (remote_timeout);
! csum += c;
! repeat = fromhex (c) << 4;
! c = readchar (remote_timeout);
! csum += c;
! repeat += fromhex (c);
! }
!
! if (repeat > 0 && repeat <= 255
! && bp + repeat - 1 < buf + PBUFSIZ - 1)
! {
! memset (bp, *(bp - 1), repeat);
! bp += c;
! continue;
! }
!
! *bp = '\0';
! printf_filtered ("Repeat count %d too large for buffer: ", repeat);
! puts_filtered (buf);
! puts_filtered ("\n");
! return 0;
! }
default:
if (bp < buf + PBUFSIZ - 1)
{
--
J.T. Conklin
RedBack Networks
From jtc@redback.com Fri Aug 20 16:58:00 1999
From: jtc@redback.com (J.T. Conklin)
To: gdb-patches@sourceware.cygnus.com
Subject: patch to top.c: DEFAULT_PROMPT
Date: Fri, 20 Aug 1999 16:58:00 -0000
Message-id: <5m4shungx3.fsf@jtc.redbacknetworks.com>
X-SW-Source: 1999-q3/msg00195.html
Content-length: 1949
While browsing through top.c, I saw that the default prompt was set to
"(gdb)" if DEFAULT_PROMPT was not defined, otherwise to DEFAULT_PROMPT.
As this is done in different ways depending on async_p, it seems a bit
cleaner to me if DEFAULT_PROMPT is set to "(gdb)" if not overriden by
target/host config files --- similar to how GDBINIT_FILENAME is done
today.
--jtc
1999-08-20 J.T. Conklin <jtc@redback.com>
* top.c (DEFAULT_PROMPT): Set to "(gdb)" if not already defined.
(init_main): Always use DEFAULT_PROMPT.
Index: top.c
===================================================================
RCS file: /home/jtc/CVSROOT/gdb/gdb/top.c,v
retrieving revision 1.1.1.10
diff -c -r1.1.1.10 top.c
*** top.c 1999/08/11 04:08:18 1.1.1.10
--- top.c 1999/08/20 23:51:11
***************
*** 158,163 ****
--- 158,169 ----
#define ISATTY(FP) (isatty (fileno (FP)))
#endif
+ /* Default command line prompt. This is overriden in some configs. */
+
+ #ifndef DEFAULT_PROMPT
+ #define DEFAULT_PROMPT "(gdb)"
+ #endif
+
/* Initialization file name for gdb. This is overridden in some configs. */
#ifndef GDBINIT_FILENAME
***************
*** 3807,3817 ****
we initialize the prompts differently. */
if (!async_p)
{
- #ifdef DEFAULT_PROMPT
gdb_prompt_string = savestring (DEFAULT_PROMPT, strlen (DEFAULT_PROMPT));
- #else
- gdb_prompt_string = savestring ("(gdb) ", 6);
- #endif
}
else
{
--- 3813,3819 ----
***************
*** 3819,3829 ****
whatever the DEFAULT_PROMPT is. */
the_prompts.top = 0;
PREFIX (0) = "";
- #ifdef DEFAULT_PROMPT
PROMPT (0) = savestring (DEFAULT_PROMPT, strlen (DEFAULT_PROMPT));
- #else
- PROMPT (0) = savestring ("(gdb) ", 6);
- #endif
SUFFIX (0) = "";
/* Set things up for annotation_level > 1, if the user ever decides
to use it. */
--- 3821,3827 ----
--
J.T. Conklin
RedBack Networks
From msnyder@cygnus.com Fri Aug 20 17:01:00 1999
From: Michael Snyder <msnyder@cygnus.com>
To: jtc@redback.com
Cc: gdb-patches@sourceware.cygnus.com
Subject: Re: patch to top.c: DEFAULT_PROMPT
Date: Fri, 20 Aug 1999 17:01:00 -0000
Message-id: <37BDEC44.7585@cygnus.com>
References: <5m4shungx3.fsf@jtc.redbacknetworks.com>
X-SW-Source: 1999-q3/msg00196.html
Content-length: 439
J.T. Conklin wrote:
>
> While browsing through top.c, I saw that the default prompt was set to
> "(gdb)" if DEFAULT_PROMPT was not defined, otherwise to DEFAULT_PROMPT.
> As this is done in different ways depending on async_p, it seems a bit
> cleaner to me if DEFAULT_PROMPT is set to "(gdb)" if not overriden by
> target/host config files --- similar to how GDBINIT_FILENAME is done
> today.
J.T., don't you have any work to do???
;-)
From jtc@redback.com Fri Aug 20 18:26:00 1999
From: jtc@redback.com (J.T. Conklin)
To: gdb-patches@sourceware.cygnus.com
Subject: patch to write_dollar_variable()
Date: Fri, 20 Aug 1999 18:26:00 -0000
Message-id: <5maerlncv8.fsf@jtc.redbacknetworks.com>
X-SW-Source: 1999-q3/msg00197.html
Content-length: 2185
As previously discussed on the gdb list, this patch is necessary. At
least until symbol table handling is greatly improved... :-)
--jtc
1999-08-20 J.T. Conklin <jtc@redback.com>
* parse.c (write_dollar_variable): If HPUXHPPA is not defined,
don't search for $ variables in the symbol table. Worst case
symbol table lookup performance is extremely poor. This causes
GDB scripts that use convenience variables to execute so slowly
to be almost unusable.
Index: parse.c
===================================================================
RCS file: /home/jtc/CVSROOT/gdb/gdb/parse.c,v
retrieving revision 1.1.1.8
diff -c -r1.1.1.8 parse.c
*** parse.c 1999/07/20 21:37:54 1.1.1.8
--- parse.c 1999/08/21 01:23:44
***************
*** 459,467 ****
{
/* Handle the tokens $digits; also $ (short for $0) and $$ (short for $$1)
and $$digits (equivalent to $<-digits> if you could type that). */
!
struct symbol *sym = NULL;
struct minimal_symbol *msym = NULL;
int negate = 0;
int i = 1;
--- 459,468 ----
{
/* Handle the tokens $digits; also $ (short for $0) and $$ (short for $$1)
and $$digits (equivalent to $<-digits> if you could type that). */
! #if defined(HPUXHPPA)
struct symbol *sym = NULL;
struct minimal_symbol *msym = NULL;
+ #endif
int negate = 0;
int i = 1;
***************
*** 496,505 ****
--- 497,510 ----
if (i >= 0)
goto handle_register;
+ #if defined(HPUXHPPA)
/* On HP-UX, certain system routines (millicode) have names beginning
with $ or $$, e.g. $$dyncall, which handles inter-space procedure
calls on PA-RISC. Check for those, first. */
+ /* This code is not enabled on non HP-UX systems, since worst case
+ symbol table lookup performance is awful, to put it mildly. */
+
sym = lookup_symbol (copy_name (str), (struct block *) NULL,
VAR_NAMESPACE, (int *) NULL, (struct symtab **) NULL);
if (sym)
***************
*** 518,523 ****
--- 523,529 ----
builtin_type_int);
return;
}
+ #endif
/* Any other names starting in $ are debugger internal variables. */
--
J.T. Conklin
RedBack Networks
From ac131313@cygnus.com Fri Aug 20 18:41:00 1999
From: Andrew Cagney <ac131313@cygnus.com>
To: jtc@redback.com, Michael Snyder <msnyder@cygnus.com>
Cc: gdb-patches@sourceware.cygnus.com
Subject: Re: remote.c run-length encoding patch
Date: Fri, 20 Aug 1999 18:41:00 -0000
Message-id: <37BE0366.A512A504@cygnus.com>
References: <5mr9kyhvln.fsf@jtc.redbacknetworks.com>
X-SW-Source: 1999-q3/msg00198.html
Content-length: 1002
"J.T. Conklin" wrote:
>
> The Cisco remote protocol varient (notice that I didn't say mutant
> remote protocol this time :-) uses two hex characters instead of a
> ASCII encoding for the run length but is otherwise the same as the
> standard protocol.
>
> However, the code implementing the decoding is quite different for the
> two encodings. The standard encoding is expanded as the packet is
> read, while the Cisco varient reads the entire packet and then expands
> it in place (actually it expands it to another buffer, and the copies
> that buffer into the first). Unlike the code implementing the
> standard encoding, the Cisco varient does not detect a packet that
> would expand to larger than the buffer size, which could lead to
> corruption within GDB.
I've an alternate patch to this laying around here :-)
> In this patch, I decided to handle both encodings in the same manner.
>
> --jtc
Thanks. Michael, can you confirm that the change works on a cisco
target?
Andrew
From ac131313@cygnus.com Fri Aug 20 18:49:00 1999
From: Andrew Cagney <ac131313@cygnus.com>
To: Daniel Kahlin <tlr@netinsight.se>
Cc: gdb-patches@sourceware.cygnus.com, "seved.torstendahl@netinsight.se" <seved.torstendahl@netinsight.se>, ace@netinsight.se, psim@ci.com.au
Subject: Re: psim bug
Date: Fri, 20 Aug 1999 18:49:00 -0000
Message-id: <37BE0593.3326917F@cygnus.com>
References: <37BD6FCA.C433AC4E@netinsight.se>
X-SW-Source: 1999-q3/msg00199.html
Content-length: 830
Daniel Kahlin wrote:
>
> Hi,
>
> BUG:
> When loading sections using 'psim' they incorrectly get placed at their
> respective VMA's instead of their LMA's. This makes debugging of romable
> code impossible, because crt0.S will break when it tries to copy the
> .data section into ram.
>
> FIX:
> Always load sections to their LMA.
> If the LMA and the VMA differ, mark the LMA area read-only, and
> allocate the VMA area filling it with zeroes.
It may or may not be a bug. It really depends on the emulation mode
being used. Can you post the output from:
.....-run -t dump-device-tree <program>
thanks,
Andrew
PS: Please submit patches as text attachments and not as compressed tar
archives (no matter how big :-). That way the reviewer can quickly
exmaine the change and determine if it is applicable.
From ac131313@cygnus.com Sat Aug 21 22:30:00 1999
From: Andrew Cagney <ac131313@cygnus.com>
To: gdb-patches@sourceware.cygnus.com
Subject: FYI, move ``enum lval_type'' to defs.h
Date: Sat, 21 Aug 1999 22:30:00 -0000
Message-id: <37BF89E8.DB24AF75@cygnus.com>
X-SW-Source: 1999-q3/msg00200.html
Content-length: 4418
FYI,
I've checked in the attached patch. It moves the declaration of enum
lval_type to defs.h so that it is visible across all header files (yuck
:-).
Hopefully that was the last remaining incomplete enum declaration.
enjoy,
Andrew
Sun Aug 22 14:49:40 1999 Andrew Cagney <cagney@b1.cygnus.com>
* value.h (enum lval_type): Move declaration from here.
* defs.h (enum lval_type): To here.
* frame.h, gdbarch.h: Delete incomplete declaration of ``enum
lval_type''.
Index: defs.h
===================================================================
RCS file: /cvs/cvsfiles/devo/gdb/defs.h,v
retrieving revision 1.246
diff -p -r1.246 defs.h
*** defs.h 1999/08/11 01:46:26 1.246
--- defs.h 1999/08/22 05:23:59
*************** extern char *symtab_to_filename PARAMS (
*** 574,583 ****
extern int read_relative_register_raw_bytes PARAMS ((int, char *));
! #if __STDC__
! enum lval_type;
struct frame_info;
! #endif
void default_get_saved_register PARAMS ((char *raw_buffer, int *optimized,
CORE_ADDR *addrp,
struct frame_info *frame, int regnum,
--- 574,602 ----
extern int read_relative_register_raw_bytes PARAMS ((int, char *));
! /* Possible lvalue types. Like enum language, this should be in
! value.h, but needs to be here for the same reason. */
!
! enum lval_type
! {
! /* Not an lval. */
! not_lval,
! /* In memory. Could be a saved register. */
! lval_memory,
! /* In a register. */
! lval_register,
! /* In a gdb internal variable. */
! lval_internalvar,
! /* Part of a gdb internal variable (structure field). */
! lval_internalvar_component,
! /* In a register series in a frame not the current one, which may have been
! partially saved or saved in different places (otherwise would be
! lval_register or lval_memory). */
! lval_reg_frame_relative
! };
!
struct frame_info;
!
void default_get_saved_register PARAMS ((char *raw_buffer, int *optimized,
CORE_ADDR *addrp,
struct frame_info *frame, int regnum,
Index: frame.h
===================================================================
RCS file: /cvs/cvsfiles/devo/gdb/frame.h,v
retrieving revision 1.41
diff -p -r1.41 frame.h
*** frame.h 1999/07/07 23:51:07 1.41
--- frame.h 1999/08/22 05:24:02
*************** extern void generic_fix_call_dummy PARAM
*** 247,257 ****
int nargs, struct value ** args,
struct type * type, int gcc_p));
- #ifdef __STDC__
- /* Some native compilers, even ones that are supposed to be ANSI and for which __STDC__
- is true, complain about forward decls of enums. */
- enum lval_type;
extern void generic_get_saved_register PARAMS ((char *, int *, CORE_ADDR *, struct frame_info *, int, enum lval_type *));
- #endif
#endif /* !defined (FRAME_H) */
--- 247,252 ----
Index: gdbarch.h
===================================================================
RCS file: /cvs/cvsfiles/devo/gdb/gdbarch.h,v
retrieving revision 2.55
diff -p -r2.55 gdbarch.h
*** gdbarch.h 1999/08/08 07:19:45 2.55
--- gdbarch.h 1999/08/22 05:24:04
***************
*** 26,32 ****
#ifdef __STDC__
struct frame_info;
struct value;
- enum lval_type;
#endif
--- 26,31 ----
Index: value.h
===================================================================
RCS file: /cvs/cvsfiles/devo/gdb/value.h,v
retrieving revision 1.81
diff -p -r1.81 value.h
*** value.h 1999/07/07 23:52:08 1.81
--- value.h 1999/08/22 05:24:08
***************
*** 27,49 ****
* be possible for a program lval value to survive over a call to the inferior
* (ie to be put into the history list or an internal variable).
*/
- enum lval_type
- {
- /* Not an lval. */
- not_lval,
- /* In memory. Could be a saved register. */
- lval_memory,
- /* In a register. */
- lval_register,
- /* In a gdb internal variable. */
- lval_internalvar,
- /* Part of a gdb internal variable (structure field). */
- lval_internalvar_component,
- /* In a register series in a frame not the current one, which may have been
- partially saved or saved in different places (otherwise would be
- lval_register or lval_memory). */
- lval_reg_frame_relative
- };
struct value
{
--- 27,32 ----
next parent reply other threads:[~1999-08-20 12:20 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <37BDA912.4AA1190D@cygnus.com>
1999-08-20 12:20 ` DJ Delorie [this message]
[not found] ` <37BDAD71.510A96A1@cygnus.com>
[not found] ` <199908202005.QAA26613@envy.delorie.com>
[not found] ` <37BDB5E2.4318@cygnus.com>
[not found] ` <199908202013.QAA26688@envy.delorie.com>
1999-08-22 3:14 ` Eli Zaretskii
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=199908201917.PAA26278@envy.delorie.com \
--to=dj@delorie.com \
--cc=Eliz@is.elta.co.il \
--cc=fnasser@cygnus.com \
--cc=gdb-patches@sourceware.cygnus.com \
--cc=shebs@cygnus.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox