Skip to content

Commit 140d6fd

Browse files
committed
Switch "." to "_" in name mangling, makes gdb happier. Also factor out into sep() helper.
1 parent f17a342 commit 140d6fd

File tree

1 file changed

+18
-14
lines changed

1 file changed

+18
-14
lines changed

src/comp/middle/trans.rs

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,10 @@ tag block_parent {
121121
state type result = rec(mutable @block_ctxt bcx,
122122
mutable ValueRef val);
123123

124+
fn sep() -> str {
125+
ret "_";
126+
}
127+
124128
fn res(@block_ctxt bcx, ValueRef val) -> result {
125129
ret rec(mutable bcx = bcx,
126130
mutable val = val);
@@ -1104,7 +1108,7 @@ fn make_generic_glue(@crate_ctxt cx, @ty.t t, str name,
11041108
vec[ast.def_id] typaram_defs) -> ValueRef {
11051109
auto llfnty = T_glue_fn();
11061110

1107-
auto fn_name = cx.names.next("_rust_" + name) + "." + ty.ty_to_str(t);
1111+
auto fn_name = cx.names.next("_rust_" + name) + sep() + ty.ty_to_str(t);
11081112
fn_name = sanitize(fn_name);
11091113
auto llfn = decl_fastcall_fn(cx.llmod, fn_name, llfnty);
11101114

@@ -2498,7 +2502,7 @@ fn trans_bind_thunk(@crate_ctxt cx,
24982502
// Construct a thunk-call with signature incoming_fty, and that copies
24992503
// args forward into a call to outgoing_fty.
25002504

2501-
let str s = cx.names.next("_rust_thunk") + "." + cx.path;
2505+
let str s = cx.names.next("_rust_thunk") + sep() + cx.path;
25022506
let TypeRef llthunk_ty = get_pair_fn_ty(type_of(cx, incoming_fty));
25032507
let ValueRef llthunk = decl_fastcall_fn(cx.llmod, s, llthunk_ty);
25042508

@@ -3592,10 +3596,10 @@ fn trans_vtbl(@crate_ctxt cx, TypeRef self_ty,
35923596
}
35933597
}
35943598

3595-
let @crate_ctxt mcx = @rec(path=cx.path + "." + m.node.ident
3599+
let @crate_ctxt mcx = @rec(path=cx.path + sep() + m.node.ident
35963600
with *cx);
35973601

3598-
let str s = cx.names.next("_rust_method") + "." + mcx.path;
3602+
let str s = cx.names.next("_rust_method") + sep() + mcx.path;
35993603
let ValueRef llfn = decl_fastcall_fn(cx.llmod, s, llfnty);
36003604
cx.item_ids.insert(m.node.id, llfn);
36013605

@@ -3606,7 +3610,7 @@ fn trans_vtbl(@crate_ctxt cx, TypeRef self_ty,
36063610
auto vtbl = C_struct(methods);
36073611
auto gvar = llvm.LLVMAddGlobal(cx.llmod,
36083612
val_ty(vtbl),
3609-
_str.buf("_rust_vtbl" + "." + cx.path));
3613+
_str.buf("_rust_vtbl" + sep() + cx.path));
36103614
llvm.LLVMSetInitializer(gvar, vtbl);
36113615
llvm.LLVMSetGlobalConstant(gvar, True);
36123616
llvm.LLVMSetLinkage(gvar, lib.llvm.LLVMPrivateLinkage
@@ -3837,29 +3841,29 @@ fn trans_const(@crate_ctxt cx, @ast.expr e,
38373841
fn trans_item(@crate_ctxt cx, &ast.item item) {
38383842
alt (item.node) {
38393843
case (ast.item_fn(?name, ?f, ?tps, ?fid, ?ann)) {
3840-
auto sub_cx = @rec(path=cx.path + "." + name with *cx);
3844+
auto sub_cx = @rec(path=cx.path + sep() + name with *cx);
38413845
trans_fn(sub_cx, f, fid, none[TypeRef], tps, ann);
38423846
}
38433847
case (ast.item_obj(?name, ?ob, ?tps, ?oid, ?ann)) {
3844-
auto sub_cx = @rec(path=cx.path + "." + name,
3848+
auto sub_cx = @rec(path=cx.path + sep() + name,
38453849
obj_typarams=tps,
38463850
obj_fields=ob.fields with *cx);
38473851
trans_obj(sub_cx, ob, oid, tps, ann);
38483852
}
38493853
case (ast.item_mod(?name, ?m, _)) {
3850-
auto sub_cx = @rec(path=cx.path + "." + name with *cx);
3854+
auto sub_cx = @rec(path=cx.path + sep() + name with *cx);
38513855
trans_mod(sub_cx, m);
38523856
}
38533857
case (ast.item_tag(?name, ?variants, ?tps, ?tag_id)) {
3854-
auto sub_cx = @rec(path=cx.path + "." + name with *cx);
3858+
auto sub_cx = @rec(path=cx.path + sep() + name with *cx);
38553859
auto i = 0;
38563860
for (ast.variant variant in variants) {
38573861
trans_tag_variant(sub_cx, tag_id, variant, i, tps);
38583862
i += 1;
38593863
}
38603864
}
38613865
case (ast.item_const(?name, _, ?expr, ?cid, ?ann)) {
3862-
auto sub_cx = @rec(path=cx.path + "." + name with *cx);
3866+
auto sub_cx = @rec(path=cx.path + sep() + name with *cx);
38633867
trans_const(sub_cx, expr, cid, ann);
38643868
}
38653869
case (_) { /* fall through */ }
@@ -3890,11 +3894,11 @@ fn decl_fn_and_pair(@crate_ctxt cx,
38903894
auto llfty = get_pair_fn_ty(llpairty);
38913895

38923896
// Declare the function itself.
3893-
let str s = cx.names.next("_rust_" + kind) + "." + name;
3897+
let str s = cx.names.next("_rust_" + kind) + sep() + name;
38943898
let ValueRef llfn = decl_fastcall_fn(cx.llmod, s, llfty);
38953899

38963900
// Declare the global constant pair that points to it.
3897-
let str ps = cx.names.next("_rust_" + kind + "_pair") + "." + name;
3901+
let str ps = cx.names.next("_rust_" + kind + "_pair") + sep() + name;
38983902
let ValueRef gvar = llvm.LLVMAddGlobal(cx.llmod, llpairty,
38993903
_str.buf(ps));
39003904
auto pair = C_struct(vec(llfn,
@@ -4208,8 +4212,8 @@ fn trans_main_fn(@crate_ctxt cx, ValueRef llcrate) {
42084212

42094213
auto llargc = llvm.LLVMGetParam(llmain, 0u);
42104214
auto llargv = llvm.LLVMGetParam(llmain, 1u);
4211-
check (cx.item_names.contains_key("_rust.main"));
4212-
auto llrust_main = cx.item_names.get("_rust.main");
4215+
check (cx.item_names.contains_key("_rust" + sep() + "main"));
4216+
auto llrust_main = cx.item_names.get("_rust" + sep() + "main");
42134217

42144218
//
42154219
// Emit the moral equivalent of:

0 commit comments

Comments
 (0)