Skip to content

Commit 69d86b4

Browse files
---
yaml --- r: 128842 b: refs/heads/try c: 910dd26 h: refs/heads/master v: v3
1 parent 641d785 commit 69d86b4

File tree

5 files changed

+73
-4
lines changed

5 files changed

+73
-4
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: 07d86b46a949a94223da714e35b343243e4ecce4
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: a86d9ad15e339ab343a12513f9c90556f677b9ca
5-
refs/heads/try: 406de8d5dd07bb898c9c4db438dd35829b7a6c25
5+
refs/heads/try: 910dd2635c0defac0f64cd62fe7a3f22dc41bdba
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c

branches/try/src/doc/rust.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1928,8 +1928,6 @@ interpreted:
19281928

19291929
### Miscellaneous attributes
19301930

1931-
- `export_name` - on statics and functions, this determines the name of the
1932-
exported symbol.
19331931
- `link_section` - on statics and functions, this specifies the section of the
19341932
object file that this item's contents will be placed into.
19351933
- `macro_export` - export a macro for cross-crate usage.

branches/try/src/librustc/lint/builtin.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -568,7 +568,6 @@ impl LintPass for UnusedAttribute {
568568
// FIXME: #14406 these are processed in trans, which happens after the
569569
// lint pass
570570
"cold",
571-
"export_name",
572571
"inline",
573572
"link",
574573
"link_name",
@@ -579,6 +578,7 @@ impl LintPass for UnusedAttribute {
579578
"packed",
580579
"static_assert",
581580
"thread_local",
581+
"no_debug",
582582

583583
// not used anywhere (!?) but apparently we want to keep them around
584584
"comment",

branches/try/src/librustc/middle/trans/debuginfo.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1128,6 +1128,10 @@ pub fn create_function_debug_context(cx: &CrateContext,
11281128

11291129
let (ident, fn_decl, generics, top_level_block, span, has_path) = match fnitem {
11301130
ast_map::NodeItem(ref item) => {
1131+
if contains_nodebug_attribute(item.attrs.as_slice()) {
1132+
return FunctionDebugContext { repr: FunctionWithoutDebugInfo };
1133+
}
1134+
11311135
match item.node {
11321136
ast::ItemFn(fn_decl, _, _, ref generics, top_level_block) => {
11331137
(item.ident, fn_decl, generics, top_level_block, item.span, true)
@@ -1141,6 +1145,12 @@ pub fn create_function_debug_context(cx: &CrateContext,
11411145
ast_map::NodeImplItem(ref item) => {
11421146
match **item {
11431147
ast::MethodImplItem(ref method) => {
1148+
if contains_nodebug_attribute(method.attrs.as_slice()) {
1149+
return FunctionDebugContext {
1150+
repr: FunctionWithoutDebugInfo
1151+
};
1152+
}
1153+
11441154
(method.pe_ident(),
11451155
method.pe_fn_decl(),
11461156
method.pe_generics(),
@@ -1173,6 +1183,12 @@ pub fn create_function_debug_context(cx: &CrateContext,
11731183
ast_map::NodeTraitItem(ref trait_method) => {
11741184
match **trait_method {
11751185
ast::ProvidedMethod(ref method) => {
1186+
if contains_nodebug_attribute(method.attrs.as_slice()) {
1187+
return FunctionDebugContext {
1188+
repr: FunctionWithoutDebugInfo
1189+
};
1190+
}
1191+
11761192
(method.pe_ident(),
11771193
method.pe_fn_decl(),
11781194
method.pe_generics(),
@@ -3169,6 +3185,16 @@ fn set_debug_location(cx: &CrateContext, debug_location: DebugLocation) {
31693185
// Utility Functions
31703186
//=-----------------------------------------------------------------------------
31713187

3188+
fn contains_nodebug_attribute(attributes: &[ast::Attribute]) -> bool {
3189+
attributes.iter().any(|attr| {
3190+
let meta_item: &ast::MetaItem = &*attr.node.value;
3191+
match meta_item.node {
3192+
ast::MetaWord(ref value) => value.get() == "no_debug",
3193+
_ => false
3194+
}
3195+
})
3196+
}
3197+
31723198
/// Return codemap::Loc corresponding to the beginning of the span
31733199
fn span_start(cx: &CrateContext, span: Span) -> codemap::Loc {
31743200
cx.sess().codemap().lookup_char_pos(span.lo)
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
// Copyright 2013-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+
// ignore-android: FIXME(#10381)
12+
// ignore-lldb
13+
14+
// compile-flags:-g
15+
16+
// gdb-command:break 'no-debug-attribute.rs':32
17+
// gdb-command:break 'no-debug-attribute.rs':38
18+
// gdb-command:run
19+
20+
// gdb-command:info locals
21+
// gdb-check:No locals.
22+
// gdb-command:continue
23+
24+
// gdb-command:info locals
25+
// gdb-check:abc = 10
26+
// gdb-command:continue
27+
28+
#![allow(unused_variable)]
29+
30+
fn function_with_debuginfo() {
31+
let abc = 10u;
32+
return (); // #break
33+
}
34+
35+
#[no_debug]
36+
fn function_without_debuginfo() {
37+
let abc = -57i32;
38+
return (); // #break
39+
}
40+
41+
fn main() {
42+
function_without_debuginfo();
43+
function_with_debuginfo();
44+
}
45+

0 commit comments

Comments
 (0)