Re: db_trace.c: use __func__ instead of hardcoding filename

2016-09-09 Thread Philip Guenther
On Fri, Sep 9, 2016 at 3:19 PM, Jasper Lievisse Adriaanse
 wrote:
> On Fri, Sep 09, 2016 at 01:54:46PM -0700, Philip Guenther wrote:
>> On Fri, Sep 9, 2016 at 11:38 AM, Jasper Lievisse Adriaanse
>>  wrote:
>> > Do we really want the filename to be printed in the message? If so we 
>> > should
>> > use __FILE__. On the other hand, having the function name makes more sense 
>> > to
>> > me.
>>
>> This is a "not found" message in response to an explicit user command:
>> why does the user care what *source file* is generating that message?
> I have no idea why the user would care about the source file. However the
> function triggering it might be of some more information, albeit of dubious
> added value. Perhaps the message should be normalized across the board
> following arm/sparc64?

In a word: YES.



Re: db_trace.c: use __func__ instead of hardcoding filename

2016-09-09 Thread Jasper Lievisse Adriaanse
On Fri, Sep 09, 2016 at 01:54:46PM -0700, Philip Guenther wrote:
> On Fri, Sep 9, 2016 at 11:38 AM, Jasper Lievisse Adriaanse
>  wrote:
> > Do we really want the filename to be printed in the message? If so we should
> > use __FILE__. On the other hand, having the function name makes more sense 
> > to
> > me.
> 
> This is a "not found" message in response to an explicit user command:
> why does the user care what *source file* is generating that message?
I have no idea why the user would care about the source file. However the
function triggering it might be of some more information, albeit of dubious
added value. Perhaps the message should be normalized across the board
following arm/sparc64?

> arm and sparc64 do the Right Thing IMO:
> if (p == NULL) {
> (*pr)("not found\n");
> return;
> }
> 
> Philip Guenther
 

-- 
jasper



Re: db_trace.c: use __func__ instead of hardcoding filename

2016-09-09 Thread Philip Guenther
On Fri, Sep 9, 2016 at 11:38 AM, Jasper Lievisse Adriaanse
 wrote:
> Do we really want the filename to be printed in the message? If so we should
> use __FILE__. On the other hand, having the function name makes more sense to
> me.

This is a "not found" message in response to an explicit user command:
why does the user care what *source file* is generating that message?
arm and sparc64 do the Right Thing IMO:
if (p == NULL) {
(*pr)("not found\n");
return;
}

Philip Guenther



Re: db_trace.c: use __func__ instead of hardcoding filename

2016-09-09 Thread Todd C. Miller
On Fri, 09 Sep 2016 20:38:05 +0200, Jasper Lievisse Adriaanse wrote:

> Do we really want the filename to be printed in the message? If so we should
> use __FILE__. On the other hand, having the function name makes more sense to
> me.

Much more useful, OK millert@

 - todd



db_trace.c: use __func__ instead of hardcoding filename

2016-09-09 Thread Jasper Lievisse Adriaanse
Hi,

Do we really want the filename to be printed in the message? If so we should
use __FILE__. On the other hand, having the function name makes more sense to
me.

OK?

Index: amd64/amd64/db_trace.c
===
RCS file: /cvs/src/sys/arch/amd64/amd64/db_trace.c,v
retrieving revision 1.20
diff -u -p -r1.20 db_trace.c
--- amd64/amd64/db_trace.c  4 Sep 2016 09:22:28 -   1.20
+++ amd64/amd64/db_trace.c  9 Sep 2016 18:35:09 -
@@ -174,7 +174,7 @@ db_stack_trace_print(db_expr_t addr, boo
if (trace_proc) {
struct proc *p = pfind((pid_t)addr);
if (p == NULL) {
-   (*pr) ("db_trace.c: process not found\n");
+   (*pr) ("%s: process not found\n", __func__);
return;
}
frame = (struct callframe *)p->p_addr->u_pcb.pcb_rbp;
Index: i386/i386/db_trace.c
===
RCS file: /cvs/src/sys/arch/i386/i386/db_trace.c,v
retrieving revision 1.19
diff -u -p -r1.19 db_trace.c
--- i386/i386/db_trace.c3 Mar 2016 12:44:09 -   1.19
+++ i386/i386/db_trace.c9 Sep 2016 18:35:09 -
@@ -186,11 +186,11 @@ db_stack_trace_print(db_expr_t addr, boo
frame = (struct callframe *)ddb_regs.tf_ebp;
callpc = (db_addr_t)ddb_regs.tf_eip;
} else if (trace_thread) {
-   (*pr) ("db_trace.c: can't trace thread\n");
+   (*pr) ("%s: can't trace thread\n", __func__);
} else if (trace_proc) {
struct proc *p = pfind((pid_t)addr);
if (p == NULL) {
-   (*pr) ("db_trace.c: process not found\n");
+   (*pr) ("%s: process not found\n", __func__);
return;
}
frame = (struct callframe *)p->p_addr->u_pcb.pcb_ebp;

-- 
jasper