调试低级gcc中间代码表示形式

时间:2019-05-22 15:26:09

标签: c gcc intermediate-language

关于this question,我还有另一个问题。

我设法重现了该代码,因此我不再复制该代码,因为您可以找到该代码。我只将编译输出粘贴到计算机上。

% gcc -std=c11 -O3 -g -Wall -Wextra -Werror -USUPPRESS_BUG  -c  msg_gcc.c
msg_gcc.c: In function 'function_under_test':
msg_gcc.c:30:9: error: 'strncpy' output may be truncated copying 128 bytes from a string of length 128 [-Werror=stringop-truncation]
         strncpy(name, name_in_queue, SERVERNAME_LEN);
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
-root-@ @...| test | stub
% gcc --version
gcc (GCC) 8.2.1 20181127
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

-root-@ @...| test | stub
% cat /proc/version
Linux version 5.0.7-arch1-1-ARCH (builduser@heftig-20167) (gcc version 8.2.1 20181127 (GCC)) #1 SMP PREEMPT Mon Apr 8 10:37:08 UTC 2019
-root-@ @...| test | stub

我希望我能理解编译器在哪个阶段检测到此类库问题。我知道该代码已转换为许多中间语言,例如通用,gimple,ssa,rtl,组合器等,但是我不知道从此编译命令中检查了哪种表示形式的代码,例如

如果我想调试中间表示形式并发现此问题的存在,我应该向gcc传递哪些参数,以便它在生成此警告之前尽可能快地停止中间语言的生成?

1 个答案:

答案 0 :(得分:2)

您的错误/警告似乎源自here。 如果我理解正确,那是从SSA表单生成阶段开始的。

同样,this问题可能会为如何为with open('Salida1.csv',newline='', mode='r') as csv_file: csv_reader = csv.reader(csv_file, delimiter=',') #rows1 = list(csv_reader) #print(len(rows1)) line_count = 0 count=0 for row in csv_reader: key = row[20] devicedict[key].append(row) if line_count == 0: print(f'Column names are {", ".join(row)}') line_count += 1 else: #print(f'\t{row[0]} works in the {row[20]} department, and was born in {row[2]}.') #print(row['id'], row['idapp']) #print(len(row)) #print(list(row)) mydict5ordenado.append(list(row)) line_count += 1 print(len(devicedict.keys())) f = "%Y-%m-%d %H:%M:%S" p = devicedict.keys() for i in range(0,len(devicedict)): mydict.append(devicedict[list(p)[i]]) print(mydict[i]) print("Los campos temporales:") #print(mydict[i][4]) #print(mydict[i][3]) out1=datetime.datetime.strptime(mydict[i][4], f) out2=datetime.datetime.strptime(mydict[i][3], f) out3=out1-out2 valoresTotalesDias+=1 valoresDias+=out3.seconds/86400 #This is what i am trying to obtain for each record without hardcoding #I want to access each field in the above loop count1=len(devicedict['4ff70ad8e2e74f49']) for i in range(0,count1): mydict5.append(devicedict['4ff70ad8e2e74f49'][i]) print(len(mydict5)) for i in range (0,len(mydict5)): print(mydict5[i][7]) print("Tipo de Bus:") print(mydict5[i][16]) print(mydict5[i][14]) if (mydict5[i][16]=='P'): preferente+=1 转储不同的中间表示形式提供有用的提示。我知道如何针对gcc执行此操作,但是您的问题似乎特定于clang