vuvova / gdb-tools

Various tools to improve the gdb experience
BSD 3-Clause "New" or "Revised" License
123 stars 17 forks source link

Option to disable verbosity of output #13

Closed midenok closed 4 years ago

midenok commented 4 years ago

F.ex. I do:

dl dbug_print_fk((FK_info *)el->share->foreign_keys->first-->(next!=?0x21052a8)->info)

and get this output:

dbug_print_fk((FK_info *)el->share->foreign_keys->first->info) = 0x2133a50 <dbug_item_print_buf> "foreign_id: fk_ch1; foreign_db: test; foreign_table: ch1; referenced_db: test; referenced_table: t1; referenced_key_name: fk_ch1; update_method: ???; delete_method: ???; foreign_fields: [0]: xid; referenced_fields: [0]: id"
dbug_print_fk((FK_info *)el->share->foreign_keys->first->(next !=? 0x21052a8)->info) = 0x2133a50 <dbug_item_print_buf> "foreign_id: fk_ch1_2; foreign_db: test; foreign_table: ch1; referenced_db: test; referenced_table: t2; referenced_key_name: fk_ch1_2; update_method: ???; delete_method: ???; foreign_fields: [0]: xid2; referenced_fields: [0]: id"
dbug_print_fk((FK_info *)el->share->foreign_keys->first-->(next !=? 0x21052a8)[[2]]->info) = 0x2133a50 <dbug_item_print_buf> "foreign_id: fk_ch1_3; foreign_db: test; foreign_table: ch1; referenced_db: test; referenced_table: t3; referenced_key_name: fk_ch1_3; update_method: ???; delete_method: ???; foreign_fields: [0]: xid; referenced_fields: [0]: id"

I'd really benefit from shorter output, like this:

0x2133a50 <dbug_item_print_buf> "foreign_id: fk_ch1; foreign_db: test; foreign_table: ch1; referenced_db: test; referenced_table: t1; referenced_key_name: fk_ch1; update_method: ???; delete_method: ???; foreign_fields: [0]: xid; referenced_fields: [0]: id"
0x2133a50 <dbug_item_print_buf> "foreign_id: fk_ch1_2; foreign_db: test; foreign_table: ch1; referenced_db: test; referenced_table: t2; referenced_key_name: fk_ch1_2; update_method: ???; delete_method: ???; foreign_fields: [0]: xid2; referenced_fields: [0]: id"
0x2133a50 <dbug_item_print_buf> "foreign_id: fk_ch1_3; foreign_db: test; foreign_table: ch1; referenced_db: test; referenced_table: t3; referenced_key_name: fk_ch1_3; update_method: ???; delete_method: ???; foreign_fields: [0]: xid; referenced_fields: [0]: id"

Is there such an option?

vuvova commented 4 years ago

Not at the moment, but I often wish there was.

I can add a rule that if the left and right part of the = sign are identical, only one is printed. Like, instead of

(gdb) dl 1..2
1 = 1
2 = 2

it'll be

(gdb) dl 1..2
1
2

or, perhaps,

(gdb) dl 1..2
= 1
= 2

Is that ok? Then if you just want a complex expression with nothing before the =, you simply wrap everything in {...} as documented.

midenok commented 4 years ago

I'd rather prefer some config variable:

import duel;
duel.verbose = false;

or something like that...

vuvova commented 4 years ago

First, duel doesn't have config variables yet. Second, wrapping the expression in {...} allows to disable verbosity only when needed, because often one actually wants to see the expression, and only when it becomes very long or irrelevant one would disable it. And third, config variable or not, it generally doesn't make much sense to print exactly the same value on both sides of =. So even in the verbose mode I'd rather force X = X to be always not verbose.

Should I keep the = sign like in

(gdb) dl 1..2
= 1
= 2

? I think I'd better keep it, otherwise one cannot clearly see where a value starts (in case values are very long and wrap around in a terminal window)

midenok commented 4 years ago

Not speaking to others, but I don't need verbosity at all. I'm not expert here, but by perl analogy there should be ability to use module-wide variables. https://stackoverflow.com/questions/1977362/how-to-create-module-wide-variables-in-python