[RFC] Use emoji to indicate errors and warnings

Guinevere Larsen guinevere@redhat.com
Thu Jan 2 11:58:05 GMT 2025


On 12/24/24 11:55 AM, Luis Machado wrote:
> On 12/20/24 21:03, Tom Tromey wrote:
>> This patch adds, at long last, some emoji output to gdb.  In
>> particular, warnings are indicated with the warning sign, and errors
>> with the police car light.
>>
>> Perhaps this kind of thing should be configurable.
>>
>> Also it should probably be dependent on whether the current encoding
>> is UTF-8 compatible.
>>
>> Anyway, looking for feedback.
>> ---
>>   gdb/exceptions.c      | 2 ++
>>   gdb/linux-thread-db.c | 3 ---
>>   gdb/main.c            | 4 ++--
>>   gdb/utils.c           | 2 +-
>>   4 files changed, 5 insertions(+), 6 deletions(-)
>>
>> diff --git a/gdb/exceptions.c b/gdb/exceptions.c
>> index 368999829fc..23b6ef47bbe 100644
>> --- a/gdb/exceptions.c
>> +++ b/gdb/exceptions.c
>> @@ -74,6 +74,8 @@ print_exception (struct ui_file *file, const struct gdb_exception &e)
>>   
>>     for (start = e.what (); start != NULL; start = end)
>>       {
>> +      gdb_puts ("🚨 ", file);
>> +
>>         end = strchr (start, '\n');
>>         if (end == NULL)
>>   	gdb_puts (start, file);
>> diff --git a/gdb/linux-thread-db.c b/gdb/linux-thread-db.c
>> index 9d84187a9ad..f946c2a3e73 100644
>> --- a/gdb/linux-thread-db.c
>> +++ b/gdb/linux-thread-db.c
>> @@ -778,9 +778,6 @@ check_thread_db (struct thread_db_info *info, bool log_progress)
>>       }
>>     catch (const gdb_exception_error &except)
>>       {
>> -      if (warning_pre_print)
>> -	gdb_puts (warning_pre_print, gdb_stderr);
>> -
>>         exception_fprintf (gdb_stderr, except,
>>   			 _("libthread_db integrity checks failed: "));
>>   
>> diff --git a/gdb/main.c b/gdb/main.c
>> index 33cdd900994..dd1aa7fe216 100644
>> --- a/gdb/main.c
>> +++ b/gdb/main.c
>> @@ -1168,7 +1168,7 @@ captured_main_1 (struct captured_main_args *context)
>>   
>>     /* Set off error and warning messages with a blank line.  */
>>     tmp_warn_preprint.reset ();
>> -  warning_pre_print = _("\nwarning: ");
>> +  warning_pre_print = _("\n⚠️ warning: ");
>>   
>>     /* Read and execute the system-wide gdbinit file, if it exists.
>>        This is done *before* all the command line arguments are
>> @@ -1273,7 +1273,7 @@ captured_main_1 (struct captured_main_args *context)
>>       current_inferior ()->set_tty (ttyarg);
>>   
>>     /* Error messages should no longer be distinguished with extra output.  */
>> -  warning_pre_print = _("warning: ");
>> +  warning_pre_print = _("⚠️ warning: ");
>>   
>>     /* Read the .gdbinit file in the current directory, *if* it isn't
>>        the same as the $HOME/.gdbinit file (it should exist, also).  */
>> diff --git a/gdb/utils.c b/gdb/utils.c
>> index 6f2055e299d..72c7463c3cb 100644
>> --- a/gdb/utils.c
>> +++ b/gdb/utils.c
>> @@ -119,7 +119,7 @@ show_sevenbit_strings (struct ui_file *file, int from_tty,
>>   
>>   /* String to be printed before warning messages, if any.  */
>>   
>> -const char *warning_pre_print = "\nwarning: ";
>> +const char *warning_pre_print = "\n⚠️ warning: ";
>>   
>>   bool pagination_enabled = true;
>>   static void
> Curious. My first reaction was "I don't think so". But emojis and memes are the future. I suppose a
> way to toggle this on/off would be OK, and then whoever is building gdb can decide what to do with it.
I think this should be disabled at runtime, not at compile time. This 
way distros can share GDB with the emoji capability, but users 
themselves can choose to enable or disable according to their preference
> I like the coloring, for the most part. I suppose these emojis would accomplish a similar purpose if they
> appear in the middle of a wall of cryptic text. But while coloring would be fine by default, I think the emojis
> would need to be off by default for now.
>
I disagree because of discoverability. Emojis will help inexperienced 
users the most, and those users are unlikely to look at changelogs and 
news entries for what GDB has added (I didn't even realize how much 
development happened at GDB until I started at red hat, I'd never think 
to check something like this). So someone who would benefit from them is 
extremely unlikely to find out that they even exist. On the other hand, 
if they are enabled by default, someone who really dislikes emojis will 
immediately see them and search how to disable.

"there must be a way to remove this" is a much more logical conclusion 
from seeing emojis, than "Is there a way to add emojis to this 1990s 
looking program?" when you see a large wall of text that may contain 
errors or warnings.

-- 
Cheers,
Guinevere Larsen
She/Her/Hers



More information about the Gdb-patches mailing list