/* * LZMA2 decoder * * Authors: Lasse Collin <lasse.collin@tukaani.org> * Igor Pavlov <http://7-zip.org/> * * This file has been put into the public domain. * You can do whatever you want with this file. */ #include "private.h" #include "lzma2.h" /* * Range decoder initialization eats the first five bytes of each LZMA chunk. */ #define RC_INIT_BYTES 5 /* * Minimum number of usable input buffer to safely decode one LZMA symbol. * The worst case is that we decode 22 bits using probabilities and 26 * direct bits. This may decode at maximum of 20 bytes of input. However, * lzma_main() does an extra normalization before returning, thus we * need to put 21 here. */ #define LZMA_IN_REQUIRED 21 /* * Dictionary (history buffer) * * These are always true: * start <= pos <= full <= end * pos <= limit <= end * * In multi-call mode, also these are true: * end == size * size <= size_max * allocated <= size * * Most of these variables are size_t to support single-call mode, * in which the dictionary variables address the actual output * buffer directly. */ struct dictionary { /* Beginning of the history buffer */ uint8_t *buf; /* Old position in buf (before decoding more data) */ size_t start; /* Position in buf */ size_t pos; /* * How full dictionary is. This is used to detect corrupt input that * would read beyond the beginning of the uncompressed stream. */ size_t full; /* Write limit; we don't write to buf[limit] or later bytes. */ size_t limit; /* * End of the dictionary buffer. In multi-call mode, this is * the same as the dictionary size. In single-call mode, this * indicates the size of the output buffer. */ size_t end; /* * Size of the dictionary as specified in Block Header. This is used * together with "full" to detect corrupt input that would make us * read beyond the beginning of the uncompressed stream. */ uint32_t size; /* * Maximum allowed dictionary size in multi-call mode. * This is ignored in single-call mode. */ uint32_t size_max; /* * Amount of memory currently allocated for the dictionary. * This is used only with XZ_DYNALLOC. (With XZ_PREALLOC, * size_max is always the same as the allocated size.) */ uint32_t allocated; /* Operation mode */ enum xz_mode mode; }; /* Range decoder */ struct rc_dec { uint32_t range; uint32_t code; /* * Number of initializing bytes remaining to be read * by rc_read_init(). */ uint32_t init_bytes_left; /* * Buffer from which we read our input. It can be either * temp.buf or the caller-provided input buffer. */ const uint8_t *in; size_t in_pos; size_t in_limit; }; /* Probabilities for a length decoder. */ struct lzma_len_dec { /* Probability of match length being at least 10 */ uint16_t choice; /* Probability of match length being at least 18 */ uint16_t choice2; /* Probabilities for match lengths 2-9 */ uint16_t low[POS_STATES_MAX][LEN_LOW_SYMBOLS]; /* Probabilities for match lengths 10-17 */ uint16_t mid[POS_STATES_MAX][LEN_MID_SYMBOLS]; /* Probabilities for match lengths 18-273 */ uint16_t high[LEN_HIGH_SYMBOLS]; }; struct lzma_dec { /* Distances of latest four matches */ uint32_t rep0; uint32_t rep1; uint32_t rep2; uint32_t rep3; /* Types of the most recently seen LZMA symbols */ enum lzma_state state; /* * Length of a match. This is updated so that dict_repeat can * be called again to finish repeating the whole match. */ uint32_t len; /* * LZMA properties or related bit masks (number of literal * context bits, a mask dervied from the number of literal * position bits, and a mask dervied from the number * position bits) */ uint32_t lc; uint32_t literal_pos_mask; /* (1 << lp) - 1 */ uint32_t pos_mask; /* (1 << pb) - 1 */ /* If 1, it's a match. Otherwise it's a single 8-bit literal. */ uint16_t is_match[STATES][POS_STATES_MAX]; /* If 1, it's a repeated match. The distance is one of rep0 .. rep3. */ uint16_t is_rep[STATES]; /* * If 0, distance of a repeated match is rep0. * Otherwise check is_rep1. */ uint16_t is_rep0[STATES]; /* * If 0, distance of a repeated match is rep1. * Otherwise check is_rep2. */ uint16_t is_rep1[STATES]; /* If 0, distance of a repeated match is rep2. Otherwise it is rep3. */ uint16_t is_rep2[STATES]; /* * If 1, the repeated match has length of one byte. Otherwise * the length is decoded from rep_len_decoder. */ uint16_t is_rep0_long[STATES][POS_STATES_MAX]; /* * Probability tree for the highest two bits of the match * distance. There is a separate probability tree for match * lengths of 2 (i.e. MATCH_LEN_MIN), 3, 4, and [5, 273]. */ uint16_t dist_slot[DIST_STATES][DIST_SLOTS]; /* * Probility trees for additional bits for match distance * when the distance is in the range [4, 127]. */ uint16_t dist_special[FULL_DISTANCES - DIST_MODEL_END]; /* * Probability tree for the lowest four bits of a match * distance that is equal to or greater than 128. */ uint16_t dist_align[ALIGN_SIZE]; /* Length of a normal match */ struct lzma_len_dec match_len_dec; /* Length of a repeated match */ struct lzma_len_dec rep_len_dec; /* Probabilities of literals */ uint16_t literal[LITERAL_CODERS_MAX][LITERAL_CODER_SIZE]; }; struct lzma2_dec { /* Position in xz_dec_lzma2_run(). */ enum lzma2_seq { SEQ_CONTROL, SEQ_UNCOMPRESSED_1, SEQ_UNCOMPRESSED_2, SEQ_COMPRESSED_0, SEQ_COMPRESSED_1, SEQ_PROPERTIES, SEQ_LZMA_PREPARE, SEQ_LZMA_RUN, SEQ_COPY } sequence; /* Next position after decoding the compressed size of the chunk. */ enum lzma2_seq next_sequence; /* Uncompressed size of LZMA chunk (2 MiB at maximum) */ uint32_t uncompressed; /* * Compressed size of LZMA chunk or compressed/uncompressed * size of uncompressed chunk (64 KiB at maximum) */ uint32_t compressed; /* * True if dictionary reset is needed. This is false before * the first chunk (LZMA or uncompressed). */ bool_t need_dict_reset; /* * True if new LZMA properties are needed. This is false * before the first LZMA chunk. */ bool_t need_props; }; struct xz_dec_lzma2 { /* * The order below is important on x86 to reduce code size and * it shouldn't hurt on other platforms. Everything up to and * including lzma.pos_mask are in the first 128 bytes on x86-32, * which allows using smaller instructions to access those * variables. On x86-64, fewer variables fit into the first 128 * bytes, but this is still the best order without sacrificing * the readability by splitting the structures. */ struct rc_dec rc; struct dictionary dict; struct lzma2_dec lzma2; struct lzma_dec lzma; /* * Temporary buffer which holds small number of input bytes between * decoder calls. See lzma2_lzma() for details. */ struct { uint32_t size; uint8_t buf[3 * LZMA_IN_REQUIRED]; } temp; }; /************** * Dictionary * **************/ /* * Reset the dictionary state. When in single-call mode, set up the beginning * of the dictionary to point to the actual output buffer. */ static void INIT dict_reset(struct dictionary *dict, struct xz_buf *b) { if (DEC_IS_SINGLE(dict->mode)) { dict->buf = b->out + b->out_pos; dict->end = b->out_size - b->out_pos; } dict->start = 0; dict->pos = 0; dict->limit = 0; dict->full = 0; } /* Set dictionary write limit */ static void INIT dict_limit(struct dictionary *dict, size_t out_max) { if (dict->end - dict->pos <= out_max) dict->limit = dict->end; else dict->limit = dict->pos + out_max; } /* Return true if at least one byte can be written into the dictionary. */ static inline bool_t INIT dict_has_space(const struct dictionary *dict) { return dict->pos < dict->limit; } /* * Get a byte from the dictionary at the given distance. The distance is * assumed to valid, or as a special case, zero when the dictionary is * still empty. This special case is needed for single-call decoding to * avoid writing a '\0' to the end of the destination buffer. */ static inline uint32_t INIT dict_get(const struct dictionary *dict, uint32_t dist) { size_t offset = dict->pos - dist - 1; if (dist >= dict->pos) offset += dict->end; return dict->full > 0 ? dict->buf[offset] : 0; } /* * Put one byte into the dictionary. It is assumed that there is space for it. */ static inline void INIT dict_put(struct dictionary *dict, uint8_t byte) { dict->buf[dict->pos++] = byte; if (dict->full < dict->pos) dict->full = dict->pos; } /* * Repeat given number of bytes from the given distance. If the distance is * invalid, false is returned. On success, true is returned and *len is * updated to indicate how many bytes were left to be repeated. */ static bool_t INIT dict_repeat(struct dictionary *dict, uint32_t *len, uint32_t dist) { size_t back; uint32_t left; if (dist >= dict->full || dist >= dict->size) return false; left = min_t(size_t, dict->limit - dict->pos, *len); *len -= left; back = dict->pos - dist - 1; if (dist >= dict->pos) back += dict->end; do { dict->buf[dict->pos++] = dict->buf[back++]; if (back == dict->end) back = 0; } while (--left > 0); if (dict->full < dict->pos) dict->full = dict->pos; return true; } /* Copy uncompressed data as is from input to dictionary and output buffers. */ static void INIT dict_uncompressed(struct dictionary *dict, struct xz_buf *b, uint32_t *left) { size_t copy_size; while (*left > 0 && b->in_pos < b->in_size && b->out_pos < b->out_size) { copy_size = min(b->in_size - b->in_pos, b->out_size - b->out_pos); if (copy_size > dict->end - dict->pos) copy_size = dict->end - dict->pos; if (copy_size > *left) copy_size = *left; *left -= copy_size; memcpy(dict->buf + dict->pos, b->in + b->in_pos, copy_size); dict->pos += copy_size; if (dict->full < dict->pos) dict->full = dict->pos; if (DEC_IS_MULTI(dict->mode)) { if (dict->pos == dict->end) dict->pos = 0; memcpy(b->out + b->out_pos, b->in + b->in_pos, copy_size); } dict->start = dict->pos; b->out_pos += copy_size; b->in_pos += copy_size; } } /* * Flush pending data from dictionary to b->out. It is assumed that there is * enough space in b->out. This is guaranteed because caller uses dict_limit() * before decoding data into the dictionary. */ static uint32_t INIT dict_flush(struct dictionary *dict, struct xz_buf *b) { size_t copy_size = dict->pos - dict->start; if (DEC_IS_MULTI(dict->mode)) { if (dict->pos == dict->end) dict->pos = 0; memcpy(b->out + b->out_pos, dict->buf + dict->start, copy_size); } dict->start = dict->pos; b->out_pos += copy_size; return copy_size; } /***************** * Range decoder * *****************/ /* Reset the range decoder. */ static void INIT rc_reset(struct rc_dec *rc) { rc->range = (uint32_t)-1; rc->code = 0; rc->init_bytes_left = RC_INIT_BYTES; } /* * Read the first five initial bytes into rc->code if they haven't been * read already. (Yes, the first byte gets completely ignored.) */ static bool_t INIT rc_read_init(struct rc_dec *rc, struct xz_buf *b) { while (rc->init_bytes_left > 0) { if (b->in_pos == b->in_size) return false; rc->code = (rc->code << 8) + b->in[b->in_pos++]; --rc->init_bytes_left; } return true; } /* Return true if there may not be enough input for the next decoding loop. */ static inline bool_t INIT rc_limit_exceeded(const struct rc_dec *rc) { return rc->in_pos > rc->in_limit; } /* * Return true if it is possible (from point of view of range decoder) that * we have reached the end of the LZMA chunk. */ static inline bool_t INIT rc_is_finished(const struct rc_dec *rc) { return rc->code == 0; } /* Read the next input byte if needed. */ static always_inline void rc_normalize(struct rc_dec *rc) { if (rc->range < RC_TOP_VALUE) { rc->range <<= RC_SHIFT_BITS; rc->code = (rc->code << RC_SHIFT_BITS) + rc->in[rc->in_pos++]; } } /* * Decode one bit. In some versions, this function has been splitted in three * functions so that the compiler is supposed to be able to more easily avoid * an extra branch. In this particular version of the LZMA decoder, this * doesn't seem to be a good idea (tested with GCC 3.3.6, 3.4.6, and 4.3.3 * on x86). Using a non-splitted version results in nicer looking code too. * * NOTE: This must return an int. Do not make it return a bool or the speed * of the code generated by GCC 3.x decreases 10-15 %. (GCC 4.3 doesn't care, * and it generates 10-20 % faster code than GCC 3.x from this file anyway.) */ static always_inline int rc_bit(struct rc_dec *rc, uint16_t *prob) { uint32_t bound; int bit; rc_normalize(rc); bound = (rc->range >> RC_BIT_MODEL_TOTAL_BITS) * *prob; if (rc->code < bound) { rc->range = bound; *prob += (RC_BIT_MODEL_TOTAL - *prob) >> RC_MOVE_BITS; bit = 0; } else { rc->range -= bound; rc->code -= bound; *prob -= *prob >> RC_MOVE_BITS; bit = 1; } return bit; } /* Decode a bittree starting from the most significant bit. */ static always_inline uint32_t rc_bittree(struct rc_dec *rc, uint16_t *probs, uint32_t limit) { uint32_t symbol = 1; do { if (rc_bit(rc, &probs[symbol])) symbol = (symbol << 1) + 1; else symbol <<= 1; } while (symbol < limit); return symbol; } /* Decode a bittree starting from the least significant bit. */ static always_inline void rc_bittree_reverse(struct rc_dec *rc, uint16_t *probs, uint32_t *dest, uint32_t limit) { uint32_t symbol = 1; uint32_t i = 0; do { if (rc_bit(rc, &probs[symbol])) { symbol = (symbol << 1) + 1; *dest += 1 << i; } else { symbol <<= 1; } } while (++i < limit); } /* Decode direct bits (fixed fifty-fifty probability) */ static inline void INIT rc_direct(struct rc_dec *rc, uint32_t *dest, uint32_t limit) { uint32_t mask; do { rc_normalize(rc); rc->range >>= 1; rc->code -= rc->range; mask = (uint32_t)0 - (rc->code >> 31); rc->code += rc->range & mask; *dest = (*dest << 1) + (mask + 1); } while (--limit > 0); } /******** * LZMA * ********/ /* Get pointer to literal coder probability array. */ static uint16_t *INIT lzma_literal_probs(struct xz_dec_lzma2 *s) { uint32_t prev_byte = dict_get(&s->dict, 0); uint32_t low = prev_byte >> (8 - s->lzma.lc); uint32_t high = (s->dict.pos & s->lzma.literal_pos_mask) << s->lzma.lc; return s->lzma.literal[low + high]; } /* Decode a literal (one 8-bit byte) */ static void INIT lzma_literal(struct xz_dec_lzma2 *s) { uint16_t *probs; uint32_t symbol; uint32_t match_byte; uint32_t match_bit; uint32_t offset; uint32_t i; probs = lzma_literal_probs(s); if (lzma_state_is_literal(s->lzma.state)) { symbol = rc_bittree(&s->rc, probs, 0x100); } else { symbol = 1; match_byte = dict_get(&s->dict, s->lzma.rep0) << 1; offset = 0x100; do { match_bit = match_byte & offset; match_byte <<= 1; i = offset + match_bit + symbol; if (rc_bit(&s->rc, &probs[i])) { symbol = (symbol << 1) + 1; offset &= match_bit; } else { symbol <<= 1; offset &= ~match_bit; } } while (symbol < 0x100); } dict_put(&s->dict, (uint8_t)symbol); lzma_state_literal(&s->lzma.state); } /* Decode the length of the match into s->lzma.len. */ static void INIT lzma_len(struct xz_dec_lzma2 *s, struct lzma_len_dec *l, uint32_t pos_state) { uint16_t *probs; uint32_t limit; if (!rc_bit(&s->rc, &l->choice)) { probs = l->low[pos_state]; limit = LEN_LOW_SYMBOLS; s->lzma.len = MATCH_LEN_MIN; } else { if (!rc_bit(&s->rc, &l->choice2)) { probs = l->mid[pos_state]; limit = LEN_MID_SYMBOLS; s->lzma.len = MATCH_LEN_MIN + LEN_LOW_SYMBOLS; } else { probs = l->high; limit = LEN_HIGH_SYMBOLS; s->lzma.len = MATCH_LEN_MIN + LEN_LOW_SYMBOLS + LEN_MID_SYMBOLS; } } s->lzma.len += rc_bittree(&s->rc, probs, limit) - limit; } /* Decode a match. The distance will be stored in s->lzma.rep0. */ static void INIT lzma_match(struct xz_dec_lzma2 *s, uint32_t pos_state) { uint16_t *probs; uint32_t dist_slot; uint32_t limit; lzma_state_match(&s->lzma.state); s->lzma.rep3 = s->lzma.rep2; s->lzma.rep2 = s->lzma.rep1; s->lzma.rep1 = s->lzma.rep0; lzma_len(s, &s->lzma.match_len_dec, pos_state); probs = s->lzma.dist_slot[lzma_get_dist_state(s->lzma.len)]; dist_slot = rc_bittree(&s->rc, probs, DIST_SLOTS) - DIST_SLOTS; if (dist_slot < DIST_MODEL_START) { s->lzma.rep0 = dist_slot; } else { limit = (dist_slot >> 1) - 1; s->lzma.rep0 = 2 + (dist_slot & 1); if (dist_slot < DIST_MODEL_END) { s->lzma.rep0 <<= limit; probs = s->lzma.dist_special + s->lzma.rep0 - dist_slot - 1; rc_bittree_reverse(&s->rc, probs, &s->lzma.rep0, limit); } else { rc_direct(&s->rc, &s->lzma.rep0, limit - ALIGN_BITS); s->lzma.rep0 <<= ALIGN_BITS; rc_bittree_reverse(&s->rc, s->lzma.dist_align, &s->lzma.rep0, ALIGN_BITS); } } } /* * Decode a repeated match. The distance is one of the four most recently * seen matches. The distance will be stored in s->lzma.rep0. */ static void INIT lzma_rep_match(struct xz_dec_lzma2 *s, uint32_t pos_state) { uint32_t tmp; if (!rc_bit(&s->rc, &s->lzma.is_rep0[s->lzma.state])) { if (!rc_bit(&s->rc, &s->lzma.is_rep0_long[ s->lzma.state][pos_state])) { lzma_state_short_rep(&s->lzma.state); s->lzma.len = 1; return; } } else { if (!rc_bit(&s->rc, &s->lzma.is_rep1[s->lzma.state])) { tmp = s->lzma.rep1; } else { if (!rc_bit(&s->rc, &s->lzma.is_rep2[s->lzma.state])) { tmp = s->lzma.rep2; } else { tmp = s->lzma.rep3; s->lzma.rep3 = s->lzma.rep2; } s->lzma.rep2 = s->lzma.rep1; } s->lzma.rep1 = s->lzma.rep0; s->lzma.rep0 = tmp; } lzma_state_long_rep(&s->lzma.state); lzma_len(s, &s->lzma.rep_len_dec, pos_state); } /* LZMA decoder core */ static bool_t INIT lzma_main(struct xz_dec_lzma2 *s) { uint32_t pos_state; /* * If the dictionary was reached during the previous call, try to * finish the possibly pending repeat in the dictionary. */ if (dict_has_space(&s->dict) && s->lzma.len > 0) dict_repeat(&s->dict, &s->lzma.len, s->lzma.rep0); /* * Decode more LZMA symbols. One iteration may consume up to * LZMA_IN_REQUIRED - 1 bytes. */ while (dict_has_space(&s->dict) && !rc_limit_exceeded(&s->rc)) { pos_state = s->dict.pos & s->lzma.pos_mask; if (!rc_bit(&s->rc, &s->lzma.is_match[ s->lzma.state][pos_state])) { lzma_literal(s); } else { if (rc_bit(&s->rc, &s->lzma.is_rep[s->lzma.state])) lzma_rep_match(s, pos_state); else lzma_match(s, pos_state); if (!dict_repeat(&s->dict, &s->lzma.len, s->lzma.rep0)) return false; } } /* * Having the range decoder always normalized when we are outside * this function makes it easier to correctly handle end of the chunk. */ rc_normalize(&s->rc); return true; } /* * Reset the LZMA decoder and range decoder state. Dictionary is nore reset * here, because LZMA state may be reset without resetting the dictionary. */ static void INIT lzma_reset(struct xz_dec_lzma2 *s) { uint16_t *probs; size_t i; s->lzma.state = STATE_LIT_LIT; s->lzma.rep0 = 0; s->lzma.rep1 = 0; s->lzma.rep2 = 0; s->lzma.rep3 = 0; /* * All probabilities are initialized to the same value. This hack * makes the code smaller by avoiding a separate loop for each * probability array. * * This could be optimized so that only that part of literal * probabilities that are actually required. In the common case * we would write 12 KiB less. */ probs = s->lzma.is_match[0]; for (i = 0; i < PROBS_TOTAL; ++i) probs[i] = RC_BIT_MODEL_TOTAL / 2; rc_reset(&s->rc); } /* * Decode and validate LZMA properties (lc/lp/pb) and calculate the bit masks * from the decoded lp and pb values. On success, the LZMA decoder state is * reset and true is returned. */ static bool_t INIT lzma_props(struct xz_dec_lzma2 *s, uint8_t props) { if (props > (4 * 5 + 4) * 9 + 8) return false; s->lzma.pos_mask = 0; while (props >= 9 * 5) { props -= 9 * 5; ++s->lzma.pos_mask; } s->lzma.pos_mask = (1 << s->lzma.pos_mask) - 1; s->lzma.literal_pos_mask = 0; while (props >= 9) { props -= 9; ++s->lzma.literal_pos_mask; } s->lzma.lc = props; if (s->lzma.lc + s->lzma.literal_pos_mask > 4) return false; s->lzma.literal_pos_mask = (1 << s->lzma.literal_pos_mask) - 1; lzma_reset(s); return true; } /********* * LZMA2 * *********/ /* * The LZMA decoder assumes that if the input limit (s->rc.in_limit) hasn't * been exceeded, it is safe to read up to LZMA_IN_REQUIRED bytes. This * wrapper function takes care of making the LZMA decoder's assumption safe. * * As long as there is plenty of input left to be decoded in the current LZMA * chunk, we decode directly from the caller-supplied input buffer until * there's LZMA_IN_REQUIRED bytes left. Those remaining bytes are copied into * s->temp.buf, which (hopefully) gets filled on the next call to this * function. We decode a few bytes from the temporary buffer so that we can * continue decoding from the caller-supplied input buffer again. */ static bool_t INIT lzma2_lzma(struct xz_dec_lzma2 *s, struct xz_buf *b) { size_t in_avail; uint32_t tmp; in_avail = b->in_size - b->in_pos; if (s->temp.size > 0 || s->lzma2.compressed == 0) { tmp = 2 * LZMA_IN_REQUIRED - s->temp.size; if (tmp > s->lzma2.compressed - s->temp.size) tmp = s->lzma2.compressed - s->temp.size; if (tmp > in_avail) tmp = in_avail; memcpy(s->temp.buf + s->temp.size, b->in + b->in_pos, tmp); if (s->temp.size + tmp == s->lzma2.compressed) { memzero(s->temp.buf + s->temp.size + tmp, sizeof(s->temp.buf) - s->temp.size - tmp); s->rc.in_limit = s->temp.size + tmp; } else if (s->temp.size + tmp < LZMA_IN_REQUIRED) { s->temp.size += tmp; b->in_pos += tmp; return true; } else { s->rc.in_limit = s->temp.size + tmp - LZMA_IN_REQUIRED; } s->rc.in = s->temp.buf; s->rc.in_pos = 0; if (!lzma_main(s) || s->rc.in_pos > s->temp.size + tmp) return false; s->lzma2.compressed -= s->rc.in_pos; if (s->rc.in_pos < s->temp.size) { s->temp.size -= s->rc.in_pos; memmove(s->temp.buf, s->temp.buf + s->rc.in_pos, s->temp.size); return true; } b->in_pos += s->rc.in_pos - s->temp.size; s->temp.size = 0; } in_avail = b->in_size - b->in_pos; if (in_avail >= LZMA_IN_REQUIRED) { s->rc.in = b->in; s->rc.in_pos = b->in_pos; if (in_avail >= s->lzma2.compressed + LZMA_IN_REQUIRED) s->rc.in_limit = b->in_pos + s->lzma2.compressed; else s->rc.in_limit = b->in_size - LZMA_IN_REQUIRED; if (!lzma_main(s)) return false; in_avail = s->rc.in_pos - b->in_pos; if (in_avail > s->lzma2.compressed) return false; s->lzma2.compressed -= in_avail; b->i<style>pre { line-height: 125%; margin: 0; } td.linenos pre { color: #000000; background-color: #f0f0f0; padding: 0 5px 0 5px; } span.linenos { color: #000000; background-color: #f0f0f0; padding: 0 5px 0 5px; } td.linenos pre.special { color: #000000; background-color: #ffffc0; padding: 0 5px 0 5px; } span.linenos.special { color: #000000; background-color: #ffffc0; padding: 0 5px 0 5px; } .highlight .hll { background-color: #ffffcc } .highlight { background: #ffffff; } .highlight .c { color: #888888 } /* Comment */ .highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */ .highlight .k { color: #008800; font-weight: bold } /* Keyword */ .highlight .ch { color: #888888 } /* Comment.Hashbang */ .highlight .cm { color: #888888 } /* Comment.Multiline */ .highlight .cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */ .highlight .cpf { color: #888888 } /* Comment.PreprocFile */ .highlight .c1 { color: #888888 } /* Comment.Single */ .highlight .cs { color: #cc0000; font-weight: bold; background-color: #fff0f0 } /* Comment.Special */ .highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */ .highlight .ge { font-style: italic } /* Generic.Emph */ .highlight .gr { color: #aa0000 } /* Generic.Error */ .highlight .gh { color: #333333 } /* Generic.Heading */ .highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */ .highlight .go { color: #888888 } /* Generic.Output */ .highlight .gp { color: #555555 } /* Generic.Prompt */ .highlight .gs { font-weight: bold } /* Generic.Strong */ .highlight .gu { color: #666666 } /* Generic.Subheading */ .highlight .gt { color: #aa0000 } /* Generic.Traceback */ .highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */ .highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */ .highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */ .highlight .kp { color: #008800 } /* Keyword.Pseudo */ .highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */ .highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */ .highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */ .highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */ .highlight .na { color: #336699 } /* Name.Attribute */ .highlight .nb { color: #003388 } /* Name.Builtin */ .highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */ .highlight .no { color: #003366; font-weight: bold } /* Name.Constant */ .highlight .nd { color: #555555 } /* Name.Decorator */ .highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */ .highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */ .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */</style><div class="highlight"><pre><span></span>2004-10-11 This patch is not submitted. Many of these functions should be passing a frame around rather than calling get_selected_frame, but at least it is an improvement over deprecated_selected_frame. <span class="gh">Index: gdb-6.3/gdb/breakpoint.c</span> <span class="gh">===================================================================</span> <span class="gd">--- gdb-6.3.orig/gdb/breakpoint.c 2004-10-08 13:30:46.000000000 -0400</span> <span class="gi">+++ gdb-6.3/gdb/breakpoint.c 2004-11-09 22:55:11.231620957 -0500</span> <span class="gu">@@ -922,7 +922,7 @@ insert_bp_location (struct bp_location *</span> /* FIXME drow/2003-09-09: It would be nice if evaluate_expression took a frame parameter, so that we didn't have to change the selected frame. */ <span class="gd">- saved_frame_id = get_frame_id (deprecated_selected_frame);</span> <span class="gi">+ saved_frame_id = get_frame_id (get_selected_frame ());</span> /* Determine if the watchpoint is within scope. */ if (bpt->owner->exp_valid_block == NULL) <span class="gu">@@ -5464,14 +5464,9 @@ break_at_finish_at_depth_command_1 (char</span> if (default_breakpoint_valid) { <span class="gd">- if (deprecated_selected_frame)</span> <span class="gd">- {</span> <span class="gd">- selected_pc = get_frame_pc (deprecated_selected_frame);</span> <span class="gd">- if (arg)</span> <span class="gd">- if_arg = 1;</span> <span class="gd">- }</span> <span class="gd">- else</span> <span class="gd">- error ("No selected frame.");</span> <span class="gi">+ selected_pc = get_frame_pc (get_selected_frame ());</span> <span class="gi">+ if (arg)</span> <span class="gi">+ if_arg = 1;</span> } else error ("No default breakpoint address now."); <span class="gu">@@ -5542,15 +5537,10 @@ break_at_finish_command_1 (char *arg, in</span> { if (default_breakpoint_valid) { <span class="gd">- if (deprecated_selected_frame)</span> <span class="gd">- {</span> <span class="gd">- addr_string = xstrprintf ("*0x%s",</span> <span class="gd">- paddr_nz (get_frame_pc (deprecated_selected_frame)));</span> <span class="gd">- if (arg)</span> <span class="gd">- if_arg = 1;</span> <span class="gd">- }</span> <span class="gd">- else</span> <span class="gd">- error ("No selected frame.");</span> <span class="gi">+ addr_string = xstrprintf ("*0x%s",</span> <span class="gi">+ paddr_nz (get_frame_pc (get_selected_frame ())));</span> <span class="gi">+ if (arg)</span> <span class="gi">+ if_arg = 1;</span> } else error ("No default breakpoint address now."); <span class="gu">@@ -6082,7 +6072,7 @@ until_break_command (char *arg, int from</span> { struct symtabs_and_lines sals; struct symtab_and_line sal; <span class="gd">- struct frame_info *prev_frame = get_prev_frame (deprecated_selected_frame);</span> <span class="gi">+ struct frame_info *prev_frame = get_prev_frame (get_selected_frame ());</span> struct breakpoint *breakpoint; struct cleanup *old_chain; struct continuation_arg *arg1; <span class="gu">@@ -6119,7 +6109,7 @@ until_break_command (char *arg, int from</span> /* Otherwise, specify the current frame, because we want to stop only at the very same frame. */ breakpoint = set_momentary_breakpoint (sal, <span class="gd">- get_frame_id (deprecated_selected_frame),</span> <span class="gi">+ get_frame_id (get_selected_frame ()),</span> bp_until); if (!target_can_async_p ()) <span class="gh">Index: gdb-6.3/gdb/cli/cli-cmds.c</span> <span class="gh">===================================================================</span> <span class="gd">--- gdb-6.3.orig/gdb/cli/cli-cmds.c 2004-09-11 06:24:53.000000000 -0400</span> <span class="gi">+++ gdb-6.3/gdb/cli/cli-cmds.c 2004-11-09 22:51:07.323246218 -0500</span> <span class="gu">@@ -845,10 +845,7 @@ disassemble_command (char *arg, int from</span> name = NULL; if (!arg) { <span class="gd">- if (!deprecated_selected_frame)</span> <span class="gd">- error ("No frame selected.\n");</span> <span class="gd">-</span> <span class="gd">- pc = get_frame_pc (deprecated_selected_frame);</span> <span class="gi">+ pc = get_frame_pc (get_selected_frame ());</span> if (find_pc_partial_function (pc, &name, &low, &high) == 0) error ("No function contains program counter for selected frame.\n"); #if defined(TUI) <span class="gh">Index: gdb-6.3/gdb/f-valprint.c</span> <span class="gh">===================================================================</span> <span class="gd">--- gdb-6.3.orig/gdb/f-valprint.c 2003-10-14 02:51:14.000000000 -0400</span> <span class="gi">+++ gdb-6.3/gdb/f-valprint.c 2004-11-09 22:51:07.326245632 -0500</span> <span class="gu">@@ -76,7 +76,7 @@ f77_get_dynamic_lowerbound (struct type </span> switch (TYPE_ARRAY_LOWER_BOUND_TYPE (type)) { case BOUND_BY_VALUE_ON_STACK: <span class="gd">- current_frame_addr = get_frame_base (deprecated_selected_frame);</span> <span class="gi">+ current_frame_addr = get_frame_base (get_selected_frame ());</span> if (current_frame_addr > 0) { *lower_bound = <span class="gu">@@ -100,7 +100,7 @@ f77_get_dynamic_lowerbound (struct type </span> break; case BOUND_BY_REF_ON_STACK: <span class="gd">- current_frame_addr = get_frame_base (deprecated_selected_frame);</span> <span class="gi">+ current_frame_addr = get_frame_base (get_selected_frame ());</span> if (current_frame_addr > 0) { ptr_to_lower_bound = <span class="gu">@@ -134,7 +134,7 @@ f77_get_dynamic_upperbound (struct type </span> switch (TYPE_ARRAY_UPPER_BOUND_TYPE (type)) { case BOUND_BY_VALUE_ON_STACK: <span class="gd">- current_frame_addr = get_frame_base (deprecated_selected_frame);</span> <span class="gi">+ current_frame_addr = get_frame_base (get_selected_frame ());</span> if (current_frame_addr > 0) { *upper_bound = <span class="gu">@@ -163,7 +163,7 @@ f77_get_dynamic_upperbound (struct type </span> break; case BOUND_BY_REF_ON_STACK: <span class="gd">- current_frame_addr = get_frame_base (deprecated_selected_frame);</span> <span class="gi">+ current_frame_addr = get_frame_base (get_selected_frame ());</span> if (current_frame_addr > 0) { ptr_to_upper_bound = <span class="gu">@@ -630,10 +630,7 @@ info_common_command (char *comname, int </span> first make sure that it is visible and if so, let us display its contents */ <span class="gd">- fi = deprecated_selected_frame;</span> <span class="gd">-</span> <span class="gd">- if (fi == NULL)</span> <span class="gd">- error ("No frame selected");</span> <span class="gi">+ fi = get_selected_frame ();</span> /* The following is generally ripped off from stack.c's routine print_frame_info() */ <span class="gu">@@ -722,10 +719,7 @@ there_is_a_visible_common_named (char *c</span> if (comname == NULL) error ("Cannot deal with NULL common name!"); <span class="gd">- fi = deprecated_selected_frame;</span> <span class="gd">-</span> <span class="gd">- if (fi == NULL)</span> <span class="gd">- error ("No frame selected");</span> <span class="gi">+ fi = get_selected_frame ();</span> /* The following is generally ripped off from stack.c's routine print_frame_info() */ <span class="gh">Index: gdb-6.3/gdb/infcmd.c</span> <span class="gh">===================================================================</span> <span class="gd">--- gdb-6.3.orig/gdb/infcmd.c 2004-09-13 14:26:28.000000000 -0400</span> <span class="gi">+++ gdb-6.3/gdb/infcmd.c 2004-11-09 22:57:37.274099559 -0500</span> <span class="gu">@@ -1214,10 +1214,8 @@ finish_command (char *arg, int from_tty)</span> error ("The \"finish\" command does not take any arguments."); if (!target_has_execution) error ("The program is not running."); <span class="gd">- if (deprecated_selected_frame == NULL)</span> <span class="gd">- error ("No selected frame.");</span> <span class="gd">- frame = get_prev_frame (deprecated_selected_frame);</span> <span class="gi">+ frame = get_prev_frame (get_selected_frame ());</span> if (frame == 0) error ("\"finish\" not meaningful in the outermost frame."); <span class="gu">@@ -1235,7 +1233,7 @@ finish_command (char *arg, int from_tty)</span> /* Find the function we will return from. */ <span class="gd">- function = find_pc_function (get_frame_pc (deprecated_selected_frame));</span> <span class="gi">+ function = find_pc_function (get_frame_pc (get_selected_frame ()));</span> /* Print info on the selected frame, including level number but not source. */ <span class="gu">@@ -1600,13 +1598,11 @@ registers_info (char *addr_exp, int fpre</span> if (!target_has_registers) error ("The program has no registers now."); <span class="gd">- if (deprecated_selected_frame == NULL)</span> <span class="gd">- error ("No selected frame.");</span> if (!addr_exp) { gdbarch_print_registers_info (current_gdbarch, gdb_stdout, <span class="gd">- deprecated_selected_frame, -1, fpregs);</span> <span class="gi">+ get_selected_frame (), -1, fpregs);</span> return; } <span class="gu">@@ -1644,7 +1640,7 @@ registers_info (char *addr_exp, int fpre</span> if (regnum >= 0) { gdbarch_print_registers_info (current_gdbarch, gdb_stdout, <span class="gd">- deprecated_selected_frame, regnum, fpregs);</span> <span class="gi">+ get_selected_frame (), regnum, fpregs);</span> continue; } } <span class="gu">@@ -1658,7 +1654,7 @@ registers_info (char *addr_exp, int fpre</span> && regnum < NUM_REGS + NUM_PSEUDO_REGS) { gdbarch_print_registers_info (current_gdbarch, gdb_stdout, <span class="gd">- deprecated_selected_frame, regnum, fpregs);</span> <span class="gi">+ get_selected_frame (), regnum, fpregs);</span> continue; } } <span class="gu">@@ -1684,7 +1680,7 @@ registers_info (char *addr_exp, int fpre</span> if (gdbarch_register_reggroup_p (current_gdbarch, regnum, group)) gdbarch_print_registers_info (current_gdbarch, <span class="gd">- gdb_stdout, deprecated_selected_frame,</span> <span class="gi">+ gdb_stdout, get_selected_frame (),</span> regnum, fpregs); } continue; <span class="gu">@@ -1714,8 +1710,6 @@ print_vector_info (struct gdbarch *gdbar</span> { if (!target_has_registers) error ("The program has no registers now."); <span class="gd">- if (deprecated_selected_frame == NULL)</span> <span class="gd">- error ("No selected frame.");</span> if (gdbarch_print_vector_info_p (gdbarch)) gdbarch_print_vector_info (gdbarch, file, frame, args); <span class="gu">@@ -1740,7 +1734,7 @@ print_vector_info (struct gdbarch *gdbar</span> static void vector_info (char *args, int from_tty) { <span class="gd">- print_vector_info (current_gdbarch, gdb_stdout, deprecated_selected_frame, args);</span> <span class="gi">+ print_vector_info (current_gdbarch, gdb_stdout, get_selected_frame (), args);</span> } <span class="gu">@@ -1910,8 +1904,6 @@ print_float_info (struct gdbarch *gdbarc</span> { if (!target_has_registers) error ("The program has no registers now."); <span class="gd">- if (deprecated_selected_frame == NULL)</span> <span class="gd">- error ("No selected frame.");</span> if (gdbarch_print_float_info_p (gdbarch)) gdbarch_print_float_info (gdbarch, file, frame, args); <span class="gu">@@ -1937,7 +1929,7 @@ No floating-point info available for thi</span> static void float_info (char *args, int from_tty) { <span class="gd">- print_float_info (current_gdbarch, gdb_stdout, deprecated_selected_frame, args);</span> <span class="gi">+ print_float_info (current_gdbarch, gdb_stdout, get_selected_frame (), args);</span> } static void <span class="gh">Index: gdb-6.3/gdb/inflow.c</span> <span class="gh">===================================================================</span> <span class="gd">--- gdb-6.3.orig/gdb/inflow.c 2004-08-11 05:00:57.000000000 -0400</span> <span class="gi">+++ gdb-6.3/gdb/inflow.c 2004-11-09 22:58:37.488338883 -0500</span> <span class="gu">@@ -591,10 +591,7 @@ kill_command (char *arg, int from_tty)</span> if (target_has_stack) { printf_filtered ("In %s,\n", target_longname); <span class="gd">- if (deprecated_selected_frame == NULL)</span> <span class="gd">- fputs_filtered ("No selected stack frame.\n", gdb_stdout);</span> <span class="gd">- else</span> <span class="gd">- print_stack_frame (get_selected_frame (), 1, SRC_AND_LOC);</span> <span class="gi">+ print_stack_frame (get_selected_frame (), 1, SRC_AND_LOC);</span> } bfd_cache_close_all (); } <span class="gh">Index: gdb-6.3/gdb/infrun.c</span> <span class="gh">===================================================================</span> <span class="gd">--- gdb-6.3.orig/gdb/infrun.c 2004-09-27 13:58:08.000000000 -0400</span> <span class="gi">+++ gdb-6.3/gdb/infrun.c 2004-11-09 22:51:07.351240752 -0500</span> <span class="gu">@@ -3485,7 +3485,7 @@ save_inferior_status (int restore_stack_</span> inf_status->registers = regcache_dup (current_regcache); <span class="gd">- inf_status->selected_frame_id = get_frame_id (deprecated_selected_frame);</span> <span class="gi">+ inf_status->selected_frame_id = get_frame_id (get_selected_frame ());</span> return inf_status; } <span class="gh">Index: gdb-6.3/gdb/mi/mi-main.c</span> <span class="gh">===================================================================</span> <span class="gd">--- gdb-6.3.orig/gdb/mi/mi-main.c 2004-09-12 11:00:42.000000000 -0400</span> <span class="gi">+++ gdb-6.3/gdb/mi/mi-main.c 2004-11-09 22:53:29.998389013 -0500</span> <span class="gu">@@ -388,7 +388,7 @@ register_changed_p (int regnum)</span> { char raw_buffer[MAX_REGISTER_SIZE]; <span class="gd">- if (! frame_register_read (deprecated_selected_frame, regnum, raw_buffer))</span> <span class="gi">+ if (! frame_register_read (get_selected_frame (), regnum, raw_buffer))</span> return -1; if (memcmp (&old_regs[DEPRECATED_REGISTER_BYTE (regnum)], raw_buffer, <span class="gu">@@ -509,7 +509,7 @@ get_register (int regnum, int format)</span> if (format == 'N') format = 0; <span class="gd">- frame_register (deprecated_selected_frame, regnum, &optim, &lval, &addr,</span> <span class="gi">+ frame_register (get_selected_frame (), regnum, &optim, &lval, &addr,</span> &realnum, buffer); if (optim) <span class="gh">Index: gdb-6.3/gdb/mn10300-tdep.c</span> <span class="gh">===================================================================</span> <span class="gd">--- gdb-6.3.orig/gdb/mn10300-tdep.c 2004-08-02 22:02:22.000000000 -0400</span> <span class="gi">+++ gdb-6.3/gdb/mn10300-tdep.c 2004-11-09 22:51:07.356239776 -0500</span> <span class="gu">@@ -1154,7 +1154,7 @@ mn10300_print_register (const char *name</span> printf_filtered ("%s: ", name); /* Get the data */ <span class="gd">- if (!frame_register_read (deprecated_selected_frame, regnum, raw_buffer))</span> <span class="gi">+ if (!frame_register_read (get_selected_frame (), regnum, raw_buffer))</span> { printf_filtered ("[invalid]"); return; <span class="gh">Index: gdb-6.3/gdb/stack.c</span> <span class="gh">===================================================================</span> <span class="gd">--- gdb-6.3.orig/gdb/stack.c 2004-08-02 20:57:26.000000000 -0400</span> <span class="gi">+++ gdb-6.3/gdb/stack.c 2004-11-09 22:51:07.361238800 -0500</span> <span class="gu">@@ -758,9 +758,7 @@ parse_frame_specification (char *frame_e</span> switch (numargs) { case 0: <span class="gd">- if (deprecated_selected_frame == NULL)</span> <span class="gd">- error ("No selected frame.");</span> <span class="gd">- return deprecated_selected_frame;</span> <span class="gi">+ return get_selected_frame ();</span> /* NOTREACHED */ case 1: { <span class="gu">@@ -902,10 +900,10 @@ frame_info (char *addr_exp, int from_tty</span> } calling_frame_info = get_prev_frame (fi); <span class="gd">- if (!addr_exp && frame_relative_level (deprecated_selected_frame) >= 0)</span> <span class="gi">+ if (!addr_exp && frame_relative_level (get_selected_frame ()) >= 0)</span> { printf_filtered ("Stack level %d, frame at ", <span class="gd">- frame_relative_level (deprecated_selected_frame));</span> <span class="gi">+ frame_relative_level (get_selected_frame ()));</span> print_address_numeric (get_frame_base (fi), 1, gdb_stdout); printf_filtered (":\n"); } <span class="gu">@@ -1445,9 +1443,7 @@ print_frame_label_vars (struct frame_inf</span> void locals_info (char *args, int from_tty) { <span class="gd">- if (!deprecated_selected_frame)</span> <span class="gd">- error ("No frame selected.");</span> <span class="gd">- print_frame_local_vars (deprecated_selected_frame, 0, gdb_stdout);</span> <span class="gi">+ print_frame_local_vars (get_selected_frame (), 0, gdb_stdout);</span> } static void <span class="gu">@@ -1470,7 +1466,7 @@ catch_info (char *ignore, int from_tty)</span> if (!deprecated_selected_frame) error ("No frame selected."); <span class="gd">- print_frame_label_vars (deprecated_selected_frame, 0, gdb_stdout);</span> <span class="gi">+ print_frame_label_vars (get_selected_frame (), 0, gdb_stdout);</span> } } <span class="gu">@@ -1537,9 +1533,7 @@ print_frame_arg_vars (struct frame_info </span> void args_info (char *ignore, int from_tty) { <span class="gd">- if (!deprecated_selected_frame)</span> <span class="gd">- error ("No frame selected.");</span> <span class="gd">- print_frame_arg_vars (deprecated_selected_frame, gdb_stdout);</span> <span class="gi">+ print_frame_arg_vars (get_selected_frame (), gdb_stdout);</span> } <span class="gu">@@ -1724,7 +1718,7 @@ down_silently_base (char *count_exp)</span> if (target_has_stack == 0 || deprecated_selected_frame == 0) error ("No stack."); <span class="gd">- frame = find_relative_frame (deprecated_selected_frame, &count1);</span> <span class="gi">+ frame = find_relative_frame (get_selected_frame (), &count1);</span> if (count1 != 0 && count_exp == 0) { <span class="gu">@@ -1944,7 +1938,7 @@ func_command (char *arg, int from_tty)</span> if (!found) printf_filtered ("'%s' not within current stack frame.\n", arg); <span class="gd">- else if (fp != deprecated_selected_frame)</span> <span class="gi">+ else if (fp != get_selected_frame ())</span> select_and_print_frame (fp); } <span class="gu">@@ -1965,7 +1959,7 @@ get_frame_language (void)</span> instruction of another function. So we rely on get_frame_address_in_block(), it provides us with a PC which is guaranteed to be inside the frame's code block. */ <span class="gd">- s = find_pc_symtab (get_frame_address_in_block (deprecated_selected_frame));</span> <span class="gi">+ s = find_pc_symtab (get_frame_address_in_block (get_selected_frame ()));</span> if (s) flang = s->language; else <span class="gh">Index: gdb-6.3/gdb/tui/tui-disasm.c</span> <span class="gh">===================================================================</span> <span class="gd">--- gdb-6.3.orig/gdb/tui/tui-disasm.c 2004-02-24 20:10:01.000000000 -0500</span> <span class="gi">+++ gdb-6.3/gdb/tui/tui-disasm.c 2004-11-09 22:51:07.370237044 -0500</span> <span class="gu">@@ -382,7 +382,7 @@ tui_vertical_disassem_scroll (enum tui_s</span> content = (tui_win_content) TUI_DISASM_WIN->generic.content; if (cursal.symtab == (struct symtab *) NULL) <span class="gd">- s = find_pc_symtab (get_frame_pc (deprecated_selected_frame));</span> <span class="gi">+ s = find_pc_symtab (get_frame_pc (get_selected_frame ()));</span> else s = cursal.symtab; <span class="gh">Index: gdb-6.3/gdb/tui/tui-source.c</span> <span class="gh">===================================================================</span> <span class="gd">--- gdb-6.3.orig/gdb/tui/tui-source.c 2004-02-16 16:05:09.000000000 -0500</span> <span class="gi">+++ gdb-6.3/gdb/tui/tui-source.c 2004-11-09 22:51:07.370237044 -0500</span> <span class="gu">@@ -326,7 +326,7 @@ tui_vertical_source_scroll (enum tui_scr</span> struct symtab_and_line cursal = get_current_source_symtab_and_line (); if (cursal.symtab == (struct symtab *) NULL) <span class="gd">- s = find_pc_symtab (get_frame_pc (deprecated_selected_frame));</span> <span class="gi">+ s = find_pc_symtab (get_frame_pc (get_selected_frame ()));</span> else s = cursal.symtab; <span class="gh">Index: gdb-6.3/gdb/tui/tui-winsource.c</span> <span class="gh">===================================================================</span> <span class="gd">--- gdb-6.3.orig/gdb/tui/tui-winsource.c 2004-02-16 16:05:09.000000000 -0500</span> <span class="gi">+++ gdb-6.3/gdb/tui/tui-winsource.c 2004-11-09 22:51:07.371236848 -0500</span> <span class="gu">@@ -311,7 +311,7 @@ tui_horizontal_source_scroll (struct tui</span> struct symtab_and_line cursal = get_current_source_symtab_and_line (); if (cursal.symtab == (struct symtab *) NULL) <span class="gd">- s = find_pc_symtab (get_frame_pc (deprecated_selected_frame));</span> <span class="gi">+ s = find_pc_symtab (get_frame_pc (get_selected_frame ()));</span> else s = cursal.symtab; <span class="gh">Index: gdb-6.3/gdb/valops.c</span> <span class="gh">===================================================================</span> <span class="gd">--- gdb-6.3.orig/gdb/valops.c 2004-09-13 23:01:48.000000000 -0400</span> <span class="gi">+++ gdb-6.3/gdb/valops.c 2004-11-09 22:51:07.374236263 -0500</span> <span class="gu">@@ -2663,15 +2663,10 @@ value_of_local (const char *name, int co</span> struct block *b; struct value * ret; <span class="gd">- if (deprecated_selected_frame == 0)</span> <span class="gd">- {</span> <span class="gd">- if (complain)</span> <span class="gd">- error ("no frame selected");</span> <span class="gd">- else</span> <span class="gd">- return 0;</span> <span class="gd">- }</span> <span class="gi">+ if (!complain && deprecated_selected_frame == 0)</span> <span class="gi">+ return 0;</span> <span class="gd">- func = get_frame_function (deprecated_selected_frame);</span> <span class="gi">+ func = get_frame_function (get_selected_frame ());</span> if (!func) { if (complain) <span class="gu">@@ -2700,7 +2695,7 @@ value_of_local (const char *name, int co</span> return NULL; } <span class="gd">- ret = read_var_value (sym, deprecated_selected_frame);</span> <span class="gi">+ ret = read_var_value (sym, get_selected_frame ());</span> if (ret == 0 && complain) error ("`%s' argument unreadable", name); return ret; <span class="gh">Index: gdb-6.3/gdb/varobj.c</span> <span class="gh">===================================================================</span> <span class="gd">--- gdb-6.3.orig/gdb/varobj.c 2004-07-26 10:53:06.000000000 -0400</span> <span class="gi">+++ gdb-6.3/gdb/varobj.c 2004-11-09 22:51:07.377235677 -0500</span> <span class="gu">@@ -488,7 +488,7 @@ varobj_create (char *objname,</span> if (fi != NULL) { var->root->frame = get_frame_id (fi); <span class="gd">- old_fi = deprecated_selected_frame;</span> <span class="gi">+ old_fi = get_selected_frame ();</span> select_frame (fi); } <span class="gh">Index: gdb-6.3/gdb/testsuite/gdb.base/default.exp</span> <span class="gh">===================================================================</span> <span class="gd">--- gdb-6.3.orig/gdb/testsuite/gdb.base/default.exp 2003-03-20 09:45:50.000000000 -0500</span> <span class="gi">+++ gdb-6.3/gdb/testsuite/gdb.base/default.exp 2004-11-09 22:51:07.379235287 -0500</span> <span class="gu">@@ -167,7 +167,7 @@ gdb_test "disable breakpoints" "" "disab</span> #test disable display gdb_test "disable display" "" "disable display" #test disassemble <span class="gd">-gdb_test "disassemble" "No frame selected." "disassemble"</span> <span class="gi">+gdb_test "disassemble" "No (frame selected|registers)." "disassemble"</span> #test display gdb_test "display" "" "display" #test do <span class="gu">@@ -229,9 +229,9 @@ gdb_expect {</span> } #test frame "f" abbreviation <span class="gd">-gdb_test "f" "No stack." "frame \"f\" abbreviation"</span> <span class="gi">+gdb_test "f" "No (stack|registers)." "frame \"f\" abbreviation"</span> #test frame <span class="gd">-gdb_test "frame" "No stack." "frame"</span> <span class="gi">+gdb_test "frame" "No (stack|registers)." "frame"</span> #test fg gdb_test "fg" "The program is not being run." "fg" # FIXME: fg kills the udi connection <span class="gu">@@ -294,9 +294,9 @@ gdb_test "ignore" "Argument required .a </span> #test info address gdb_test "info address" "Argument required." "info address" #test info all-registers <span class="gd">-gdb_test "info all-registers" "The program has no registers now." "info all-registers"</span> <span class="gi">+gdb_test "info all-registers" "(The program has no registers now|No registers)." "info all-registers"</span> #test info args <span class="gd">-gdb_test "info args" "No frame selected." "info args"</span> <span class="gi">+gdb_test "info args" "No (frame selected|registers)." "info args"</span> #test info bogus-gdb-command gdb_test "info bogus-gdb-command" "Undefined info command: \"bogus-gdb-command\". Try \"help info\".*" "info bogus-gdb-command" #test info breakpoints <span class="gu">@@ -320,11 +320,11 @@ gdb_test "info frame" "No stack.|No sele</span> #test info files gdb_test "info files" "" "info files" #test info float <span class="gd">-gdb_test "info float" "The program has no registers now." "info float"</span> <span class="gi">+gdb_test "info float" "(The program has no registers now|No registers)." "info float"</span> #test info functions gdb_test "info functions" "All defined functions:" "info functions" #test info locals <span class="gd">-gdb_test "info locals" "No frame selected." "info locals"</span> <span class="gi">+gdb_test "info locals" "(No frame selected|No registers)." "info locals"</span> #test info program gdb_test "info program" "The program being debugged is not being run." "info program" #test info registers <span class="gu">@@ -352,7 +352,7 @@ gdb_test "info types" "All defined types</span> #test info variables gdb_test "info variables" "All defined variables:" "info variables" #test info vector <span class="gd">-gdb_test "info vector" "The program has no registers now." "info vector"</span> <span class="gi">+gdb_test "info vector" "(The program has no registers now|No registers)." "info vector"</span> #test info warranty gdb_test "info warranty" "NO WARRANTY(\[^\r\n\]*\[\r\n\])+ *11. *BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY(\[^\r\n\]*\[\r\n\])+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN(\[^\r\n\]*\[\r\n\])+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES(\[^\r\n\]*\[\r\n\])+PROVIDE THE PROGRAM \"AS IS\" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED(\[^\r\n\]*\[\r\n\])+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF(\[^\r\n\]*\[\r\n\])+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS(\[^\r\n\]*\[\r\n\])+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE(\[^\r\n\]*\[\r\n\])+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,(\[^\r\n\]*\[\r\n\])+REPAIR OR CORRECTION.(\[^\r\n\]*\[\r\n\])+ *12. *IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING(\[^\r\n\]*\[\r\n\])+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR(\[^\r\n\]*\[\r\n\])+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,(\[^\r\n\]*\[\r\n\])+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING(\[^\r\n\]*\[\r\n\])+OUT OF THE USE OR INABILITY TO USE THE PROGRAM .INCLUDING BUT NOT LIMITED(\[^\r\n\]*\[\r\n\])+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY(\[^\r\n\]*\[\r\n\])+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER(\[^\r\n\]*\[\r\n\])+PROGRAMS., EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE(\[^\r\n\]*\[\r\n\])+POSSIBILITY OF SUCH DAMAGES.*" "info warranty" #test info watchpoints </pre></div> </code></pre></td></tr></table> </div> <!-- class=content --> <div class='footer'>generated by <a href='https://git.zx2c4.com/cgit/about/'>cgit v1.2.3</a> (<a href='https://git-scm.com/'>git 2.25.1</a>) at 2025-03-07 07:03:19 +0000</div> </div> <!-- id=cgit --> </body> </html>