Skip to content

Commit 542d68f

Browse files
committed
---
yaml --- r: 137578 b: refs/heads/master c: dfd5281 h: refs/heads/master v: v3
1 parent 3fd614d commit 542d68f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+539
-206
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 6fa5a2f66fddd473d265e646b41da43d20e87ec2
2+
refs/heads/master: dfd52817ee81676e0cdba4ab2c5badf195fcfda7
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: cd53dac86b43e0b46f06ab265b71526242a2fc5e

trunk/configure

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -535,13 +535,17 @@ probe CFG_LLDB lldb
535535

536536
if [ ! -z "$CFG_GDB" ]
537537
then
538-
# Extract the version
538+
# Store GDB's version
539539
CFG_GDB_VERSION=$($CFG_GDB --version 2>/dev/null | head -1)
540540
putvar CFG_GDB_VERSION
541541
fi
542542

543543
if [ ! -z "$CFG_LLDB" ]
544544
then
545+
# Store LLDB's version
546+
CFG_LLDB_VERSION=$($CFG_LLDB --version 2>/dev/null | head -1)
547+
putvar CFG_LLDB_VERSION
548+
545549
# If CFG_LLDB_PYTHON_DIR is not already set from the outside and valid, try to read it from
546550
# LLDB via the -P commandline options.
547551
if [ -z "$CFG_LLDB_PYTHON_DIR" ] || [ ! -d "$CFG_LLDB_PYTHON_DIR" ]

trunk/mk/tests.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -625,6 +625,7 @@ CTEST_COMMON_ARGS$(1)-T-$(2)-H-$(3) := \
625625
--target $(2) \
626626
--host $(3) \
627627
--gdb-version="$(CFG_GDB_VERSION)" \
628+
--lldb-version="$(CFG_LLDB_VERSION)" \
628629
--android-cross-path=$(CFG_ANDROID_CROSS_PATH) \
629630
--adb-path=$(CFG_ADB) \
630631
--adb-test-dir=$(CFG_ADB_TEST_DIR) \

trunk/src/compiletest/common.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,9 @@ pub struct Config {
133133
// Version of GDB
134134
pub gdb_version: Option<String>,
135135

136+
// Version of LLDB
137+
pub lldb_version: Option<String>,
138+
136139
// Path to the android tools
137140
pub android_cross_path: Path,
138141

trunk/src/compiletest/compiletest.rs

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ pub fn parse_config(args: Vec<String> ) -> Config {
7171
optflag("", "jit", "run tests under the JIT"),
7272
optopt("", "target", "the target to build for", "TARGET"),
7373
optopt("", "host", "the host to build for", "HOST"),
74-
optopt("", "gdb-version", "the version of GDB used", "MAJOR.MINOR"),
74+
optopt("", "gdb-version", "the version of GDB used", "VERSION STRING"),
75+
optopt("", "lldb-version", "the version of LLDB used", "VERSION STRING"),
7576
optopt("", "android-cross-path", "Android NDK standalone path", "PATH"),
7677
optopt("", "adb-path", "path to the android debugger", "PATH"),
7778
optopt("", "adb-test-dir", "path to tests for the android debugger", "PATH"),
@@ -149,6 +150,7 @@ pub fn parse_config(args: Vec<String> ) -> Config {
149150
target: opt_str2(matches.opt_str("target")),
150151
host: opt_str2(matches.opt_str("host")),
151152
gdb_version: extract_gdb_version(matches.opt_str("gdb-version")),
153+
lldb_version: extract_lldb_version(matches.opt_str("lldb-version")),
152154
android_cross_path: opt_path(matches, "android-cross-path"),
153155
adb_path: opt_str2(matches.opt_str("adb-path")),
154156
adb_test_dir: opt_str2(matches.opt_str("adb-test-dir")),
@@ -391,3 +393,37 @@ fn extract_gdb_version(full_version_line: Option<String>) -> Option<String> {
391393
_ => None
392394
}
393395
}
396+
397+
fn extract_lldb_version(full_version_line: Option<String>) -> Option<String> {
398+
// Extract the major LLDB version from the given version string.
399+
// LLDB version strings are different for Apple and non-Apple platforms.
400+
// At the moment, this function only supports the Apple variant, which looks
401+
// like this:
402+
//
403+
// LLDB-179.5 (older versions)
404+
// lldb-300.2.51 (new versions)
405+
//
406+
// We are only interested in the major version number, so this function
407+
// will return `Some("179")` and `Some("300")` respectively.
408+
409+
match full_version_line {
410+
Some(ref full_version_line)
411+
if full_version_line.as_slice().trim().len() > 0 => {
412+
let full_version_line = full_version_line.as_slice().trim();
413+
414+
let re = Regex::new(r"[Ll][Ll][Dd][Bb]-([0-9]+)").unwrap();
415+
416+
match re.captures(full_version_line) {
417+
Some(captures) => {
418+
Some(captures.at(1).to_string())
419+
}
420+
None => {
421+
println!("Could not extract LLDB version from line '{}'",
422+
full_version_line);
423+
None
424+
}
425+
}
426+
},
427+
_ => None
428+
}
429+
}

trunk/src/compiletest/header.rs

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,14 +181,42 @@ pub fn is_test_ignored(config: &Config, testfile: &Path) -> bool {
181181
}
182182
}
183183

184+
fn ignore_lldb(config: &Config, line: &str) -> bool {
185+
if config.mode != common::DebugInfoLldb {
186+
return false;
187+
}
188+
189+
if parse_name_directive(line, "ignore-lldb") {
190+
return true;
191+
}
192+
193+
match config.lldb_version {
194+
Some(ref actual_version) => {
195+
if line.contains("min-lldb-version") {
196+
let min_version = line.trim()
197+
.split(' ')
198+
.last()
199+
.expect("Malformed lldb version directive");
200+
// Ignore if actual version is smaller the minimum required
201+
// version
202+
lldb_version_to_int(actual_version.as_slice()) <
203+
lldb_version_to_int(min_version.as_slice())
204+
} else {
205+
false
206+
}
207+
}
208+
None => false
209+
}
210+
}
211+
184212
let val = iter_header(testfile, |ln| {
185213
!parse_name_directive(ln, "ignore-test") &&
186214
!parse_name_directive(ln, ignore_target(config).as_slice()) &&
187215
!parse_name_directive(ln, ignore_stage(config).as_slice()) &&
188216
!(config.mode == common::Pretty && parse_name_directive(ln, "ignore-pretty")) &&
189217
!(config.target != config.host && parse_name_directive(ln, "ignore-cross-compile")) &&
190218
!ignore_gdb(config, ln) &&
191-
!(config.mode == common::DebugInfoLldb && parse_name_directive(ln, "ignore-lldb"))
219+
!ignore_lldb(config, ln)
192220
});
193221

194222
!val
@@ -330,3 +358,12 @@ pub fn gdb_version_to_int(version_string: &str) -> int {
330358

331359
return major * 1000 + minor;
332360
}
361+
362+
pub fn lldb_version_to_int(version_string: &str) -> int {
363+
let error_string = format!(
364+
"Encountered LLDB version string with unexpected format: {}",
365+
version_string);
366+
let error_string = error_string.as_slice();
367+
let major: int = FromStr::from_str(version_string).expect(error_string);
368+
return major;
369+
}

trunk/src/compiletest/runtest.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -626,6 +626,17 @@ fn run_debuginfo_lldb_test(config: &Config, props: &TestProps, testfile: &Path)
626626

627627
let exe_file = make_exe_name(config, testfile);
628628

629+
match config.lldb_version {
630+
Some(ref version) => {
631+
println!("NOTE: compiletest thinks it is using LLDB version {}",
632+
version.as_slice());
633+
}
634+
_ => {
635+
println!("NOTE: compiletest does not know which version of \
636+
LLDB it is using");
637+
}
638+
}
639+
629640
// Parse debugger commands etc from test files
630641
let DebuggerCommands {
631642
commands,

trunk/src/doc/guide-macros.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ forbidden.
8787

8888
Otherwise, the invocation syntax is free-form.
8989

90-
To take as an argument a fragment of Rust code, write `$` followed by a name
90+
To take a fragment of Rust code as an argument, write `$` followed by a name
9191
(for use on the right-hand side), followed by a `:`, followed by a *fragment
9292
specifier*. The fragment specifier denotes the sort of fragment to match. The
9393
most common fragment specifiers are:

trunk/src/doc/guide.md

Lines changed: 13 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -5212,8 +5212,8 @@ We can check this out using a special flag to `rustc`. This code, in a file
52125212

52135213
```{rust}
52145214
fn main() {
5215-
let x = "Hello";
5216-
println!("x is: {:s}", x);
5215+
let x = 5i;
5216+
println!("x is: {}", x);
52175217
}
52185218
```
52195219

@@ -5225,32 +5225,19 @@ give us this huge result:
52255225
#![no_std]
52265226
#![feature(globs)]
52275227
#[phase(plugin, link)]
5228-
extern crate std = "std";
5229-
extern crate rt = "native";
5228+
extern crate "std" as std;
5229+
extern crate "native" as rt;
5230+
#[prelude_import]
52305231
use std::prelude::*;
52315232
fn main() {
5232-
let x = "Hello";
5233+
let x = 5i;
52335234
match (&x,) {
52345235
(__arg0,) => {
52355236
#[inline]
52365237
#[allow(dead_code)]
5237-
static __STATIC_FMTSTR: [::std::fmt::rt::Piece<'static>, ..2u] =
5238-
[::std::fmt::rt::String("x is: "),
5239-
::std::fmt::rt::Argument(::std::fmt::rt::Argument{position:
5240-
::std::fmt::rt::ArgumentNext,
5241-
format:
5242-
::std::fmt::rt::FormatSpec{fill:
5243-
' ',
5244-
align:
5245-
::std::fmt::rt::AlignUnknown,
5246-
flags:
5247-
0u,
5248-
precision:
5249-
::std::fmt::rt::CountImplied,
5250-
width:
5251-
::std::fmt::rt::CountImplied,},})];
5238+
static __STATIC_FMTSTR: [&'static str, ..1u] = ["x is: "];
52525239
let __args_vec =
5253-
&[::std::fmt::argument(::std::fmt::secret_string, __arg0)];
5240+
&[::std::fmt::argument(::std::fmt::secret_show, __arg0)];
52545241
let __args =
52555242
unsafe {
52565243
::std::fmt::Arguments::new(__STATIC_FMTSTR, __args_vec)
@@ -5261,45 +5248,16 @@ fn main() {
52615248
}
52625249
```
52635250

5264-
Intense. Here's a trimmed down version that's a bit easier to read:
5265-
5266-
```{rust,ignore}
5267-
fn main() {
5268-
let x = 5i;
5269-
match (&x,) {
5270-
(__arg0,) => {
5271-
static __STATIC_FMTSTR: =
5272-
[String("x is: "),
5273-
Argument(Argument {
5274-
position: ArgumentNext,
5275-
format: FormatSpec {
5276-
fill: ' ',
5277-
align: AlignUnknown,
5278-
flags: 0u,
5279-
precision: CountImplied,
5280-
width: CountImplied,
5281-
},
5282-
},
5283-
];
5284-
let __args_vec = &[argument(secret_string, __arg0)];
5285-
let __args = unsafe { Arguments::new(__STATIC_FMTSTR, __args_vec) };
5286-
5287-
println_args(&__args)
5288-
}
5289-
};
5290-
}
5291-
```
5292-
52935251
Whew! This isn't too terrible. You can see that we still `let x = 5i`,
52945252
but then things get a little bit hairy. Three more bindings get set: a
52955253
static format string, an argument vector, and the arguments. We then
52965254
invoke the `println_args` function with the generated arguments.
52975255

5298-
This is the code (well, the full version) that Rust actually compiles. You can
5299-
see all of the extra information that's here. We get all of the type safety and
5300-
options that it provides, but at compile time, and without needing to type all
5301-
of this out. This is how macros are powerful. Without them, you would need to
5302-
type all of this by hand to get a type checked `println`.
5256+
This is the code that Rust actually compiles. You can see all of the extra
5257+
information that's here. We get all of the type safety and options that it
5258+
provides, but at compile time, and without needing to type all of this out.
5259+
This is how macros are powerful. Without them, you would need to type all of
5260+
this by hand to get a type checked `println`.
53035261

53045262
For more on macros, please consult [the Macros Guide](guide-macros.html).
53055263
Macros are a very advanced and still slightly experimental feature, but don't

trunk/src/doc/reference.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,8 @@ grammar as double-quoted strings. Other tokens have exact rules given.
187187

188188
The keywords are the following strings, organized by first letter:
189189

190+
<div id="keywords">
191+
| | | | |
190192
|----------|--------|--------|-------|
191193
| as | | | |
192194
|----------|--------|--------|-------|
@@ -216,6 +218,7 @@ The keywords are the following strings, organized by first letter:
216218
|----------|--------|--------|-------|
217219
| while | | | |
218220
|----------|--------|--------|-------|
221+
</div>
219222

220223
Each of these keywords has special meaning in its grammar, and all of them are
221224
excluded from the `ident` rule.
@@ -1894,7 +1897,7 @@ type int8_t = i8;
18941897
18951898
### Crate-only attributes
18961899

1897-
- `crate_id` - specify the this crate's crate ID.
1900+
- `crate_name` - specify the this crate's crate name.
18981901
- `crate_type` - see [linkage](#linkage).
18991902
- `feature` - see [compiler features](#compiler-features).
19001903
- `no_builtins` - disable optimizing certain code patterns to invocations of
@@ -1924,6 +1927,8 @@ type int8_t = i8;
19241927
- `start` - indicates that this function should be used as the entry point,
19251928
overriding the "start" language item. See the "start" [language
19261929
item](#language-items) for more details.
1930+
- `test` - indicates that this function is a test function, to only be compiled
1931+
in case of `--test`.
19271932

19281933
### Static-only attributes
19291934

trunk/src/doc/rust.css

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,3 +392,5 @@ pre.rust { position: relative; }
392392
background-color: #fff !important;
393393
}
394394
}
395+
396+
#keywords table td { border: none; }

trunk/src/etc/gdb_rust_pretty_printing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ def classify_struct(type):
196196
if field_count == 0:
197197
return STRUCT_KIND_REGULAR_STRUCT
198198

199-
if fields[0].artificial:
199+
if fields[0].name == "RUST$ENUM$DISR":
200200
if field_count == 1:
201201
return STRUCT_KIND_CSTYLE_VARIANT
202202
elif fields[1].name == None:

trunk/src/etc/lldb_rust_formatters.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,19 @@ def print_enum_val(val, internal_dict):
117117

118118
assert val.GetType().GetTypeClass() == lldb.eTypeClassUnion
119119

120+
120121
if val.num_children == 1:
122+
# This is either an enum with just one variant, or it is an Option-like enum
123+
# where the discriminant is encoded in a non-nullable pointer field. We find
124+
# out which one it is by looking at the member name of the sole union
125+
# variant. If it starts with "RUST$ENCODED$ENUM$" then we have an
126+
# Option-like enum.
121127
first_variant_name = val.GetChildAtIndex(0).GetName()
122128
if first_variant_name and first_variant_name.startswith("RUST$ENCODED$ENUM$"):
123-
# Try to extract the
124129

130+
# This is an Option-like enum. The position of the discriminator field is
131+
# encoded in the name which has the format:
132+
# RUST$ENCODED$ENUM$<index of discriminator field>$<name of null variant>
125133
last_separator_index = first_variant_name.rfind("$")
126134
if last_separator_index == -1:
127135
return "<invalid enum encoding: %s>" % first_variant_name
@@ -130,25 +138,30 @@ def print_enum_val(val, internal_dict):
130138
if second_last_separator_index == -1:
131139
return "<invalid enum encoding: %s>" % first_variant_name
132140

141+
# Extract index of the discriminator field
133142
try:
134143
disr_field_index = first_variant_name[second_last_separator_index + 1 :
135144
last_separator_index]
136145
disr_field_index = int(disr_field_index)
137146
except:
138147
return "<invalid enum encoding: %s>" % first_variant_name
139148

149+
# Read the discriminant
140150
disr_val = val.GetChildAtIndex(0).GetChildAtIndex(disr_field_index).GetValueAsUnsigned()
141151

142152
if disr_val == 0:
153+
# Null case: Print the name of the null-variant
143154
null_variant_name = first_variant_name[last_separator_index + 1:]
144155
return null_variant_name
145156
else:
157+
# Non-null case: Interpret the data as a value of the non-null variant type
146158
return print_struct_val_starting_from(0, val.GetChildAtIndex(0), internal_dict)
147159
else:
160+
# This is just a regular uni-variant enum without discriminator field
148161
return print_struct_val_starting_from(0, val.GetChildAtIndex(0), internal_dict)
149162

150-
# extract the discriminator value by
151-
disr_val = val.GetChildAtIndex(0).GetChildAtIndex(0)
163+
# If we are here, this is a regular enum with more than one variant
164+
disr_val = val.GetChildAtIndex(0).GetChildMemberWithName("RUST$ENUM$DISR")
152165
disr_type = disr_val.GetType()
153166

154167
if disr_type.GetTypeClass() != lldb.eTypeClassEnumeration:

trunk/src/etc/vim/syntax/rust.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ syn match rustMacroRepeatCount ".\?[*+]" contained
5454
syn match rustMacroVariable "$\w\+"
5555

5656
" Reserved (but not yet used) keywords {{{2
57-
syn keyword rustReservedKeyword alignof be do offsetof priv pure sizeof typeof unsized yield
57+
syn keyword rustReservedKeyword alignof be do offsetof priv pure sizeof typeof unsized yield abstract final override
5858

5959
" Built-in types {{{2
6060
syn keyword rustType int uint float char bool u8 u16 u32 u64 f32

0 commit comments

Comments
 (0)