Skip to content

Commit 82cb5a5

Browse files
committed
---
yaml --- r: 124647 b: refs/heads/try c: 06c7ee9 h: refs/heads/master i: 124645: 23985ca 124643: 7979e90 124639: 1c2f4d7 v: v3
1 parent 4529eec commit 82cb5a5

File tree

90 files changed

+3601
-273
lines changed

Some content is hidden

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

90 files changed

+3601
-273
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: f15d6d28396e8700b6c3f2704204a2769e710403
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 9fc8394d3bce22ab483f98842434c84c396212ae
5-
refs/heads/try: 80ef6b83ef68713a255ee29b8ce326b5145e2135
5+
refs/heads/try: 06c7ee9c56f7c768be94c89f699527b44be664ab
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c

branches/try/src/compiletest/compiletest.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ use std::io::fs;
3030
use std::from_str::FromStr;
3131
use getopts::{optopt, optflag, reqopt};
3232
use common::Config;
33-
use common::{Pretty, DebugInfoGdb, Codegen};
33+
use common::{Pretty, DebugInfoGdb, DebugInfoLldb, Codegen};
3434
use util::logv;
3535
use regex::Regex;
3636

@@ -241,6 +241,16 @@ pub fn run_tests(config: &Config) {
241241
os::setenv("RUST_TEST_TASKS","1");
242242
}
243243

244+
match config.mode {
245+
DebugInfoLldb => {
246+
// Some older versions of LLDB seem to have problems with multiple
247+
// instances running in parallel, so only run one test task at a
248+
// time.
249+
os::setenv("RUST_TEST_TASKS", "1");
250+
}
251+
_ => { /* proceed */ }
252+
}
253+
244254
let opts = test_opts(config);
245255
let tests = make_tests(config);
246256
// sadly osx needs some file descriptor limits raised for running tests in

branches/try/src/compiletest/runtest.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -536,6 +536,16 @@ fn run_debuginfo_lldb_test(config: &Config, props: &TestProps, testfile: &Path)
536536
// We don't want to hang when calling `quit` while the process is still running
537537
let mut script_str = String::from_str("settings set auto-confirm true\n");
538538

539+
// Make LLDB emit its version, so we have it documented in the test output
540+
script_str.push_str("version\n");
541+
542+
// Switch LLDB into "Rust mode"
543+
script_str.push_str("command script import ./src/etc/lldb_rust_formatters.py\n");
544+
script_str.push_str("type summary add --no-value ");
545+
script_str.push_str("--python-function lldb_rust_formatters.print_val ");
546+
script_str.push_str("-x \".*\" --category Rust\n");
547+
script_str.push_str("type category enable Rust\n");
548+
539549
// Set breakpoints on every line that contains the string "#break"
540550
for line in breakpoint_lines.iter() {
541551
script_str.push_str(format!("breakpoint set --line {}\n",

branches/try/src/etc/lldb_batchmode.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,6 @@
3131
import re
3232
import atexit
3333

34-
# Terminate the debugger
35-
atexit.register(lambda: lldb.SBDebugger.Terminate())
36-
3734
# Set this to True for additional output
3835
DEBUG_OUTPUT = False
3936

Lines changed: 232 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,232 @@
1+
# Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2+
# file at the top-level directory of this distribution and at
3+
# http://rust-lang.org/COPYRIGHT.
4+
#
5+
# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
# http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
# <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
# option. This file may not be copied, modified, or distributed
9+
# except according to those terms.
10+
11+
import lldb
12+
13+
def print_val(val, internal_dict):
14+
'''Prints the given value with Rust syntax'''
15+
type_class = val.GetType().GetTypeClass()
16+
17+
if type_class == lldb.eTypeClassStruct:
18+
return print_struct_val(val, internal_dict)
19+
20+
if type_class == lldb.eTypeClassUnion:
21+
return print_enum_val(val, internal_dict)
22+
23+
if type_class == lldb.eTypeClassPointer:
24+
return print_pointer_val(val, internal_dict)
25+
26+
if type_class == lldb.eTypeClassArray:
27+
return print_fixed_size_vec_val(val, internal_dict)
28+
29+
return val.GetValue()
30+
31+
32+
#=--------------------------------------------------------------------------------------------------
33+
# Type-Specialized Printing Functions
34+
#=--------------------------------------------------------------------------------------------------
35+
36+
def print_struct_val(val, internal_dict):
37+
'''Prints a struct, tuple, or tuple struct value with Rust syntax'''
38+
assert val.GetType().GetTypeClass() == lldb.eTypeClassStruct
39+
40+
if is_vec_slice(val):
41+
return print_vec_slice_val(val, internal_dict)
42+
else:
43+
return print_struct_val_starting_from(0, val, internal_dict)
44+
45+
def print_vec_slice_val(val, internal_dict):
46+
output = "&["
47+
48+
length = val.GetChildAtIndex(1).GetValueAsUnsigned()
49+
50+
data_ptr_val = val.GetChildAtIndex(0)
51+
data_ptr_type = data_ptr_val.GetType()
52+
assert data_ptr_type.IsPointerType()
53+
54+
element_type = data_ptr_type.GetPointeeType()
55+
element_type_size = element_type.GetByteSize()
56+
57+
start_address = data_ptr_val.GetValueAsUnsigned()
58+
59+
for i in range(length):
60+
address = start_address + i * element_type_size
61+
element_val = val.CreateValueFromAddress( val.GetName() + ("[%s]" % i), address, element_type )
62+
output += print_val(element_val, internal_dict)
63+
64+
if i != length - 1:
65+
output += ", "
66+
67+
output += "]"
68+
return output
69+
70+
def print_struct_val_starting_from(field_start_index, val, internal_dict):
71+
'''
72+
Prints a struct, tuple, or tuple struct value with Rust syntax.
73+
Ignores any fields before field_start_index.
74+
'''
75+
assert val.GetType().GetTypeClass() == lldb.eTypeClassStruct
76+
77+
t = val.GetType()
78+
has_field_names = type_has_field_names(t)
79+
type_name = extract_type_name(t.GetName())
80+
output = ""
81+
82+
if not type_name.startswith("("):
83+
# this is a tuple, so don't print the type name
84+
output += type_name
85+
86+
if has_field_names:
87+
output += " { \n"
88+
else:
89+
output += "("
90+
91+
num_children = val.num_children
92+
93+
for child_index in range(field_start_index, num_children):
94+
if has_field_names:
95+
field_name = t.GetFieldAtIndex(child_index).GetName()
96+
output += field_name + ": "
97+
98+
field_val = val.GetChildAtIndex(child_index)
99+
output += print_val(field_val, internal_dict)
100+
101+
if child_index != num_children - 1:
102+
output += ", "
103+
104+
if has_field_names:
105+
output += "\n"
106+
107+
if has_field_names:
108+
output += "}"
109+
else:
110+
output += ")"
111+
112+
return output
113+
114+
115+
def print_enum_val(val, internal_dict):
116+
'''Prints an enum value with Rust syntax'''
117+
118+
assert val.GetType().GetTypeClass() == lldb.eTypeClassUnion
119+
120+
if val.num_children == 1:
121+
first_variant_name = val.GetChildAtIndex(0).GetName()
122+
if first_variant_name and first_variant_name.startswith("RUST$ENCODED$ENUM$"):
123+
# Try to extract the
124+
125+
last_separator_index = first_variant_name.rfind("$")
126+
if last_separator_index == -1:
127+
return "<invalid enum encoding: %s>" % first_variant_name
128+
129+
second_last_separator_index = first_variant_name.rfind("$", 0, last_separator_index)
130+
if second_last_separator_index == -1:
131+
return "<invalid enum encoding: %s>" % first_variant_name
132+
133+
try:
134+
disr_field_index = first_variant_name[second_last_separator_index + 1 :
135+
last_separator_index]
136+
disr_field_index = int(disr_field_index)
137+
except:
138+
return "<invalid enum encoding: %s>" % first_variant_name
139+
140+
disr_val = val.GetChildAtIndex(0).GetChildAtIndex(disr_field_index).GetValueAsUnsigned()
141+
142+
if disr_val == 0:
143+
null_variant_name = first_variant_name[last_separator_index + 1:]
144+
return null_variant_name
145+
else:
146+
return print_struct_val_starting_from(0, val.GetChildAtIndex(0), internal_dict)
147+
else:
148+
return print_struct_val_starting_from(0, val.GetChildAtIndex(0), internal_dict)
149+
150+
# extract the discriminator value by
151+
disr_val = val.GetChildAtIndex(0).GetChildAtIndex(0)
152+
disr_type = disr_val.GetType()
153+
154+
if disr_type.GetTypeClass() != lldb.eTypeClassEnumeration:
155+
return "<Invalid enum value encountered: Discriminator is not an enum>"
156+
157+
variant_index = disr_val.GetValueAsUnsigned()
158+
return print_struct_val_starting_from(1, val.GetChildAtIndex(variant_index), internal_dict)
159+
160+
161+
def print_pointer_val(val, internal_dict):
162+
'''Prints a pointer value with Rust syntax'''
163+
assert val.GetType().IsPointerType()
164+
sigil = "&"
165+
type_name = extract_type_name(val.GetType().GetName())
166+
if type_name and type_name[0:1] in ["&", "~", "*"]:
167+
sigil = type_name[0:1]
168+
169+
return sigil + hex(val.GetValueAsUnsigned()) #print_val(val.Dereference(), internal_dict)
170+
171+
172+
def print_fixed_size_vec_val(val, internal_dict):
173+
assert val.GetType().GetTypeClass() == lldb.eTypeClassArray
174+
175+
output = "["
176+
177+
for i in range(val.num_children):
178+
output += print_val(val.GetChildAtIndex(i), internal_dict)
179+
if i != val.num_children - 1:
180+
output += ", "
181+
182+
output += "]"
183+
return output
184+
185+
186+
#=--------------------------------------------------------------------------------------------------
187+
# Helper Functions
188+
#=--------------------------------------------------------------------------------------------------
189+
190+
unqualified_type_markers = frozenset(["(", "[", "&", "*"])
191+
192+
def extract_type_name(qualified_type_name):
193+
'''Extracts the type name from a fully qualified path'''
194+
if qualified_type_name[0] in unqualified_type_markers:
195+
return qualified_type_name
196+
197+
end_of_search = qualified_type_name.find("<")
198+
if end_of_search < 0:
199+
end_of_search = len(qualified_type_name)
200+
201+
index = qualified_type_name.rfind("::", 0, end_of_search)
202+
if index < 0:
203+
return qualified_type_name
204+
else:
205+
return qualified_type_name[index + 2:]
206+
207+
208+
def type_has_field_names(ty):
209+
'''Returns true of this is a type with field names (struct, struct-like enum variant)'''
210+
# This may also be an enum variant where the first field doesn't have a name but the rest has
211+
if ty.GetNumberOfFields() > 1:
212+
return ty.GetFieldAtIndex(1).GetName() != None
213+
else:
214+
return ty.GetFieldAtIndex(0).GetName() != None
215+
216+
217+
def is_vec_slice(val):
218+
ty = val.GetType()
219+
if ty.GetTypeClass() != lldb.eTypeClassStruct:
220+
return False
221+
222+
if ty.GetNumberOfFields() != 2:
223+
return False
224+
225+
if ty.GetFieldAtIndex(0).GetName() != "data_ptr":
226+
return False
227+
228+
if ty.GetFieldAtIndex(1).GetName() != "length":
229+
return False
230+
231+
type_name = extract_type_name(ty.GetName()).replace("&'static", "&").replace(" ", "")
232+
return type_name.startswith("&[") and type_name.endswith("]")

branches/try/src/etc/vim/doc/rust.txt

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
*rust.txt* Filetype plugin for Rust
22

33
==============================================================================
4-
CONTENTS *rust*
4+
CONTENTS *rust* *ft-rust*
55

66
1. Introduction |rust-intro|
77
2. Settings |rust-settings|
@@ -53,6 +53,18 @@ g:rust_conceal_pub~
5353
let g:rust_conceal_pub = 1
5454
<
5555

56+
*g:rust_fold*
57+
g:rust_fold~
58+
Set this option to turn on |folding|: >
59+
let g:rust_fold = 1
60+
<
61+
Value Effect ~
62+
0 No folding
63+
1 Braced blocks are folded. All folds are open by
64+
default.
65+
2 Braced blocks are folded. 'foldlevel' is left at the
66+
global value (all folds are closed by default).
67+
5668
*g:rust_bang_comment_leader*
5769
g:rust_bang_comment_leader~
5870
Set this option to 1 to preserve the leader on multi-line doc comments

branches/try/src/etc/vim/ftplugin/rust.vim

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
" Description: Vim syntax file for Rust
33
" Maintainer: Chris Morgan <[email protected]>
44
" Maintainer: Kevin Ballard <[email protected]>
5-
" Last Change: May 27, 2014
5+
" Last Change: Jul 07, 2014
66

77
if exists("b:did_ftplugin")
88
finish
@@ -35,7 +35,9 @@ silent! setlocal formatoptions+=j
3535
" otherwise it's better than nothing.
3636
setlocal smartindent nocindent
3737

38-
setlocal tabstop=4 shiftwidth=4 expandtab
38+
setlocal tabstop=4 shiftwidth=4 softtabstop=4 expandtab
39+
40+
setlocal textwidth=99
3941

4042
" This includeexpr isn't perfect, but it's a good start
4143
setlocal includeexpr=substitute(v:fname,'::','/','g')
@@ -93,7 +95,8 @@ endif
9395
" Cleanup {{{1
9496

9597
let b:undo_ftplugin = "
96-
\setlocal formatoptions< comments< commentstring< includeexpr< suffixesadd<
98+
\ setlocal formatoptions< comments< commentstring< includeexpr< suffixesadd<
99+
\|setlocal tabstop< shiftwidth< softtabstop< expandtab< textwidth<
97100
\|if exists('b:rust_original_delimitMate_excluded_regions')
98101
\|let b:delimitMate_excluded_regions = b:rust_original_delimitMate_excluded_regions
99102
\|unlet b:rust_original_delimitMate_excluded_regions

branches/try/src/etc/vim/syntax/rust.vim

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,25 @@
33
" Maintainer: Patrick Walton <[email protected]>
44
" Maintainer: Ben Blum <[email protected]>
55
" Maintainer: Chris Morgan <[email protected]>
6-
" Last Change: 2014 Feb 27
6+
" Last Change: July 06, 2014
77

88
if version < 600
99
syntax clear
1010
elseif exists("b:current_syntax")
1111
finish
1212
endif
1313

14+
" Fold settings {{{1
15+
16+
if has("folding") && exists('g:rust_fold') && g:rust_fold != 0
17+
setlocal foldmethod=syntax
18+
if g:rust_fold == 2
19+
setlocal foldlevel<
20+
else
21+
setlocal foldlevel=99
22+
endif
23+
endif
24+
1425
" Syntax definitions {{{1
1526
" Basic keywords {{{2
1627
syn keyword rustConditional match if else
@@ -213,8 +224,6 @@ syn keyword rustTodo contained TODO FIXME XXX NB NOTE
213224
" Trivial folding rules to begin with.
214225
" TODO: use the AST to make really good folding
215226
syn region rustFoldBraces start="{" end="}" transparent fold
216-
" If you wish to enable this, setlocal foldmethod=syntax
217-
" It's not enabled by default as it would drive some people mad.
218227

219228
" Default highlighting {{{1
220229
hi def link rustDecNumber rustNumber

0 commit comments

Comments
 (0)