Skip to content

Lldb cleanups #19166

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Nov 23, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions src/compiletest/runtest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1161,7 +1161,7 @@ fn compile_test_(config: &Config, props: &TestProps,
let args = make_compile_args(config,
props,
link_args,
|a, b| ThisFile(make_exe_name(a, b)), testfile);
|a, b| TargetLocation::ThisFile(make_exe_name(a, b)), testfile);
compose_and_run_compiler(config, props, testfile, args, None)
}

Expand Down Expand Up @@ -1219,7 +1219,7 @@ fn compose_and_run_compiler(
crate_type,
|a,b| {
let f = make_lib_name(a, b, testfile);
ThisDirectory(f.dir_path())
TargetLocation::ThisDirectory(f.dir_path())
},
&abs_ab);
let auxres = compose_and_run(config,
Expand Down Expand Up @@ -1296,11 +1296,11 @@ fn make_compile_args(config: &Config,
args.push("prefer-dynamic".to_string());
}
let path = match xform_file {
ThisFile(path) => {
TargetLocation::ThisFile(path) => {
args.push("-o".to_string());
path
}
ThisDirectory(path) => {
TargetLocation::ThisDirectory(path) => {
args.push("--out-dir".to_string());
path
}
Expand Down Expand Up @@ -1672,7 +1672,8 @@ fn compile_test_and_save_bitcode(config: &Config, props: &TestProps,
let args = make_compile_args(config,
props,
link_args,
|a, b| ThisDirectory(output_base_name(a, b).dir_path()),
|a, b| TargetLocation::ThisDirectory(
output_base_name(a, b).dir_path()),
testfile);
compose_and_run_compiler(config, props, testfile, args, None)
}
Expand Down
52 changes: 21 additions & 31 deletions src/etc/lldb_rust_formatters.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ def print_struct_val(val, internal_dict):
return print_struct_val_starting_from(0, val, internal_dict)

def print_vec_slice_val(val, internal_dict):
output = "&["

length = val.GetChildAtIndex(1).GetValueAsUnsigned()

data_ptr_val = val.GetChildAtIndex(0)
Expand All @@ -56,16 +54,12 @@ def print_vec_slice_val(val, internal_dict):

start_address = data_ptr_val.GetValueAsUnsigned()

for i in range(length):
def render_element(i):
address = start_address + i * element_type_size
element_val = val.CreateValueFromAddress( val.GetName() + ("[%s]" % i), address, element_type )
output += print_val(element_val, internal_dict)

if i != length - 1:
output += ", "
element_val = val.CreateValueFromAddress( val.GetName() + ("[%s]" % i), address, element_type)
return print_val(element_val, internal_dict)

output += "]"
return output
return "&[%s]" % (', '.join([render_element(i) for i in range(length)]))

def print_struct_val_starting_from(field_start_index, val, internal_dict):
'''
Expand All @@ -77,39 +71,33 @@ def print_struct_val_starting_from(field_start_index, val, internal_dict):
t = val.GetType()
has_field_names = type_has_field_names(t)
type_name = extract_type_name(t.GetName())
output = ""

if not type_name.startswith("("):
# this is a tuple, so don't print the type name
output += type_name

if has_field_names:
output += " { \n"
template = "%(type_name)s {\n%(body)s\n}"
separator = ", \n"
else:
output += "("
template = "%(type_name)s(%(body)s)"
separator = ", "

if type_name.startswith("("):
# this is a tuple, so don't print the type name
type_name = ""

num_children = val.num_children

for child_index in range(field_start_index, num_children):
def render_child(child_index):
this = ""
if has_field_names:
field_name = t.GetFieldAtIndex(child_index).GetName()
output += field_name + ": "
this += field_name + ": "

field_val = val.GetChildAtIndex(child_index)
output += print_val(field_val, internal_dict)
return this + print_val(field_val, internal_dict)

if child_index != num_children - 1:
output += ", "

if has_field_names:
output += "\n"

if has_field_names:
output += "}"
else:
output += ")"
body = separator.join([render_child(idx) for idx in range(field_start_index, num_children)])

return output
return template % {"type_name": type_name,
"body": body}


def print_enum_val(val, internal_dict):
Expand Down Expand Up @@ -243,3 +231,5 @@ def is_vec_slice(val):

type_name = extract_type_name(ty.GetName()).replace("&'static", "&").replace(" ", "")
return type_name.startswith("&[") and type_name.endswith("]")

# vi: sw=2:ts=2
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't comment on that since I don't know the first thing about vi :)