Patchwork [4/4] kernel,debug: SPARC KGDB stub strcpy fix

login
register
mail settings
Submitter Konrad Eisele
Date Sept. 30, 2011, 1:47 p.m.
Message ID <1317390450-5982-5-git-send-email-konrad@gaisler.com>
Download mbox | patch
Permalink /patch/117147/
State Changes Requested
Delegated to: David Miller
Headers show

Comments

Konrad Eisele - Sept. 30, 2011, 1:47 p.m.
Works aroung the fact that strcpy in SPARC returns 0.

Signed-off-by: Konrad Eisele <konrad@gaisler.com>
---
 kernel/debug/gdbstub.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
David Miller - Oct. 6, 2011, 5:49 a.m.
From: Konrad Eisele <konrad@gaisler.com>
Date: Fri, 30 Sep 2011 15:47:30 +0200

> Works aroung the fact that strcpy in SPARC returns 0.
> 
> Signed-off-by: Konrad Eisele <konrad@gaisler.com>

Fix strcpy() on SPARC instead please.
--
To unsubscribe from this list: send the line "unsubscribe sparclinux" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Konrad Eisele - Oct. 11, 2011, 12:16 p.m.
David Miller wrote:
> From: Konrad Eisele <konrad@gaisler.com>
> Date: Fri, 30 Sep 2011 15:47:30 +0200
> 
>> Works aroung the fact that strcpy in SPARC returns 0.
>>
>> Signed-off-by: Konrad Eisele <konrad@gaisler.com>
> 
> Fix strcpy() on SPARC instead please.
> --
> To unsubscribe from this list: send the line "unsubscribe sparclinux" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 
> 
It is a gcc optimization. strcpy(p,"string") is converted to memcpy(p,7).
I could think of 2 ways:
- fix memcpy() so that it returns the dest-pointer instead of 0. (However
  there might be a reason that it returns 0 ...
- keep the "kernel,debug: SPARC KGDB stub strcpy fix" patch but change the
  summary of the patch to:
    Works aroung the fact that strcpy with a constant string is
    converted to memcpy by gcc and that  memcpy in SPARC returns 0.

I'll send the 2 possibilities as a reply in a moment.

-- Konrad

--
To unsubscribe from this list: send the line "unsubscribe sparclinux" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
David Miller - Oct. 11, 2011, 6:38 p.m.
From: Konrad Eisele <konrad@gaisler.com>
Date: Tue, 11 Oct 2011 14:16:01 +0200

> It is a gcc optimization. strcpy(p,"string") is converted to memcpy(p,7).
> I could think of 2 ways:
> - fix memcpy() so that it returns the dest-pointer instead of 0. (However
>   there might be a reason that it returns 0 ...
> - keep the "kernel,debug: SPARC KGDB stub strcpy fix" patch but change the
>   summary of the patch to:
>     Works aroung the fact that strcpy with a constant string is
>     converted to memcpy by gcc and that  memcpy in SPARC returns 0.
> 
> I'll send the 2 possibilities as a reply in a moment.

I think memcpy() should be fixed to return the dest pointer.
--
To unsubscribe from this list: send the line "unsubscribe sparclinux" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Konrad Eisele - Oct. 12, 2011, 10:11 a.m.
David Miller wrote:
> From: Konrad Eisele <konrad@gaisler.com>
> Date: Tue, 11 Oct 2011 14:16:01 +0200
> 
>> It is a gcc optimization. strcpy(p,"string") is converted to memcpy(p,7).
>> I could think of 2 ways:
>> - fix memcpy() so that it returns the dest-pointer instead of 0. (However
>>   there might be a reason that it returns 0 ...
>> - keep the "kernel,debug: SPARC KGDB stub strcpy fix" patch but change the
>>   summary of the patch to:
>>     Works aroung the fact that strcpy with a constant string is
>>     converted to memcpy by gcc and that  memcpy in SPARC returns 0.
>>
>> I'll send the 2 possibilities as a reply in a moment.
> 
> I think memcpy() should be fixed to return the dest pointer.
> 
> 

In that case the patchset would be (I sent them 10/11/2011 02:18 PM):

+ 0001-apbuart-add-polling-callbacks-to-apbuart-driver.patch
+ 0002-apbuart-add-support-for-virtual-KGDB-GRMON-channel.patch
+ 0004-sparc32-return-destination-pointer-on-return-from-me.patch
+ 0005-sparc32-Add-support-for-KGDB-with-SMP-for-leon-and-s.patch


and skip the "0003-kernel-debug-SPARC-KGDB-stub-strcpy-fix.patch"

-- Konrad
--
To unsubscribe from this list: send the line "unsubscribe sparclinux" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Konrad Eisele - Oct. 13, 2011, 7 a.m.
[PATCH 1/4] apbuart: add polling callbacks to apbuart driver:
   adds polling functions to apbuart.c

[PATCH 2/4] apbuart: add support for virtual KGDB<->GRMON channel   
   add GRMON virtual channel for KGDB

[PATCH 3/4] sparc32: return destination pointer on return from memcpy   
    fix memcpy to return destination pointer

[PATCH 4/4] sparc32: Add support for KGDB with SMP for leon and sun4d
    Implement KGDB for SMP for Leon and sun4d. For sun4m smp4m_ipi_kgdbcapture is a
    stub that has to be implemented later.
 
Greetings Konrad


--
To unsubscribe from this list: send the line "unsubscribe sparclinux" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

diff --git a/kernel/debug/gdbstub.c b/kernel/debug/gdbstub.c
index a11db95..380753e 100644
--- a/kernel/debug/gdbstub.c
+++ b/kernel/debug/gdbstub.c
@@ -946,7 +946,8 @@  int gdb_serial_stub(struct kgdb_state *ks)
 		ptr = remcom_out_buffer;
 		*ptr++ = 'T';
 		ptr = pack_hex_byte(ptr, ks->signo);
-		ptr += strlen(strcpy(ptr, "thread:"));
+		strcpy(ptr, "thread:");
+		ptr += strlen(ptr);
 		int_to_threadref(thref, shadow_pid(current->pid));
 		ptr = pack_threadid(ptr, thref);
 		*ptr++ = ';';