rollup merge of #19954: michaelwoerister/rust-gdb

This pull request adds the `rust-gdb` shell script which starts GDB with Rust pretty printers enabled. The PR also makes `rustc` add a special `.debug_gdb_scripts` ELF section on Linux which tells GDB that the produced binary should use the Rust pretty printers.

Note that at the moment this script will only work and be installed on Linux. On Mac OS X there's `rust-lldb` which works much better there. On Windows I had too many problems making this stable. I'll give it another try soonish.

You can use this script just like you would use GDB from the command line. It will use the pretty printers from the Rust "installation" found first in PATH. E.g. if you have `~/rust/x86_64-linux-gnu/stage1/bin` in your path, it will use the pretty printer scripts in `~/rust/x86_64-linux-gnu/stage1/lib/rustlib/etc`.
This commit is contained in:
Alex Crichton 2014-12-30 16:25:44 -08:00
commit fe64ff1104
101 changed files with 396 additions and 71 deletions

View file

@ -45,6 +45,7 @@
#![allow(unused_variables)]
#![allow(dead_code)]
#![omit_gdb_pretty_printer_section]
static B: bool = false;

View file

@ -50,6 +50,7 @@
// gdb-command:continue
#![allow(unused_variables)]
#![omit_gdb_pretty_printer_section]
static B: bool = false;
static I: int = -1;

View file

@ -48,6 +48,7 @@
// gdb-command:continue
#![allow(unused_variables)]
#![omit_gdb_pretty_printer_section]
fn main() {
let unit: () = ();

View file

@ -83,6 +83,7 @@
// gdb-check:$28 = 9.25
#![allow(unused_variables)]
#![omit_gdb_pretty_printer_section]
static mut B: bool = false;
static mut I: int = -1;

View file

@ -88,6 +88,7 @@
// lldb-check:[...]$12 = 3.5
#![allow(unused_variables)]
#![omit_gdb_pretty_printer_section]
fn main() {
let b: bool = false;

View file

@ -109,6 +109,7 @@
// lldb-check:[...]$12 = 3.5
#![allow(unused_variables)]
#![omit_gdb_pretty_printer_section]
fn main() {
let bool_val: bool = true;

View file

@ -41,6 +41,7 @@
// lldb-check:[...]$2 = TheC
#![allow(unused_variables)]
#![omit_gdb_pretty_printer_section]
enum ABC { TheA, TheB, TheC }

View file

@ -40,6 +40,7 @@
// lldb-check:[...]$2 = TheOnlyCase(4820353753753434)
#![allow(unused_variables)]
#![omit_gdb_pretty_printer_section]
// The first element is to ensure proper alignment, irrespective of the machines word size. Since
// the size of the discriminant value is machine dependent, this has be taken into account when

View file

@ -64,6 +64,7 @@
// lldb-check:[...]$6 = 26.5
#![allow(unused_variables)]
#![omit_gdb_pretty_printer_section]
struct SomeStruct {
x: int,

View file

@ -42,6 +42,7 @@
#![allow(unused_variables)]
#![omit_gdb_pretty_printer_section]
fn main() {
let stack_val: (i16, f32) = (-14, -19f32);

View file

@ -112,7 +112,7 @@
// lldb-check:[...]$12 = 3.5
#![allow(unused_variables)]
#![omit_gdb_pretty_printer_section]
fn main() {
let bool_box: Box<bool> = box true;

View file

@ -32,6 +32,7 @@
// lldb-check:[...]$1 = (2, 3.5)
#![allow(unused_variables)]
#![omit_gdb_pretty_printer_section]
fn main() {
let a = box 1i;

View file

@ -35,6 +35,7 @@
// lldb-check:[...]$1 = StructWithDestructor { x: 77, y: 777, z: 7777, w: 77777 }
#![allow(unused_variables)]
#![omit_gdb_pretty_printer_section]
struct StructWithSomePadding {
x: i16,

View file

@ -71,6 +71,8 @@
// lldb-check:[...]$6 = Case1 { x: 0, y: 8970181431921507452 }
// lldb-command:continue
#![omit_gdb_pretty_printer_section]
#[deriving(Clone)]
struct Struct {
a: int,

View file

@ -46,6 +46,8 @@
// lldb-check:[...]$2 = (4444.5, 5555, 6666, 7777.5)
// lldb-command:continue
#![omit_gdb_pretty_printer_section]
trait Trait {
fn method(self) -> Self;
}

View file

@ -65,6 +65,7 @@
// lldb-check:[...]$6 = (StructWithDrop { a: OneHundred, b: Vienna }, 9)
#![allow(unused_variables)]
#![omit_gdb_pretty_printer_section]
use self::AnEnum::{OneHundred, OneThousand, OneMillion};
use self::AnotherEnum::{MountainView, Toronto, Vienna};

View file

@ -99,6 +99,7 @@
#![allow(unused_variables)]
#![allow(dead_code)]
#![omit_gdb_pretty_printer_section]
use self::AutoDiscriminant::{One, Two, Three};
use self::ManualDiscriminant::{OneHundred, OneThousand, OneMillion};

View file

@ -46,6 +46,8 @@
// lldb-check:[...]$3 = 110
// lldb-command:continue
#![omit_gdb_pretty_printer_section]
fn some_generic_fun<T1, T2>(a: T1, b: T2) -> (T2, T1) {
let closure = |x, y| {

View file

@ -311,6 +311,7 @@
// lldb-command:continue
#![allow(unused_variables)]
#![omit_gdb_pretty_printer_section]
use self::Univariant::Unit;

View file

@ -152,6 +152,9 @@
// lldb-check:[...]$23 = (34903493, 232323)
// lldb-command:continue
#![allow(unused_variables)]
#![omit_gdb_pretty_printer_section]
struct Struct {
x: i16,
y: f32,

View file

@ -244,6 +244,7 @@
#![allow(unused_variables)]
#![omit_gdb_pretty_printer_section]
use self::Univariant::Unit;

View file

@ -51,6 +51,7 @@
// lldb-check:[...]$4 = StructPaddedAtEnd { x: [22, 23], y: [24, 25] }
#![allow(unused_variables)]
#![omit_gdb_pretty_printer_section]
struct NoPadding1 {
x: [u32; 3],

View file

@ -222,10 +222,8 @@
// lldb-command:continue
#![allow(unused_variables)]
#![omit_gdb_pretty_printer_section]
fn immediate_args(a: int, b: bool, c: f64) {
::std::io::print("") // #break

View file

@ -45,6 +45,9 @@
// lldb-check:[...]$3 = 3000
// lldb-command:continue
#![omit_gdb_pretty_printer_section]
fn main() {
fun(111102, true);

View file

@ -245,6 +245,7 @@
// lldb-command:continue
#![allow(unused_variables)]
#![omit_gdb_pretty_printer_section]
#[no_stack_check]
fn immediate_args(a: int, b: bool, c: f64) {

View file

@ -126,6 +126,7 @@
// lldb-command:continue
#![allow(unused_variables)]
#![omit_gdb_pretty_printer_section]
fn immediate_args(a: int, b: bool, c: f64) {
()

View file

@ -17,7 +17,6 @@
// ignore-lldb
// ignore-android: FIXME(#10381)
// compile-flags:-g
// gdb-use-pretty-printer
// gdb-command: run

View file

@ -13,7 +13,6 @@
// ignore-lldb
// ignore-android: FIXME(#10381)
// compile-flags:-g
// gdb-use-pretty-printer
// This test uses some GDB Python API features (e.g. accessing anonymous fields)
// which are only available in newer GDB version. The following directive will

View file

@ -70,6 +70,7 @@
// lldb-check:[...]$8 = ((5, Struct { a: 6, b: 7.5 }), (Struct { a: 6, b: 7.5 }, 5))
// lldb-command:continue
#![omit_gdb_pretty_printer_section]
#[deriving(Clone)]
struct Struct {

View file

@ -70,6 +70,9 @@
// lldb-check:[...]$7 = 2.5
// lldb-command:continue
#![omit_gdb_pretty_printer_section]
fn outer<TA: Clone>(a: TA) {
inner(a.clone(), 1i);
inner(a.clone(), 2.5f64);

View file

@ -112,6 +112,7 @@
// lldb-check:[...]$14 = -10.5
// lldb-command:continue
#![omit_gdb_pretty_printer_section]
struct Struct<T> {
x: T

View file

@ -31,6 +31,9 @@
// gdb-check:$5 = 5
// gdb-command:continue
#![omit_gdb_pretty_printer_section]
struct Struct {
x: int
}

View file

@ -29,6 +29,9 @@
// gdb-command:print univariant
// gdb-check:$4 = {{a = -1}}
#![omit_gdb_pretty_printer_section]
use self::Regular::{Case1, Case2, Case3};
use self::Univariant::TheOnlyCase;

View file

@ -41,6 +41,9 @@
// lldb-command:print float_int_float
// lldb-check:[...]$3 = AGenericStruct<f64, generic-struct::AGenericStruct<int, f64>> { key: 6.5, value: AGenericStruct<int, f64> { key: 7, value: 8.5 } }
#![omit_gdb_pretty_printer_section]
struct AGenericStruct<TKey, TValue> {
key: TKey,
value: TValue

View file

@ -25,6 +25,7 @@
// gdb-check:$4 = {3.5, {4, 5, 6}}
// gdb-command:continue
#![omit_gdb_pretty_printer_section]
struct Struct {
x: int

View file

@ -48,6 +48,8 @@
// lldb-command:print univariant
// lldb-check:[...]$3 = TheOnlyCase(-1)
#![omit_gdb_pretty_printer_section]
use self::Regular::{Case1, Case2, Case3};
use self::Univariant::TheOnlyCase;

View file

@ -36,6 +36,7 @@
// lldb-command:continue
#![allow(unused_variables)]
#![omit_gdb_pretty_printer_section]
// This test case makes sure that debug info does not ICE when include_str is
// used multiple times (see issue #11322).

View file

@ -16,9 +16,11 @@
// gdb-command:run
// gdb-command:next
// gdb-check:[...]32[...]s
// gdb-check:[...]34[...]s
// gdb-command:continue
#![omit_gdb_pretty_printer_section]
// IF YOU MODIFY THIS FILE, BE CAREFUL TO ADAPT THE LINE NUMBERS IN THE DEBUGGER COMMANDS
// This test makes sure that gdb does not set unwanted breakpoints in inlined functions. If a

View file

@ -86,6 +86,8 @@
// lldb-check:[...]$6 = 1000000
// lldb-command:continue
#![omit_gdb_pretty_printer_section]
fn main() {
let range = [1i, 2, 3];

View file

@ -134,6 +134,7 @@
// lldb-check:[...]$15 = -1
// lldb-command:continue
#![omit_gdb_pretty_printer_section]
fn main() {

View file

@ -126,6 +126,7 @@
// lldb-check:[...]$17 = 232
// lldb-command:continue
#![omit_gdb_pretty_printer_section]
struct Struct {
x: int,

View file

@ -70,6 +70,8 @@
// lldb-check:[...]$5 = false
// lldb-command:continue
#![omit_gdb_pretty_printer_section]
fn main() {
let x = false;

View file

@ -132,6 +132,8 @@
// lldb-check:[...]$12 = 2
// lldb-command:continue
#![omit_gdb_pretty_printer_section]
fn main() {
let mut x = 0i;

View file

@ -70,6 +70,9 @@
// lldb-check:[...]$5 = false
// lldb-command:continue
#![omit_gdb_pretty_printer_section]
fn main() {
let x = false;

View file

@ -132,6 +132,7 @@
// lldb-check:[...]$12 = 2
// lldb-command:continue
#![omit_gdb_pretty_printer_section]
fn main() {

View file

@ -112,6 +112,7 @@
#![feature(macro_rules)]
#![omit_gdb_pretty_printer_section]
macro_rules! trivial {
($e1:expr) => ($e1)

View file

@ -349,6 +349,7 @@
#![allow(unused_variables)]
#![allow(unused_assignments)]
#![omit_gdb_pretty_printer_section]
static mut MUT_INT: int = 0;

View file

@ -30,6 +30,7 @@
#![allow(unused_variables)]
#![omit_gdb_pretty_printer_section]
struct Struct {
a: i64,

View file

@ -113,6 +113,8 @@
// lldb-check:[...]$14 = -10
// lldb-command:continue
#![omit_gdb_pretty_printer_section]
enum Enum {
Variant1 { x: u16, y: u16 },
Variant2 (u32)

View file

@ -113,6 +113,8 @@
// lldb-command:continue
#![omit_gdb_pretty_printer_section]
struct Struct<T> {
x: T
}

View file

@ -112,6 +112,9 @@
// lldb-check:[...]$14 = -10
// lldb-command:continue
#![omit_gdb_pretty_printer_section]
struct Struct {
x: int
}

View file

@ -112,6 +112,9 @@
// lldb-check:[...]$14 = -10
// lldb-command:continue
#![omit_gdb_pretty_printer_section]
struct Struct {
x: int
}

View file

@ -112,6 +112,9 @@
// lldb-check:[...]$14 = -10
// lldb-command:continue
#![omit_gdb_pretty_printer_section]
struct TupleStruct(int, f64);
impl TupleStruct {

View file

@ -45,6 +45,7 @@
// lldb-check:[...]$2 = 30303
#![allow(unused_variables)]
#![omit_gdb_pretty_printer_section]
fn function_one() {
let abc = 10101i;

View file

@ -45,6 +45,7 @@
// lldb-check:[...]$2 = 30303
#![allow(unused_variables)]
#![omit_gdb_pretty_printer_section]
fn function_one() {
let a = 10101i;

View file

@ -94,6 +94,8 @@
// lldb-check:[...]$11 = 20
// lldb-command:continue
#![omit_gdb_pretty_printer_section]
fn main() {
let x = false;
let y = true;

View file

@ -23,6 +23,7 @@
// gdb-check:$2 = {<No data fields>}
#![allow(unused_variables)]
#![omit_gdb_pretty_printer_section]
enum ANilEnum {}
enum AnotherNilEnum {}

View file

@ -24,6 +24,7 @@
// gdb-command:continue
#![allow(unused_variables)]
#![omit_gdb_pretty_printer_section]
fn function_with_debuginfo() {
let abc = 10u;

View file

@ -68,6 +68,8 @@
// lldb-check:[...]$7 = None
#![omit_gdb_pretty_printer_section]
// If a struct has exactly two variants, one of them is empty, and the other one
// contains a non-nullable pointer, then this value is used as the discriminator.
// The test cases in this file make sure that something readable is generated for

View file

@ -74,6 +74,7 @@
#![allow(unused_variables)]
#![omit_gdb_pretty_printer_section]
#[repr(packed)]
struct Packed {

View file

@ -60,6 +60,7 @@
// lldb-check:[...]$5 = 40
#![allow(unused_variables)]
#![omit_gdb_pretty_printer_section]
#[repr(packed)]
struct Packed {

View file

@ -18,6 +18,7 @@
// is taken from issue #11083.
#![allow(unused_variables)]
#![omit_gdb_pretty_printer_section]
pub struct Window<'a> {
callbacks: WindowCallbacks<'a>

View file

@ -69,6 +69,7 @@
// gdb-command:continue
#![allow(unused_variables)]
#![omit_gdb_pretty_printer_section]
use self::Opt::{Empty, Val};

View file

@ -112,6 +112,7 @@
// lldb-check:[...]$14 = -10
// lldb-command:continue
#![omit_gdb_pretty_printer_section]
struct Struct {
x: int

View file

@ -112,6 +112,7 @@
// lldb-check:[...]$14 = -10.5
// lldb-command:continue
#![omit_gdb_pretty_printer_section]
struct Struct {
x: int

View file

@ -58,6 +58,9 @@
// lldb-check:[...]$5 = 20
// lldb-command:continue
#![omit_gdb_pretty_printer_section]
fn a_function(x: bool, y: bool) {
zzz(); // #break
sentinel();

View file

@ -58,6 +58,8 @@
// lldb-check:[...]$5 = 20
// lldb-command:continue
#![omit_gdb_pretty_printer_section]
fn main() {
let x = false;
let y = true;

View file

@ -43,6 +43,7 @@
#![allow(experimental)]
#![allow(unused_variables)]
#![omit_gdb_pretty_printer_section]
use std::simd::{i8x16, i16x8,i32x4,i64x2,u8x16,u16x8,u32x4,u64x2,f32x4,f64x2};

View file

@ -78,6 +78,9 @@
// lldb-check:[...]$6 = false
// lldb-command:continue
#![omit_gdb_pretty_printer_section]
fn main() {
let x = false;

View file

@ -95,8 +95,9 @@
// lldb-command:print padding_at_end
// lldb-check:[...]$5 = PaddingAtEnd { x: -10014, y: 10015 }
#![allow(unused_variables)];
#![allow(dead_code)];
#![allow(unused_variables)]
#![allow(dead_code)]
#![omit_gdb_pretty_printer_section]
struct NoPadding16 {
x: u16,

View file

@ -92,6 +92,7 @@
#![allow(unused_variables)]
#![allow(dead_code)]
#![omit_gdb_pretty_printer_section]
static mut NO_PADDING_8: (i8, u8) = (-50, 50);
static mut NO_PADDING_16: (i16, i16, u16) = (-1, 2, 3);

View file

@ -54,6 +54,8 @@
// lldb-check:[...]$4 = 5
// lldb-command:continue
#![omit_gdb_pretty_printer_section]
struct Struct {
x: int
}

View file

@ -42,6 +42,7 @@
// lldb-check:[...]$2 = TheOnlyCase(Struct { x: 123, y: 456, z: 789 })
#![allow(unused_variables)]
#![omit_gdb_pretty_printer_section]
use self::Regular::{Case1, Case2};
use self::Univariant::TheOnlyCase;

View file

@ -57,6 +57,7 @@
// lldb-check:[...]$7 = Tree { x: Simple { x: 25 }, y: InternalPaddingParent { x: InternalPadding { x: 26, y: 27 }, y: InternalPadding { x: 28, y: 29 }, z: InternalPadding { x: 30, y: 31 } }, z: BagInBag { x: Bag { x: Simple { x: 32 } } } }
#![allow(unused_variables)]
#![omit_gdb_pretty_printer_section]
struct Simple {
x: i32

View file

@ -49,6 +49,7 @@
// lldb-check:[...]$3 = TheOnlyCase { a: -1 }
#![allow(unused_variables)]
#![omit_gdb_pretty_printer_section]
use self::Regular::{Case1, Case2, Case3};
use self::Univariant::TheOnlyCase;

View file

@ -45,6 +45,7 @@
// lldb-check:[...]$3 = NestedOuter { a: NestedInner { a: WithDestructor { x: 7890, y: 9870 } } }
#![allow(unused_variables)]
#![omit_gdb_pretty_printer_section]
struct NoDestructor {
x: i32,

View file

@ -45,6 +45,8 @@
// lldb-check:[...]$3 = (1, 2, 3)
// lldb-command:continue
#![omit_gdb_pretty_printer_section]
struct Struct {
x: int
}

View file

@ -16,6 +16,7 @@
// lldb-command:run
#![allow(unused_variables)]
#![omit_gdb_pretty_printer_section]
trait Trait {
fn method(&self) -> int { 0 }

View file

@ -41,6 +41,7 @@
// gdb-check:$10 = {x = {{40, 41, 42}, {43, 44}}, y = {45, 46, 47, 48}}
#![allow(unused_variables)]
#![omit_gdb_pretty_printer_section]
struct NoPadding1 {
x: (i32, i32),

View file

@ -57,6 +57,7 @@
// lldb-check:[...]$6 = ((21, 22), 23)
#![allow(unused_variables)]
#![omit_gdb_pretty_printer_section]
fn main() {
let no_padding1: ((u32, u32), u32, u32) = ((0, 1), 2, 3);

View file

@ -62,6 +62,9 @@
// to all fields having the name "<unnamed_field>"). Otherwise they are handled the same a normal
// structs.
#![omit_gdb_pretty_printer_section]
struct NoPadding16(u16, i16);
struct NoPadding32(i32, f32, u32);
struct NoPadding64(f64, i64, u64);

View file

@ -49,6 +49,7 @@
// lldb-check:[...]$3 = TheOnlyCase(-1)
#![allow(unused_variables)]
#![omit_gdb_pretty_printer_section]
use self::Regular::{Case1, Case2, Case3};
use self::Univariant::TheOnlyCase;

View file

@ -173,6 +173,8 @@
// gdb-command:whatis stack_closure2
// gdb-check:type = struct (&mut|i8, f32| -> f32, uint)
#![omit_gdb_pretty_printer_section]
use self::Enum1::{Variant1_1, Variant1_2};
use std::ptr;

View file

@ -42,6 +42,7 @@
// lldb-check:[...]$2 = TheOnlyCase(123234)
#![allow(unused_variables)]
#![omit_gdb_pretty_printer_section]
// The first element is to ensure proper alignment, irrespective of the machines word size. Since
// the size of the discriminant value is machine dependent, this has be taken into account when

View file

@ -79,6 +79,7 @@
// lldb-command:continue
#![allow(unused_variables)]
#![omit_gdb_pretty_printer_section]
struct Struct {
a: int,

View file

@ -42,6 +42,7 @@
#![allow(unused_variables)]
#![feature(unboxed_closures)]
#![omit_gdb_pretty_printer_section]
struct Struct {
a: int,

View file

@ -72,6 +72,7 @@
#![feature(unboxed_closures)]
#![allow(unused_variables)]
#![omit_gdb_pretty_printer_section]
struct Struct {
a: int,

View file

@ -78,6 +78,7 @@
#![allow(unused_variables)]
#![feature(slicing_syntax)]
#![omit_gdb_pretty_printer_section]
struct AStruct {
x: i16,

View file

@ -29,6 +29,7 @@
// lldb-check:[...]$0 = [1, 2, 3]
#![allow(unused_variables)]
#![omit_gdb_pretty_printer_section]
static mut VECT: [i32; 3] = [1, 2, 3];