[Bug debug/92664] New: Wrong .debug_line section information when compiling stdin input with -g3

2019-11-25 Thread robert.dumitru at cyberthorstudios dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92664

Bug ID: 92664
   Summary: Wrong .debug_line section information when compiling
stdin input with -g3
   Product: gcc
   Version: 7.2.1
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: debug
  Assignee: unassigned at gcc dot gnu.org
  Reporter: robert.dumitru at cyberthorstudios dot com
  Target Milestone: ---

Hello,

When compiling simple test programs with -g3 and input from the console (-
(stdin)), the .debug_line section is wrong. 

Steps to reproduce this issue: 

1. In your console type:

arm-none-eabi-gcc -mcpu=cortex-m4 -mthumb -mfloat-abi=hard -mfpu=fpv4-sp-d16
-O0 -g3 -c -o test.o -x c -

2. Copy and paste: 

#include 
int main(void)
{
printf("Hello World\n");
return 0;
}

3. Ctrl+Z and Return 

4. If you type: arm-none-eabi-readelf --debug-dump=decodedline  test.o
You get the following:

Contents of the .debug_line section:

CU: ./:
File nameLine numberStarting addressView
readelf: Warning: Badly formed extended line op encountered!
readelf: Warning: Badly formed extended line op encountered!
UNKNOWN (116): length 115
0 0xc
   -10x1a
   -10x1e
10x2a
UNKNOWN (0): length 4
   -10x36
   -60x42
   -80x50
   -70x5c
   -70x60
   -50x6c
UNKNOWN (0): length 2
20x76
20x84
70x92
30xa0
20xac
10xba
10xbe
30xca
UNKNOWN (0): length 4
   -10xd8
   -20xe4
   -30xf2
   -30xf6
   -1   0x102
UNKNOWN (0): length 1
UNKNOWN (115): length 95
   -2   0x110
   -6   0x11e
   -7   0x12a
  -10   0x136
  -10   0x13a
   -8   0x146
UNKNOWN (0): length 1
UNKNOWN (112): length 95

5. Repeating the steps with -g instead of -g3 we get the right .debug_line
section:
Contents of the .debug_line section:

CU: ./:
File nameLine numberStarting addressView
3   0
4 0x4
5 0xa
6 0xc
60x14

[Bug c++/93380] New: Variable Length Array Evaluation will be wrong or cause GDB to crash due to GCC

2020-01-22 Thread robert.dumitru at cyberthorstudios dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93380

Bug ID: 93380
   Summary: Variable Length Array Evaluation will be wrong or
cause GDB to crash due to GCC
   Product: gcc
   Version: 7.2.1
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: robert.dumitru at cyberthorstudios dot com
  Target Milestone: ---

We have the following code that runs on a cortex a9 of a Renesas RZ A1 board
and involves the declaration of a variable length array. I will present here
the code, the debug info for the variable and the disassembly code.  

The sample code:

int main(void)
{
volatile int n;
int a = 1000;

int id_size = sizeof(cTaskList) / sizeof(V4_T_CTSK);
ID id[id_size];


for(;;){
  for(n=0; n<9e2>: Abbrev Number: 38 (DW_TAG_variable)
<9e3>   DW_AT_name: id  
<9e6>   DW_AT_decl_file   : 1   
<9e7>   DW_AT_decl_line   : 85  
<9e8>   DW_AT_type: <0x9f1> 
<9ec>   DW_AT_location: 3 byte block: 91 68 6   (DW_OP_fbreg: -24;
DW_OP_deref)

The disassembly code:

  main():
20021230:   push{r11, lr}
20021234:   add r11, sp, #4
20021238:   sub sp, sp, #24
82  int a = 1000;
2002123c:   mov r3, #1000   ; 0x3e8
20021240:   str r3, [r11, #-8]
84  int id_size = sizeof(cTaskList) / sizeof(V4_T_CTSK);
20021244:   mov r3, #13
20021248:   str r3, [r11, #-12]
85ID id[id_size];/* <-- debug session terminates with this
declaration */
2002124c:   ldr r3, [r11, #-12]
20021250:   sub r12, r3, #1
20021254:   str r12, [r11, #-16]
20021258:   mov r3, r12
2002125c:   add r3, r3, #1
20021260:   mov r0, r3
20021264:   mov r1, #0
20021268:   mov r2, #0
2002126c:   mov r3, #0
20021270:   lsl r3, r1, #5
20021274:   orr r3, r3, r0, lsr #27
20021278:   lsl r2, r0, #5
2002127c:   mov r3, r12
20021280:   add r3, r3, #1
20021284:   mov r0, r3
20021288:   mov r1, #0
2002128c:   mov r2, #0
20021290:   mov r3, #0
20021294:   lsl r3, r1, #5
20021298:   orr r3, r3, r0, lsr #27
2002129c:   lsl r2, r0, #5
200212a0:   mov r3, r12
200212a4:   add r3, r3, #1
200212a8:   lsl r3, r3, #2
200212ac:   add r3, r3, #3
200212b0:   add r3, r3, #7
200212b4:   lsr r3, r3, #3
200212b8:   lsl r3, r3, #3
200212bc:   sub sp, sp, r3
200212c0:   mov r3, sp
200212c4:   add r3, r3, #3
200212c8:   lsr r3, r3, #2
200212cc:   lsl r3, r3, #2
200212d0:   str r3, [r11, #-20]
89  for(n=0; n

[Bug debug/93380] Variable Length Array Evaluation will be wrong or cause GDB to crash due to GCC

2020-01-27 Thread robert.dumitru at cyberthorstudios dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93380

--- Comment #2 from Robert Dumitru  
---
Hi Andrew, 

Thank you for your pointing out that. I will report the issue to ARM as well.
However, regarding 1 and 2: 

1. I understand this looks like a gdb bug, but my investigation pointed me to
consider that what gdb does is correct- at least partially. It tries to read
the memory to find the size of the array. If the memory is not initialised with
the correct value, the size can be huge - hence - virtual memory exhausted bug. 
I will try and check with a newer gdb. Maybe gdb should know the expression can
not be evaluated before right instructions are executed? 

2. I checked with gcc 9.2.1 20191025 and the this still happens.

[Bug c/82283] Wrong warning with -Wmissing-field-initializers

2021-04-14 Thread robert.dumitru at cyberthorstudios dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82283

Robert Dumitru  changed:

   What|Removed |Added

 CC||robert.dumitru@cyberthorstu
   ||dios.com

--- Comment #10 from Robert Dumitru  ---
We are experiencing the same issue:

The warning: missing initializer for field ... [-Wmissing-field-initializers]
is being thrown incorrectly. 

The following code is correct, however [-Wmissing-field-initializers] are
shown. 

struct test_t{
  int value1;
  int value2;
};

struct test_t test[] = {
  [0].value1 = 1,
  [0].value2 = 2,
  [1].value1 = 10,
  [1].value2 = 20
};

int main(){
  return 0;
}

warning: missing initializer for field 'value2' of 'struct test_t'
[-Wmissing-field-initializers]
   [0].value2 = 2,
warning: missing initializer for field 'value2' of 'struct test_t'
[-Wmissing-field-initializers]
   [1].value2 = 20

The initialization is correct:
_test:
.long 1
.long 2
.long 10
.long 20

This bug was discovered first on version 8.3 but it can be reproduced on
version 10.2 as well. Please note you need the -Wextra flag in order to
reproduce this. 

I think https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99081 is also relating to
this.