From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0a-0010f301.pphosted.com (mx0a-0010f301.pphosted.com [148.163.149.254]) by sourceware.org (Postfix) with ESMTPS id 6137E3858408 for ; Mon, 6 Sep 2021 00:07:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 6137E3858408 Received: from pps.filterd (m0102857.ppops.net [127.0.0.1]) by mx0b-0010f301.pphosted.com (8.16.1.2/8.16.0.43) with SMTP id 185NjDk3022530 for ; Sun, 5 Sep 2021 19:07:58 -0500 Received: from mx4.mail.rice.edu (mx4.mail.rice.edu [128.42.199.101]) by mx0b-0010f301.pphosted.com with ESMTP id 3aw7u1g0a3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Sun, 05 Sep 2021 19:07:57 -0500 Received: from mx4.mail.rice.edu (localhost [127.0.0.1]) by mx4.mail.rice.edu (Postfix) with ESMTP id 3DC1B433A92 for ; Sun, 5 Sep 2021 19:07:57 -0500 (CDT) Received: from localhost (localhost [127.0.0.1]) by mx4.mail.rice.edu (Postfix) with ESMTP id 23C4A424653; Sun, 5 Sep 2021 19:07:57 -0500 (CDT) X-Virus-Scanned: by amavis-2.12.1 at mx4.mail.rice.edu, auth channel Received: from mx4.mail.rice.edu ([127.0.0.1]) by localhost (mx4.mail.rice.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id U4FuHNGIsDsO; Sun, 5 Sep 2021 19:07:46 -0500 (CDT) Received: from [192.168.50.202] (c-98-200-175-18.hsd1.tx.comcast.net [98.200.175.18]) (using TLSv1.2 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: johnmc@rice.edu) by mx4.mail.rice.edu (Postfix) with ESMTPSA id F2A2F225608; Sun, 5 Sep 2021 19:07:45 -0500 (CDT) From: John Mellor-Crummey Content-Type: multipart/mixed; boundary="Apple-Mail=_EB22CA76-EC65-45E3-8A9F-E0830BF864E9" Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.4\)) Subject: Extension: read inlining info in an NVIDIA extended line map Message-Id: <7C166312-4876-444F-9B85-C7E30C8F4959@rice.edu> Date: Sun, 5 Sep 2021 19:07:45 -0500 Cc: John Mellor-Crummey , Xiaozhu Meng To: elfutils-devel@sourceware.org X-Mailer: Apple Mail (2.3608.120.23.2.4) X-Proofpoint-ORIG-GUID: JH9RxzbGEePNNR2Hu4zaOmXdUlpNV8wj X-Proofpoint-GUID: JH9RxzbGEePNNR2Hu4zaOmXdUlpNV8wj X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.182.1,Aquarius:18.0.790,Hydra:6.0.391,FMLib:17.0.607.475 definitions=2021-09-05_04,2021-09-03_01,2020-04-07_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 adultscore=0 mlxlogscore=729 spamscore=0 impostorscore=0 mlxscore=0 suspectscore=0 lowpriorityscore=0 clxscore=1011 bulkscore=0 phishscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2108310000 definitions=main-2109050170 X-Spam-Status: No, score=-3.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: elfutils-devel@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Elfutils-devel mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 06 Sep 2021 00:08:02 -0000 --Apple-Mail=_EB22CA76-EC65-45E3-8A9F-E0830BF864E9 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 As of CUDA 11.2, NVIDIA added extensions to the line map section of CUDA binaries to represent inlined functions. These extensions include - two new fields in a line table row to represent inline=20 information: context, and functionname, - two new DWARF extended opcodes: DW_LNE_inlined_call,=20 DW_LNE_set_function_name, - an additional word in the line table header that indicates=20 the offset in the .debug_str function where the function=20 names for this line table begin, and - two new functions in the libdw API: dwarf_linecontext and=20 dwarf_linefunctionname, which return the new line table fields. A line table row for an inlined function contains a non-zero "context" value. The =E2=80=9Ccontext=E2=80=9D field indicates the index = of the line table row that serves as the call site for an inlined context. The "functionname" field in a line table row is only meaningful if the "context" field of the row is non-zero. A meaningful "functionname" field contains an index into the .debug_str section relative to the base offset established in the line table header; the position in the .debug_str section indicates the name of the inlined function. These extensions resemble the proposed DWARF extensions (http://dwarfstd.org/ShowIssue.php?issue=3D140906.1) by Cary Coutant, but are not identical. This patch adds integrates support for handling NVIDIA's extended line maps into elfutil's libdw library and the readelf command line utility. Since this support is a non-standard extension to DWARF, all code that implements the extensions is implemented between markers =20 /* Begin NVIDIA_LINEMAP_INLINING_EXTENSIONS */ and=20 /* End NVIDIA_LINEMAP_INLINING_EXTENSIONS */. The definition below #define NVIDIA_LINEMAP_INLINING_EXTENSIONS 1 is added to elfutils/version.h, which enables a client of elfutils=20 to test whether the NVIDIA line map extensions are present.=20 Note: The support for NVIDIA extended line maps adds two integer fields (context and functionname) to struct Dwarf_Line_s, which makes the structure about 30% larger. The patch includes a binary testfile_nvidia_linemap.bz2 that contains an NVIDIA extended linemap along with two tests that read the line map. - A test script run-nvidia-extended-linemap-readelf.sh=20 checks the output of readelf on the new test binary to=20 validate its dump of the line op codes containing context=20 and functionname entries. - A test program tests/nvidia_extended_linemap_libdw.c reads=20 the extended line map with dwarf_next_lines and dumps the=20 context and functionname fields of the line map where they=20 are relevant, i.e. the value of context is non-zero. A test=20 script run-nvidia-extended-linemap-libdw.sh runs this test=20 and validates its output. A patch with the new functionality described above is attached. -- John Mellor-Crummey Professor Dept of Computer Science Rice University email: johnmc@rice.edu phone: 713-348-5179 --Apple-Mail=_EB22CA76-EC65-45E3-8A9F-E0830BF864E9 Content-Disposition: attachment; filename=0001-Read-inlining-info-in-NVIDIA-extended-line-map.patch Content-Type: application/octet-stream; x-unix-mode=0644; name="0001-Read-inlining-info-in-NVIDIA-extended-line-map.patch" Content-Transfer-Encoding: quoted-printable =46rom=2032e6b3530677bcbb595ba9010d49feef03314bd4=20Mon=20Sep=2017=20= 00:00:00=202001=0AFrom:=20John=20M=20Mellor-Crummey=20=0A= Date:=20Fri,=203=20Sep=202021=2016:13:40=20-0500=0ASubject:=20[PATCH]=20= Read=20inlining=20info=20in=20NVIDIA=20extended=20line=20map=0A=0A= Signed-off-by:=20John=20M=20Mellor-Crummey=20=0A---=0A=20= ChangeLog=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20|=20=20=204=20+=0A=20= config/version.h.in=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20|=20=20=204=20+=0A=20libdw/Makefile.am=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= |=20=20=201=20+=0A=20libdw/dwarf.h=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20|=20=20=204=20+=0A= =20libdw/dwarf_getsrclines.c=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20|=20=2052=20++++++-=0A=20libdw/dwarf_linecontext.c=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20|=20=2047=20++++++=0A=20= libdw/dwarf_linefunctionname.c=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= |=20=2047=20++++++=0A=20libdw/libdw.h=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20|=20=2012=20= ++=0A=20libdw/libdw.map=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20|=20=20=202=20+=0A=20= libdw/libdwP.h=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20|=20=20=204=20+=0A=20src/readelf.c=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20|=20=2046=20++++++=0A=20tests/Makefile.am=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20|=20=20= =203=20+=0A=20tests/nvidia_extended_linemap_libdw.c=20=20=20=20=20=20=20=20= |=20153=20+++++++++++++++++++=0A=20= tests/run-nvidia-extended-linemap-libdw.sh=20=20=20|=20=2041=20+++++=0A=20= tests/run-nvidia-extended-linemap-readelf.sh=20|=20114=20++++++++++++++=0A= =20tests/testfile_nvidia_linemap.bz2=20=20=20=20=20=20=20=20=20=20=20=20= |=20Bin=200=20->=202365=20bytes=0A=2016=20files=20changed,=20533=20= insertions(+),=201=20deletion(-)=0A=20create=20mode=20100644=20= libdw/dwarf_linecontext.c=0A=20create=20mode=20100644=20= libdw/dwarf_linefunctionname.c=0A=20create=20mode=20100644=20= tests/nvidia_extended_linemap_libdw.c=0A=20create=20mode=20100755=20= tests/run-nvidia-extended-linemap-libdw.sh=0A=20create=20mode=20100755=20= tests/run-nvidia-extended-linemap-readelf.sh=0A=20create=20mode=20100644=20= tests/testfile_nvidia_linemap.bz2=0A=0Adiff=20--git=20a/ChangeLog=20= b/ChangeLog=0Aindex=206255fe61..d4b89f9c=20100644=0A---=20a/ChangeLog=0A= +++=20b/ChangeLog=0A@@=20-1,3=20+1,7=20@@=0A+2021-09-03=20=20John=20= Mellor-Crummey=20=0A+=0A+=09*=20NEWS:=20Read=20inlining=20= info=20in=20NVIDIA=20extended=20line=20map=0A+=0A=202021-08-10=20=20= Adrian=20Ratiu=20=20=0A=20=0A=20=09*=20= configure.ac=20(AC_CACHE_CHECK):=20Rework=20std=3Dgnu99=20check=20to=20= allow=20clang.=0Adiff=20--git=20a/config/version.h.in=20= b/config/version.h.in=0Aindex=2034e62c3b..8b30d144=20100644=0A---=20= a/config/version.h.in=0A+++=20b/config/version.h.in=0A@@=20-35,4=20+35,8=20= @@=0A=20#define=20_ELFUTILS_PREREQ(major,=20minor)=20\=0A=20=20=20= (_ELFUTILS_VERSION=20>=3D=20((major)=20*=201000=20+=20(minor)))=0A=20=0A= +/*=20Begin=20NVIDIA_LINEMAP_INLINING_EXTENSIONS=20*/=0A+#define=20= NVIDIA_LINEMAP_INLINING_EXTENSIONS=201=0A+/*=20End=20= NVIDIA_LINEMAP_INLINING_EXTENSIONS=20*/=0A+=0A=20#endif=09/*=20= elfutils/version.h=20*/=0Adiff=20--git=20a/libdw/Makefile.am=20= b/libdw/Makefile.am=0Aindex=206b7834af..4fda33bd=20100644=0A---=20= a/libdw/Makefile.am=0A+++=20b/libdw/Makefile.am=0A@@=20-63,6=20+63,7=20= @@=20libdw_a_SOURCES=20=3D=20dwarf_begin.c=20dwarf_begin_elf.c=20= dwarf_end.c=20dwarf_getelf.c=20\=0A=20=09=09=20=20dwarf_linesrc.c=20= dwarf_lineno.c=20dwarf_lineaddr.c=20\=0A=20=09=09=20=20dwarf_linecol.c=20= dwarf_linebeginstatement.c=20\=0A=20=09=09=20=20dwarf_lineendsequence.c=20= dwarf_lineblock.c=20\=0A+=09=09=20=20dwarf_linecontext.c=20= dwarf_linefunctionname.c=20\=0A=20=09=09=20=20dwarf_lineprologueend.c=20= dwarf_lineepiloguebegin.c=20\=0A=20=09=09=20=20dwarf_lineisa.c=20= dwarf_linediscriminator.c=20\=0A=20=09=09=20=20dwarf_lineop_index.c=20= dwarf_line_file.c=20\=0Adiff=20--git=20a/libdw/dwarf.h=20b/libdw/dwarf.h=0A= index=2019a4be96..2faf852a=20100644=0A---=20a/libdw/dwarf.h=0A+++=20= b/libdw/dwarf.h=0A@@=20-844,6=20+844,10=20@@=20enum=0A=20=20=20=20=20= DW_LNE_set_discriminator=20=3D=204,=0A=20=0A=20=20=20=20=20= DW_LNE_lo_user=20=3D=20128,=0A+=20=20=20=20/*=20Begin=20=20= NVIDIA_LINEMAP_INLINING_EXTENSIONS=20*/=0A+=20=20=20=20= DW_LNE_inlined_call=20=3D=20144,=0A+=20=20=20=20DW_LNE_set_function_name=20= =3D=20145,=0A+=20=20=20=20/*=20End=20=20= NVIDIA_LINEMAP_INLINING_EXTENSIONS=20*/=0A=20=20=20=20=20DW_LNE_hi_user=20= =3D=20255=0A=20=20=20};=0A=20=0Adiff=20--git=20= a/libdw/dwarf_getsrclines.c=20b/libdw/dwarf_getsrclines.c=0Aindex=20= d6a581ad..d7907d4d=20100644=0A---=20a/libdw/dwarf_getsrclines.c=0A+++=20= b/libdw/dwarf_getsrclines.c=0A@@=20-93,6=20+93,10=20@@=20struct=20= line_state=0A=20=20=20struct=20linelist=20*linelist;=0A=20=20=20size_t=20= nlinelist;=0A=20=20=20unsigned=20int=20end_sequence;=0A+/*=20Begin=20= NVIDIA_LINEMAP_INLINING_EXTENSIONS=20*/=0A+=20=20unsigned=20int=20= context;=0A+=20=20unsigned=20int=20function_name;=0A+/*=20End=20= NVIDIA_LINEMAP_INLINING_EXTENSIONS=20*/=0A=20};=0A=20=0A=20static=20= inline=20void=0A@@=20-139,6=20+143,10=20@@=20add_new_line=20(struct=20= line_state=20*state,=20struct=20linelist=20*new_line)=0A=20=20=20SET=20= (epilogue_begin);=0A=20=20=20SET=20(isa);=0A=20=20=20SET=20= (discriminator);=0A+/*=20Begin=20NVIDIA_LINEMAP_INLINING_EXTENSIONS=20*/=0A= +=20=20SET=20(context);=0A+=20=20SET=20(function_name);=0A+/*=20End=20= NVIDIA_LINEMAP_INLINING_EXTENSIONS=20*/=0A=20=0A=20#undef=20SET=0A=20=0A= @@=20-165,6=20+173,13=20@@=20read_srclines=20(Dwarf=20*dbg,=0A=20#define=20= MAX_STACK_FILES=20(MAX_STACK_ALLOC=20/=204)=0A=20#define=20= MAX_STACK_DIRS=20=20(MAX_STACK_ALLOC=20/=2016)=0A=20=0A+/*=20Begin=20= NVIDIA_LINEMAP_INLINING_EXTENSIONS=20*/=0A+=20=20/*=20reduce=20the=20= MAX_STACK_LINES=20when=20using=20NVIDIA=20linemap=20inlining=20= extensions,=20which=0A+=20=20=20=20=20increase=20the=20size=20of=20the=20= line=20structure=20by=20two=20unsigned=20int=20*/=0A+#undef=20= MAX_STACK_LINES=0A+#define=20MAX_STACK_LINES=20(MAX_STACK_ALLOC=20/=202)=0A= +/*=20End=20NVIDIA_LINEMAP_INLINING_EXTENSIONS=20*/=0A+=0A=20=20=20/*=20= Initial=20statement=20program=20state=20(except=20for=20stmt_list,=20see=20= below).=20=20*/=0A=20=20=20struct=20line_state=20state=20=3D=0A=20=20=20=20= =20{=0A@@=20-180,7=20+195,11=20@@=20read_srclines=20(Dwarf=20*dbg,=0A=20=20= =20=20=20=20=20.prologue_end=20=3D=20false,=0A=20=20=20=20=20=20=20= .epilogue_begin=20=3D=20false,=0A=20=20=20=20=20=20=20.isa=20=3D=200,=0A= -=20=20=20=20=20=20.discriminator=20=3D=200=0A+=20=20=20=20=20=20= .discriminator=20=3D=200,=0A+/*=20Begin=20= NVIDIA_LINEMAP_INLINING_EXTENSIONS=20*/=0A+=20=20=20=20=20=20.context=20= =3D=200,=0A+=20=20=20=20=20=20.function_name=20=3D=200=0A+/*=20End=20= NVIDIA_LINEMAP_INLINING_EXTENSIONS=20*/=0A=20=20=20=20=20};=0A=20=0A=20=20= =20/*=20The=20dirs=20normally=20go=20on=20the=20stack,=20but=20if=20= there=20are=20too=20many=0A@@=20-648,6=20+667,14=20@@=20read_srclines=20= (Dwarf=20*dbg,=0A=20=09}=0A=20=20=20=20=20}=0A=20=0A+/*=20Begin=20= NVIDIA_LINEMAP_INLINING_EXTENSIONS=20*/=0A+=20=20unsigned=20int=20= debug_str_offset=20__attribute__((unused))=20=3D=200;=0A+=20=20if=20= (unlikely=20(linep=20<=20header_start=20+=20header_length))=20{=0A+=20=20= =20=20=20=20/*=20CUBINs=20contain=20an=20unsigned=204-byte=20offset=20*/=0A= +=20=20=20=20=20=20debug_str_offset=20=3D=20read_4ubyte_unaligned_inc=20= (dbg,=20linep);=0A+=20=20}=0A+/*=20End=20= NVIDIA_LINEMAP_INLINING_EXTENSIONS=20*/=0A+=0A=20=20=20/*=20Consistency=20= check.=20=20*/=0A=20=20=20if=20(unlikely=20(linep=20!=3D=20header_start=20= +=20header_length))=0A=20=20=20=20=20{=0A@@=20-753,6=20+780,10=20@@=20= read_srclines=20(Dwarf=20*dbg,=0A=20=09=20=20=20=20=20=20= state.epilogue_begin=20=3D=20false;=0A=20=09=20=20=20=20=20=20state.isa=20= =3D=200;=0A=20=09=20=20=20=20=20=20state.discriminator=20=3D=200;=0A+/*=20= Begin=20NVIDIA_LINEMAP_INLINING_EXTENSIONS=20*/=0A+=09=20=20=20=20=20=20= state.context=20=3D=200;=0A+=09=20=20=20=20=20=20state.function_name=20=3D= =200;=0A+/*=20End=20NVIDIA_LINEMAP_INLINING_EXTENSIONS=20*/=0A=20=09=20=20= =20=20=20=20break;=0A=20=0A=20=09=20=20=20=20case=20DW_LNE_set_address:=0A= @@=20-831,6=20+862,25=20@@=20read_srclines=20(Dwarf=20*dbg,=0A=20=09=20=20= =20=20=20=20get_uleb128=20(state.discriminator,=20linep,=20lineendp);=0A=20= =09=20=20=20=20=20=20break;=0A=20=0A+/*=20Begin=20= NVIDIA_LINEMAP_INLINING_EXTENSIONS=20*/=0A+=09=20=20=20=20case=20= DW_LNE_inlined_call:=0A+=09=20=20=20=20=20=20if=20(unlikely=20(linep=20= >=3D=20lineendp))=0A+=09=09goto=20invalid_data;=0A+=09=20=20=20=20=20=20= get_uleb128=20(state.context,=20linep,=20lineendp);=0A+=09=20=20=20=20=20= =20if=20(unlikely=20(linep=20>=3D=20lineendp))=0A+=09=09goto=20= invalid_data;=0A+=09=20=20=20=20=20=20get_uleb128=20= (state.function_name,=20linep,=20lineendp);=0A+=09=20=20=20=20=20=20= state.function_name=20+=3D=20debug_str_offset;=0A+=09=20=20=20=20=20=20= break;=0A+=0A+=09=20=20=20=20case=20DW_LNE_set_function_name:=0A+=09=20=20= =20=20=20=20if=20(unlikely=20(linep=20>=3D=20lineendp))=0A+=09=09goto=20= invalid_data;=0A+=09=20=20=20=20=20=20get_uleb128=20= (state.function_name,=20linep,=20lineendp);=0A+=09=20=20=20=20=20=20= state.function_name=20+=3D=20debug_str_offset;=0A+=09=20=20=20=20=20=20= break;=0A+/*=20End=20NVIDIA_LINEMAP_INLINING_EXTENSIONS=20*/=0A+=0A=20=09= =20=20=20=20default:=0A=20=09=20=20=20=20=20=20/*=20Unknown,=20ignore=20= it.=20=20*/=0A=20=09=20=20=20=20=20=20if=20(unlikely=20((size_t)=20= (lineendp=20-=20(linep=20-=201))=20<=20len))=0Adiff=20--git=20= a/libdw/dwarf_linecontext.c=20b/libdw/dwarf_linecontext.c=0Anew=20file=20= mode=20100644=0Aindex=2000000000..f1c78dfd=0A---=20/dev/null=0A+++=20= b/libdw/dwarf_linecontext.c=0A@@=20-0,0=20+1,47=20@@=0A+/*=20Return=20= context=20in=20line.=0A+=20=20=20This=20file=20is=20part=20of=20= elfutils.=0A+=20=20=20Written=20by=20John=20Mellor-Crummey=20= ,=202021.=0A+=0A+=20=20=20This=20file=20is=20free=20= software;=20you=20can=20redistribute=20it=20and/or=20modify=0A+=20=20=20= it=20under=20the=20terms=20of=20either=0A+=0A+=20=20=20=20=20*=20the=20= GNU=20Lesser=20General=20Public=20License=20as=20published=20by=20the=20= Free=0A+=20=20=20=20=20=20=20Software=20Foundation;=20either=20version=20= 3=20of=20the=20License,=20or=20(at=0A+=20=20=20=20=20=20=20your=20= option)=20any=20later=20version=0A+=0A+=20=20=20or=0A+=0A+=20=20=20=20=20= *=20the=20GNU=20General=20Public=20License=20as=20published=20by=20the=20= Free=0A+=20=20=20=20=20=20=20Software=20Foundation;=20either=20version=20= 2=20of=20the=20License,=20or=20(at=0A+=20=20=20=20=20=20=20your=20= option)=20any=20later=20version=0A+=0A+=20=20=20or=20both=20in=20= parallel,=20as=20here.=0A+=0A+=20=20=20elfutils=20is=20distributed=20in=20= the=20hope=20that=20it=20will=20be=20useful,=20but=0A+=20=20=20WITHOUT=20= ANY=20WARRANTY;=20without=20even=20the=20implied=20warranty=20of=0A+=20=20= =20MERCHANTABILITY=20or=20FITNESS=20FOR=20A=20PARTICULAR=20PURPOSE.=20=20= See=20the=20GNU=0A+=20=20=20General=20Public=20License=20for=20more=20= details.=0A+=0A+=20=20=20You=20should=20have=20received=20copies=20of=20= the=20GNU=20General=20Public=20License=20and=0A+=20=20=20the=20GNU=20= Lesser=20General=20Public=20License=20along=20with=20this=20program.=20=20= If=0A+=20=20=20not,=20see=20.=20=20*/=0A+=0A= +#ifdef=20HAVE_CONFIG_H=0A+#=20include=20=0A+#endif=0A+=0A= +#include=20"libdwP.h"=0A+=0A+=0A+/*=20Begin=20= NVIDIA_LINEMAP_INLINING_EXTENSIONS=20*/=0A+int=0A+dwarf_linecontext=20= (Dwarf_Line=20*line,=20unsigned=20int=20*contextp)=0A+{=0A+=20=20if=20= (line=20=3D=3D=20NULL)=0A+=20=20=20=20return=20-1;=0A+=0A+=20=20= *contextp=20=3D=20=20line->context;=0A+=0A+=20=20return=200;=0A+}=0A+/*=20= End=20NVIDIA_LINEMAP_INLINING_EXTENSIONS=20*/=0Adiff=20--git=20= a/libdw/dwarf_linefunctionname.c=20b/libdw/dwarf_linefunctionname.c=0A= new=20file=20mode=20100644=0Aindex=2000000000..a7027135=0A---=20= /dev/null=0A+++=20b/libdw/dwarf_linefunctionname.c=0A@@=20-0,0=20+1,47=20= @@=0A+/*=20Return=20function=20name=20in=20line.=0A+=20=20=20This=20file=20= is=20part=20of=20elfutils.=0A+=20=20=20Written=20by=20John=20= Mellor-Crummey=20,=202021.=0A+=0A+=20=20=20This=20file=20= is=20free=20software;=20you=20can=20redistribute=20it=20and/or=20modify=0A= +=20=20=20it=20under=20the=20terms=20of=20either=0A+=0A+=20=20=20=20=20*=20= the=20GNU=20Lesser=20General=20Public=20License=20as=20published=20by=20= the=20Free=0A+=20=20=20=20=20=20=20Software=20Foundation;=20either=20= version=203=20of=20the=20License,=20or=20(at=0A+=20=20=20=20=20=20=20= your=20option)=20any=20later=20version=0A+=0A+=20=20=20or=0A+=0A+=20=20=20= =20=20*=20the=20GNU=20General=20Public=20License=20as=20published=20by=20= the=20Free=0A+=20=20=20=20=20=20=20Software=20Foundation;=20either=20= version=202=20of=20the=20License,=20or=20(at=0A+=20=20=20=20=20=20=20= your=20option)=20any=20later=20version=0A+=0A+=20=20=20or=20both=20in=20= parallel,=20as=20here.=0A+=0A+=20=20=20elfutils=20is=20distributed=20in=20= the=20hope=20that=20it=20will=20be=20useful,=20but=0A+=20=20=20WITHOUT=20= ANY=20WARRANTY;=20without=20even=20the=20implied=20warranty=20of=0A+=20=20= =20MERCHANTABILITY=20or=20FITNESS=20FOR=20A=20PARTICULAR=20PURPOSE.=20=20= See=20the=20GNU=0A+=20=20=20General=20Public=20License=20for=20more=20= details.=0A+=0A+=20=20=20You=20should=20have=20received=20copies=20of=20= the=20GNU=20General=20Public=20License=20and=0A+=20=20=20the=20GNU=20= Lesser=20General=20Public=20License=20along=20with=20this=20program.=20=20= If=0A+=20=20=20not,=20see=20.=20=20*/=0A+=0A= +#ifdef=20HAVE_CONFIG_H=0A+#=20include=20=0A+#endif=0A+=0A= +#include=20"libdwP.h"=0A+=0A+=0A+/*=20Begin=20= NVIDIA_LINEMAP_INLINING_EXTENSIONS=20*/=0A+int=0A+dwarf_linefunctionname=20= (Dwarf_Line=20*line,=20unsigned=20int=20*functionnamep)=0A+{=0A+=20=20if=20= (line=20=3D=3D=20NULL)=0A+=20=20=20=20return=20-1;=0A+=0A+=20=20= *functionnamep=20=3D=20=20line->function_name;=0A+=0A+=20=20return=200;=0A= +}=0A+/*=20End=20NVIDIA_LINEMAP_INLINING_EXTENSIONS=20*/=0Adiff=20--git=20= a/libdw/libdw.h=20b/libdw/libdw.h=0Aindex=2077174d28..730f9338=20100644=0A= ---=20a/libdw/libdw.h=0A+++=20b/libdw/libdw.h=0A@@=20-701,6=20+701,18=20= @@=20extern=20int=20dwarf_linediscriminator=20(Dwarf_Line=20*line,=20= unsigned=20int=20*discp)=0A=20extern=20const=20char=20*dwarf_linesrc=20= (Dwarf_Line=20*line,=0A=20=09=09=09=09=20=20Dwarf_Word=20*mtime,=20= Dwarf_Word=20*length);=0A=20=0A+/*=20Begin=20= NVIDIA_LINEMAP_INLINING_EXTENSIONS=20*/=0A+/*=20NVIDIA=20extension:=20= Return=20inline=20context=20in=20this=20record.=20A=20non-zero=20context=0A= +=20=20=20value=20represents=20an=20inline=20context=20*/=0A+extern=20= int=20dwarf_linecontext=20(Dwarf_Line=20*line,=20unsigned=20int=20= *contextp);=0A+=0A+/*=20NVIDIA=20extension:=20Return=20function=20name=20= in=20this=20record.=20When=20context=20is=0A+=20=20=20non-zero,=20the=20= value=20of=20function=20name=20is=20an=20offset=20into=20the=20= .debug_str=20section,=0A+=20=20=20which=20contains=20a=20character=20= string=20that=20specifies=20the=20name=20of=20an=20inlined=0A+=20=20=20= function.=20*/=0A+extern=20int=20dwarf_linefunctionname=20(Dwarf_Line=20= *line,=20unsigned=20int=20*functionnamep);=0A+/*=20End=20= NVIDIA_LINEMAP_INLINING_EXTENSIONS=20*/=0A+=0A=20/*=20Return=20file=20= information.=20=20The=20returned=20string=20is=20NULL=20when=0A=20=20=20=20= an=20error=20occurred,=20or=20the=20file=20path.=20=20The=20file=20path=20= is=20either=20absolute=0A=20=20=20=20or=20relative=20to=20the=20= compilation=20directory.=20=20See=20dwarf_decl_file.=20=20*/=0Adiff=20= --git=20a/libdw/libdw.map=20b/libdw/libdw.map=0Aindex=20= 8ab0a2a0..2505cd46=20100644=0A---=20a/libdw/libdw.map=0A+++=20= b/libdw/libdw.map=0A@@=20-67,8=20+67,10=20@@=20ELFUTILS_0.122=20{=0A=20=20= =20=20=20dwarf_linebeginstatement;=0A=20=20=20=20=20dwarf_lineblock;=0A=20= =20=20=20=20dwarf_linecol;=0A+=20=20=20=20dwarf_linecontext;=0A=20=20=20=20= =20dwarf_lineendsequence;=0A=20=20=20=20=20dwarf_lineepiloguebegin;=0A+=20= =20=20=20dwarf_linefunctionname;=0A=20=20=20=20=20dwarf_lineno;=0A=20=20=20= =20=20dwarf_lineprologueend;=0A=20=20=20=20=20dwarf_linesrc;=0Adiff=20= --git=20a/libdw/libdwP.h=20b/libdw/libdwP.h=0Aindex=207174ea93..d8fa7e7e=20= 100644=0A---=20a/libdw/libdwP.h=0A+++=20b/libdw/libdwP.h=0A@@=20-291,6=20= +291,10=20@@=20struct=20Dwarf_Line_s=0A=20=20=20unsigned=20int=20= op_index:8;=0A=20=20=20unsigned=20int=20isa:8;=0A=20=20=20unsigned=20int=20= discriminator:24;=0A+/*=20Begin=20NVIDIA_LINEMAP_INLINING_EXTENSIONS=20= */=0A+=20=20unsigned=20int=20context;=0A+=20=20unsigned=20int=20= function_name;=0A+/*=20End=20NVIDIA_LINEMAP_INLINING_EXTENSIONS=20*/=0A=20= };=0A=20=0A=20struct=20Dwarf_Lines_s=0Adiff=20--git=20a/src/readelf.c=20= b/src/readelf.c=0Aindex=208191bde2..050f2592=20100644=0A---=20= a/src/readelf.c=0A+++=20b/src/readelf.c=0A@@=20-8481,6=20+8481,9=20@@=20= print_debug_line_section=20(Dwfl_Module=20*dwflmod,=20Ebl=20*ebl,=20= GElf_Ehdr=20*ehdr,=0A=20=09=20=20=20=20goto=20invalid_data;=0A=20=09=20=20= header_length=20=3D=20read_8ubyte_unaligned_inc=20(dbg,=20linep);=0A=20=09= }=0A+/*=20Begin=20NVIDIA_LINEMAP_INLINING_EXTENSIONS=20*/=0A+=20=20=20=20= =20=20const=20unsigned=20char=20*header_start=20=3D=20linep;=0A+/*=20End=20= NVIDIA_LINEMAP_INLINING_EXTENSIONS=20*/=0A=20=0A=20=20=20=20=20=20=20/*=20= Next=20the=20minimum=20instruction=20length.=20=20*/=0A=20=20=20=20=20=20= =20if=20((size_t)=20(lineendp=20-=20linep)=20<=201)=0A@@=20-8765,6=20= +8768,14=20@@=20print_debug_line_section=20(Dwfl_Module=20*dwflmod,=20= Ebl=20*ebl,=20GElf_Ehdr=20*ehdr,=0A=20=09=20=20++linep;=0A=20=09}=0A=20=0A= +/*=20Begin=20NVIDIA_LINEMAP_INLINING_EXTENSIONS=20*/=0A+=20=20=20=20=20=20= unsigned=20int=20debug_str_offset=20__attribute__((unused))=20=3D=200;=0A= +=20=20=20=20=20=20if=20(unlikely=20(linep=20<=20header_start=20+=20= header_length))=20{=0A+=09/*=20CUBINs=20contain=20an=20unsigned=204-byte=20= offset=20*/=0A+=09debug_str_offset=20=3D=20read_4ubyte_unaligned_inc=20= (dbg,=20linep);=0A+=20=20=20=20=20=20}=0A+/*=20End=20= NVIDIA_LINEMAP_INLINING_EXTENSIONS=20*/=0A+=0A=20=20=20=20=20=20=20if=20= (linep=20=3D=3D=20lineendp)=0A=20=09{=0A=20=09=20=20puts=20(_("\nNo=20= line=20number=20statements."));=0A@@=20-8913,6=20+8924,41=20@@=20= print_debug_line_section=20(Dwfl_Module=20*dwflmod,=20Ebl=20*ebl,=20= GElf_Ehdr=20*ehdr,=0A=20=09=09=20=20printf=20(_("=20set=20discriminator=20= to=20%u\n"),=20u128);=0A=20=09=09=20=20break;=0A=20=0A+/*=20Begin=20= NVIDIA_LINEMAP_INLINING_EXTENSIONS=20*/=0A+=09=09case=20= DW_LNE_inlined_call:=0A+=09=09=20=20{=0A+=09=09=20=20=20=20if=20= (unlikely=20(linep=20>=3D=20lineendp))=0A+=09=09=20=20=20=20=20=20goto=20= invalid_data;=0A+=0A+=09=09=20=20=20=20unsigned=20int=20context;=0A+=09=09= =20=20=20=20get_uleb128=20(context,=20linep,=20lineendp);=0A+=0A+=09=09=20= =20=20=20if=20(unlikely=20(linep=20>=3D=20lineendp))=0A+=09=09=20=20=20=20= =20=20goto=20invalid_data;=0A+=0A+=09=09=20=20=20=20unsigned=20int=20= function_name;=0A+=09=09=20=20=20=20get_uleb128=20(function_name,=20= linep,=20lineendp);=0A+=09=09=20=20=20=20function_name=20+=3D=20= debug_str_offset;=0A+=0A+=09=09=20=20=20=20printf=20(_("=20inlined=20= context=20%u,=20function=20name=200x%x=20\n"),=0A+=09=09=09=20=20=20=20= context,=20function_name);=0A+=09=09=20=20=20=20break;=0A+=09=09=20=20}=0A= +=0A+=09=09case=20DW_LNE_set_function_name:=0A+=09=09=20=20{=0A+=09=09=20= =20=20=20if=20(unlikely=20(linep=20>=3D=20lineendp))=0A+=09=09=20=20=20=20= =20=20goto=20invalid_data;=0A+=0A+=09=09=20=20=20=20unsigned=20int=20= function_name;=0A+=09=09=20=20=20=20get_uleb128=20(function_name,=20= linep,=20lineendp);=0A+=09=09=20=20=20=20function_name=20+=3D=20= debug_str_offset;=0A+=0A+=09=09=20=20=20=20printf=20(_("=20set=20= function=20name=20%u\n"),=20function_name);=0A+=09=09=20=20}=0A+=09=09=20= =20break;=0A+/*=20End=20NVIDIA_LINEMAP_INLINING_EXTENSIONS=20*/=0A+=0A=20= =09=09default:=0A=20=09=09=20=20/*=20Unknown,=20ignore=20it.=20=20*/=0A=20= =09=09=20=20puts=20(_("=20unknown=20opcode"));=0Adiff=20--git=20= a/tests/Makefile.am=20b/tests/Makefile.am=0Aindex=20c586422e..263d6bc5=20= 100644=0A---=20a/tests/Makefile.am=0A+++=20b/tests/Makefile.am=0A@@=20= -61,6=20+61,7=20@@=20check_PROGRAMS=20=3D=20arextract=20arsymtest=20= newfile=20saridx=20scnnames=20sectiondump=20\=0A=20=09=09=20=20= dwelf_elf_e_machine_string=20\=0A=20=09=09=20=20getphdrnum=20leb128=20= read_unaligned=20\=0A=20=09=09=20=20msg_tst=20system-elf-libelf-test=20\=0A= +=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= nvidia_extended_linemap_libdw=20\=0A=20=09=09=20=20$(asm_TESTS)=0A=20=0A=20= asm_TESTS=20=3D=20asm-tst1=20asm-tst2=20asm-tst3=20asm-tst4=20asm-tst5=20= \=0A@@=20-189,6=20+190,7=20@@=20TESTS=20=3D=20run-arextract.sh=20= run-arsymtest.sh=20run-ar.sh=20newfile=20test-nlist=20\=0A=20=09leb128=20= read_unaligned=20\=0A=20=09msg_tst=20system-elf-libelf-test=20\=0A=20=09= $(asm_TESTS)=20run-disasm-bpf.sh=20run-low_high_pc-dw-form-indirect.sh=20= \=0A+=09run-nvidia-extended-linemap-libdw.sh=20= run-nvidia-extended-linemap-readelf.sh=20\=0A=20=09= run-readelf-dw-form-indirect.sh=20run-strip-largealign.sh=0A=20=0A=20if=20= !BIARCH=0A@@=20-725,6=20+727,7=20@@=20dwelf_elf_e_machine_string_LDADD=20= =3D=20$(libelf)=20$(libdw)=0A=20getphdrnum_LDADD=20=3D=20$(libelf)=20= $(libdw)=0A=20leb128_LDADD=20=3D=20$(libelf)=20$(libdw)=0A=20= read_unaligned_LDADD=20=3D=20$(libelf)=20$(libdw)=0A= +nvidia_extended_linemap_libdw_LDADD=20=3D=20$(libelf)=20$(libdw)=0A=20=0A= =20#=20We=20want=20to=20test=20the=20libelf=20header=20against=20the=20= system=20elf.h=20header.=0A=20#=20Don't=20include=20any=20-I=20CPPFLAGS.=20= Except=20when=20we=20install=20our=20own=20elf.h.=0Adiff=20--git=20= a/tests/nvidia_extended_linemap_libdw.c=20= b/tests/nvidia_extended_linemap_libdw.c=0Anew=20file=20mode=20100644=0A= index=2000000000..9f1e5efd=0A---=20/dev/null=0A+++=20= b/tests/nvidia_extended_linemap_libdw.c=0A@@=20-0,0=20+1,153=20@@=0A+/*=20= Inspect=20nvidia=20extended=20linemap=20with=20dwarf_next_lines.=0A+=20=20= =20Copyright=20(C)=202002,=202004,=202018=20Red=20Hat,=20Inc.=0A+=20=20=20= This=20file=20is=20part=20of=20elfutils.=0A+=0A+=20=20=20This=20file=20= is=20free=20software;=20you=20can=20redistribute=20it=20and/or=20modify=0A= +=20=20=20it=20under=20the=20terms=20of=20the=20GNU=20General=20Public=20= License=20as=20published=20by=0A+=20=20=20the=20Free=20Software=20= Foundation;=20either=20version=203=20of=20the=20License,=20or=0A+=20=20=20= (at=20your=20option)=20any=20later=20version.=0A+=0A+=20=20=20elfutils=20= is=20distributed=20in=20the=20hope=20that=20it=20will=20be=20useful,=20= but=0A+=20=20=20WITHOUT=20ANY=20WARRANTY;=20without=20even=20the=20= implied=20warranty=20of=0A+=20=20=20MERCHANTABILITY=20or=20FITNESS=20FOR=20= A=20PARTICULAR=20PURPOSE.=20=20See=20the=0A+=20=20=20GNU=20General=20= Public=20License=20for=20more=20details.=0A+=0A+=20=20=20You=20should=20= have=20received=20a=20copy=20of=20the=20GNU=20General=20Public=20License=0A= +=20=20=20along=20with=20this=20program.=20=20If=20not,=20see=20= .=20=20*/=0A+=0A+#ifdef=20HAVE_CONFIG_H=0A= +#=20include=20=0A+#endif=0A+=0A+#include=20=0A= +#include=20=0A+#include=20=0A+#include=20= ELFUTILS_HEADER(dw)=0A+#include=20=0A+#include=20=0A= +#include=20=0A+=0A+=0A+int=0A+main=20(int=20argc,=20char=20= *argv[])=0A+{=0A+=20=20int=20result=20=3D=200;=0A+=20=20int=20cnt;=0A+=0A= +=20=20for=20(cnt=20=3D=201;=20cnt=20<=20argc;=20++cnt)=0A+=20=20=20=20{=0A= +=20=20=20=20=20=20int=20fd=20=3D=20open=20(argv[cnt],=20O_RDONLY);=0A+=0A= +=20=20=20=20=20=20Dwarf=20*dbg=20=3D=20dwarf_begin=20(fd,=20= DWARF_C_READ);=0A+=20=20=20=20=20=20if=20=20(dbg=20=3D=3D=20NULL)=0A+=09= {=0A+=09=20=20printf=20("%s=20not=20usable:=20%s\n",=20argv[cnt],=20= dwarf_errmsg=20(-1));=0A+=09=20=20close=20=20(fd);=0A+=09=20=20continue;=0A= +=09}=0A+=0A+=20=20=20=20=20=20Dwarf_Off=20off;=0A+=20=20=20=20=20=20= Dwarf_Off=20next_off=20=3D=200;=0A+=20=20=20=20=20=20Dwarf_CU=20*cu=20=3D=20= NULL;=0A+=20=20=20=20=20=20Dwarf_Lines=20*lb;=0A+=20=20=20=20=20=20= size_t=20nlb;=0A+=20=20=20=20=20=20int=20res;=0A+=20=20=20=20=20=20while=20= ((res=20=3D=20dwarf_next_lines=20(dbg,=20off=20=3D=20next_off,=20= &next_off,=20&cu,=0A+=09=09=09=09=20=20=20=20=20=20NULL,=20NULL,=20&lb,=20= &nlb))=20=3D=3D=200)=0A+=09{=0A+=09=20=20printf=20("off=20=3D=20%"=20= PRIu64=20"\n",=20off);=0A+=09=20=20printf=20("=20%zu=20lines\n",=20nlb);=0A= +=0A+=09=20=20for=20(size_t=20i=20=3D=200;=20i=20<=20nlb;=20++i)=0A+=09=20= =20=20=20{=0A+=09=20=20=20=20=20=20Dwarf_Line=20*l=20=3D=20= dwarf_onesrcline=20(lb,=20i);=0A+=09=20=20=20=20=20=20if=20(l=20=3D=3D=20= NULL)=0A+=09=09{=0A+=09=09=20=20printf=20("%s:=20cannot=20get=20= individual=20line\n",=20argv[cnt]);=0A+=09=09=20=20result=20=3D=201;=0A+=09= =09=20=20break;=0A+=09=09}=0A+=0A+=09=20=20=20=20=20=20Dwarf_Addr=20= addr;=0A+=09=20=20=20=20=20=20if=20(dwarf_lineaddr=20(l,=20&addr)=20!=3D=20= 0)=0A+=09=09addr=20=3D=200;=0A+=09=20=20=20=20=20=20const=20char=20*file=20= =3D=20dwarf_linesrc=20(l,=20NULL,=20NULL);=0A+=09=20=20=20=20=20=20int=20= line;=0A+=09=20=20=20=20=20=20if=20(dwarf_lineno=20(l,=20&line)=20!=3D=20= 0)=0A+=09=09line=20=3D=200;=0A+=0A+=09=20=20=20=20=20=20printf=20("%"=20= PRIx64=20":=20%s:%d:",=20(uint64_t)=20addr,=0A+=09=09=20=20=20=20=20=20= file=20?:=20"???",=20line);=0A+=0A+=09=20=20=20=20=20=20/*=20Getting=20= the=20file=20path=20through=20the=20Dwarf_Files=20should=0A+=09=09=20= result=20in=20the=20same=20path.=20=20*/=0A+=09=20=20=20=20=20=20= Dwarf_Files=20*files;=0A+=09=20=20=20=20=20=20size_t=20idx;=0A+=09=20=20=20= =20=20=20if=20(dwarf_line_file=20(l,=20&files,=20&idx)=20!=3D=200)=0A+=09= =09{=0A+=09=09=20=20printf=20("%s:=20cannot=20get=20file=20from=20line=20= (%zd):=20%s\n",=0A+=09=09=09=20=20argv[cnt],=20i,=20dwarf_errmsg=20= (-1));=0A+=09=09=20=20result=20=3D=201;=0A+=09=09=20=20break;=0A+=09=09}=0A= +=09=20=20=20=20=20=20const=20char=20*path=20=3D=20dwarf_filesrc=20= (files,=20idx,=20NULL,=20NULL);=0A+=09=20=20=20=20=20=20if=20((path=20=3D=3D= =20NULL=20&&=20file=20!=3D=20NULL)=0A+=09=09=20=20||=20(path=20!=3D=20= NULL=20&&=20file=20=3D=3D=20NULL)=0A+=09=09=20=20||=20(strcmp=20(file,=20= path)=20!=3D=200))=0A+=09=09{=0A+=09=09=20=20printf=20("%s:=20line=20%zd=20= srcline=20(%s)=20!=3D=20file=20srcline=20(%s)\n",=0A+=09=09=09=20=20= argv[cnt],=20i,=20file=20?:=20"???",=20path=20?:=20"???");=0A+=09=09=20=20= result=20=3D=201;=0A+=09=09=20=20break;=0A+=09=09}=0A+=0A+=09=20=20=20=20= =20=20int=20column;=0A+=09=20=20=20=20=20=20if=20(dwarf_linecol=20(l,=20= &column)=20!=3D=200)=0A+=09=09column=20=3D=200;=0A+=09=20=20=20=20=20=20= if=20(column=20>=3D=200)=0A+=09=09printf=20("%d:",=20column);=0A+=0A+=20=20= =20=20=20=20=20=20=20=20=20=20=20=20unsigned=20int=20context;=0A+=09=20=20= =20=20=20=20if=20(dwarf_linecontext=20(l,=20&context)=20!=3D=200)=0A+=09=20= =20=20=20=20=20=20=20context=20=3D=200;=0A+=20=20=20=20=20=20=20=20=20=20= =20=20=20=20unsigned=20int=20functionname;=0A+=09=20=20=20=20=20=20if=20= (dwarf_linefunctionname=20(l,=20&functionname)=20!=3D=200)=0A+=09=09= functionname=20=3D=200;=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20if=20= (context=20>=200)=20{=0A+=09=09=20=20printf=20("=20context:%u,=20= functionname:%u,",=20context,=20functionname);=0A+=20=20=20=20=20=20=20=20= =20=20=20=20=20=20}=0A+=0A+=09=20=20=20=20=20=20bool=20is_stmt;=0A+=09=20= =20=20=20=20=20if=20(dwarf_linebeginstatement=20(l,=20&is_stmt)=20!=3D=20= 0)=0A+=09=09is_stmt=20=3D=20false;=0A+=09=20=20=20=20=20=20bool=20= end_sequence;=0A+=09=20=20=20=20=20=20if=20(dwarf_lineendsequence=20(l,=20= &end_sequence)=20!=3D=200)=0A+=09=09end_sequence=20=3D=20false;=0A+=09=20= =20=20=20=20=20bool=20basic_block;=0A+=09=20=20=20=20=20=20if=20= (dwarf_lineblock=20(l,=20&basic_block)=20!=3D=200)=0A+=09=09basic_block=20= =3D=20false;=0A+=09=20=20=20=20=20=20bool=20prologue_end;=0A+=09=20=20=20= =20=20=20if=20(dwarf_lineprologueend=20(l,=20&prologue_end)=20!=3D=200)=0A= +=09=09prologue_end=20=3D=20false;=0A+=09=20=20=20=20=20=20bool=20= epilogue_begin;=0A+=09=20=20=20=20=20=20if=20(dwarf_lineepiloguebegin=20= (l,=20&epilogue_begin)=20!=3D=200)=0A+=09=09epilogue_begin=20=3D=20= false;=0A+=09=20=20=20=20=20=20printf=20("=20is_stmt:%s,=20end_seq:%s,=20= bb:%s,=20prologue:%s,=20epilogue:%s\n",=0A+=09=09=20=20=20=20=20=20= is_stmt=20?=20"yes"=20:=20"no",=20end_sequence=20?=20"yes"=20:=20"no",=0A= +=09=09=20=20=20=20=20=20basic_block=20?=20"yes"=20:=20"no",=20= prologue_end=20=20?=20"yes"=20:=20"no",=0A+=09=09=20=20=20=20=20=20= epilogue_begin=20?=20"yes"=20:=20"no");=0A+=09=20=20=20=20}=0A+=09}=0A+=0A= +=20=20=20=20=20=20if=20(res=20<=200)=0A+=09{=0A+=09=20=20printf=20= ("dwarf_next_lines=20failed:=20%s\n",=20dwarf_errmsg=20(-1));=0A+=09=20=20= result=20=3D=201;=0A+=09}=0A+=0A+=20=20=20=20=20=20dwarf_end=20(dbg);=0A= +=20=20=20=20=20=20close=20(fd);=0A+=20=20=20=20}=0A+=0A+=20=20return=20= result;=0A+}=0Adiff=20--git=20= a/tests/run-nvidia-extended-linemap-libdw.sh=20= b/tests/run-nvidia-extended-linemap-libdw.sh=0Anew=20file=20mode=20= 100755=0Aindex=2000000000..b0386b49=0A---=20/dev/null=0A+++=20= b/tests/run-nvidia-extended-linemap-libdw.sh=0A@@=20-0,0=20+1,41=20@@=0A= +#=20Copyright=20(C)=202011=20Red=20Hat,=20Inc.=0A+#=20This=20file=20is=20= part=20of=20elfutils.=0A+#=0A+#=20This=20file=20is=20free=20software;=20= you=20can=20redistribute=20it=20and/or=20modify=0A+#=20it=20under=20the=20= terms=20of=20the=20GNU=20General=20Public=20License=20as=20published=20= by=0A+#=20the=20Free=20Software=20Foundation;=20either=20version=203=20= of=20the=20License,=20or=0A+#=20(at=20your=20option)=20any=20later=20= version.=0A+#=0A+#=20elfutils=20is=20distributed=20in=20the=20hope=20= that=20it=20will=20be=20useful,=20but=0A+#=20WITHOUT=20ANY=20WARRANTY;=20= without=20even=20the=20implied=20warranty=20of=0A+#=20MERCHANTABILITY=20= or=20FITNESS=20FOR=20A=20PARTICULAR=20PURPOSE.=20=20See=20the=0A+#=20GNU=20= General=20Public=20License=20for=20more=20details.=0A+#=0A+#=20You=20= should=20have=20received=20a=20copy=20of=20the=20GNU=20General=20Public=20= License=0A+#=20along=20with=20this=20program.=20=20If=20not,=20see=20= .=0A+=0A+.=20$srcdir/test-subr.sh=0A+=0A= +testfiles=20testfile_nvidia_linemap=0A+testrun_compare=20= ${abs_top_builddir}/tests/nvidia_extended_linemap_libdw=20= testfile_nvidia_linemap=20<<=20EOF=0A+off=20=3D=200=0A+=2018=20lines=0A= +0:=20= /home/johnmc/hpctoolkit-gpu-samples/nvidia_extended_linemap4/main.cu:25:0:= =20is_stmt:yes,=20end_seq:no,=20bb:no,=20prologue:no,=20epilogue:no=0A= +10:=20= /home/johnmc/hpctoolkit-gpu-samples/nvidia_extended_linemap4/main.cu:26:0:= =20is_stmt:yes,=20end_seq:no,=20bb:no,=20prologue:no,=20epilogue:no=0A= +40:=20= /home/johnmc/hpctoolkit-gpu-samples/nvidia_extended_linemap4/main.cu:27:0:= =20is_stmt:yes,=20end_seq:no,=20bb:no,=20prologue:no,=20epilogue:no=0A= +90:=20= /home/johnmc/hpctoolkit-gpu-samples/nvidia_extended_linemap4/main.cu:25:0:= =20is_stmt:yes,=20end_seq:no,=20bb:no,=20prologue:no,=20epilogue:no=0A= +a0:=20= /home/johnmc/hpctoolkit-gpu-samples/nvidia_extended_linemap4/main.cu:28:0:= =20is_stmt:yes,=20end_seq:no,=20bb:no,=20prologue:no,=20epilogue:no=0A= +100:=20= /home/johnmc/hpctoolkit-gpu-samples/nvidia_extended_linemap4/main.cu:28:0:= =20is_stmt:yes,=20end_seq:no,=20bb:no,=20prologue:no,=20epilogue:no=0A= +100:=20= /home/johnmc/hpctoolkit-gpu-samples/nvidia_extended_linemap4/main.cu:8:0:=20= context:6,=20functionname:0,=20is_stmt:yes,=20end_seq:no,=20bb:no,=20= prologue:no,=20epilogue:no=0A+150:=20= /home/johnmc/hpctoolkit-gpu-samples/nvidia_extended_linemap4/main.cu:9:0:=20= context:6,=20functionname:0,=20is_stmt:yes,=20end_seq:no,=20bb:no,=20= prologue:no,=20epilogue:no=0A+1e0:=20= /home/johnmc/hpctoolkit-gpu-samples/nvidia_extended_linemap4/main.cu:31:0:= =20is_stmt:yes,=20end_seq:no,=20bb:no,=20prologue:no,=20epilogue:no=0A= +1e0:=20= /home/johnmc/hpctoolkit-gpu-samples/nvidia_extended_linemap4/bar.h:6:0:=20= context:9,=20functionname:4,=20is_stmt:yes,=20end_seq:no,=20bb:no,=20= prologue:no,=20epilogue:no=0A+1e0:=20= /home/johnmc/hpctoolkit-gpu-samples/nvidia_extended_linemap4/main.cu:8:0:=20= context:10,=20functionname:0,=20is_stmt:yes,=20end_seq:no,=20bb:no,=20= prologue:no,=20epilogue:no=0A+220:=20= /home/johnmc/hpctoolkit-gpu-samples/nvidia_extended_linemap4/main.cu:9:0:=20= context:10,=20functionname:0,=20is_stmt:yes,=20end_seq:no,=20bb:no,=20= prologue:no,=20epilogue:no=0A+2b0:=20= /home/johnmc/hpctoolkit-gpu-samples/nvidia_extended_linemap4/bar.h:7:0:=20= context:9,=20functionname:4,=20is_stmt:yes,=20end_seq:no,=20bb:no,=20= prologue:no,=20epilogue:no=0A+2f0:=20= /home/johnmc/hpctoolkit-gpu-samples/nvidia_extended_linemap4/bar.h:8:0:=20= context:9,=20functionname:4,=20is_stmt:yes,=20end_seq:no,=20bb:no,=20= prologue:no,=20epilogue:no=0A+2f0:=20= /home/johnmc/hpctoolkit-gpu-samples/nvidia_extended_linemap4/main.cu:18:0:= =20context:14,=20functionname:8,=20is_stmt:yes,=20end_seq:no,=20bb:no,=20= prologue:no,=20epilogue:no=0A+330:=20= /home/johnmc/hpctoolkit-gpu-samples/nvidia_extended_linemap4/main.cu:19:0:= =20context:14,=20functionname:8,=20is_stmt:yes,=20end_seq:no,=20bb:no,=20= prologue:no,=20epilogue:no=0A+3c0:=20= /home/johnmc/hpctoolkit-gpu-samples/nvidia_extended_linemap4/main.cu:33:0:= =20is_stmt:yes,=20end_seq:no,=20bb:no,=20prologue:no,=20epilogue:no=0A= +480:=20= /home/johnmc/hpctoolkit-gpu-samples/nvidia_extended_linemap4/main.cu:33:0:= =20is_stmt:yes,=20end_seq:yes,=20bb:no,=20prologue:no,=20epilogue:no=0A= +EOF=0Adiff=20--git=20a/tests/run-nvidia-extended-linemap-readelf.sh=20= b/tests/run-nvidia-extended-linemap-readelf.sh=0Anew=20file=20mode=20= 100755=0Aindex=2000000000..6ad96027=0A---=20/dev/null=0A+++=20= b/tests/run-nvidia-extended-linemap-readelf.sh=0A@@=20-0,0=20+1,114=20@@=0A= +#=20Copyright=20(C)=202011=20Red=20Hat,=20Inc.=0A+#=20This=20file=20is=20= part=20of=20elfutils.=0A+#=0A+#=20This=20file=20is=20free=20software;=20= you=20can=20redistribute=20it=20and/or=20modify=0A+#=20it=20under=20the=20= terms=20of=20the=20GNU=20General=20Public=20License=20as=20published=20= by=0A+#=20the=20Free=20Software=20Foundation;=20either=20version=203=20= of=20the=20License,=20or=0A+#=20(at=20your=20option)=20any=20later=20= version.=0A+#=0A+#=20elfutils=20is=20distributed=20in=20the=20hope=20= that=20it=20will=20be=20useful,=20but=0A+#=20WITHOUT=20ANY=20WARRANTY;=20= without=20even=20the=20implied=20warranty=20of=0A+#=20MERCHANTABILITY=20= or=20FITNESS=20FOR=20A=20PARTICULAR=20PURPOSE.=20=20See=20the=0A+#=20GNU=20= General=20Public=20License=20for=20more=20details.=0A+#=0A+#=20You=20= should=20have=20received=20a=20copy=20of=20the=20GNU=20General=20Public=20= License=0A+#=20along=20with=20this=20program.=20=20If=20not,=20see=20= .=0A+=0A+.=20$srcdir/test-subr.sh=0A+=0A= +testfiles=20testfile_nvidia_linemap=0A+testrun_compare=20= ${abs_top_builddir}/src/readelf=20--debug-dump=3Dline=20= testfile_nvidia_linemap=20<<=20EOF=0A+=0A+DWARF=20section=20[=205]=20= '.debug_line'=20at=20offset=200x3e0:=0A+=0A+Table=20at=20offset=200:=0A+=0A= +=20Length:=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20253=0A+=20DWARF=20version:=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=202=0A+=20Prologue=20length:=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20111=0A+=20Address=20size:=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=208=0A+=20Segment=20selector=20size:=20=20=20=20= =20=20=20=20=20=200=0A+=20Min=20instruction=20length:=20=20=20=20=20=20=20= =20=201=0A+=20Max=20operations=20per=20instruction:=201=0A+=20Initial=20= value=20if=20'is_stmt':=20=20=20=20=201=0A+=20Line=20base:=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20-5=0A+=20Line=20= range:=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=2014=0A= +=20Opcode=20base:=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =2010=0A+=0A+Opcodes:=0A+=20=20[1]=20=200=20arguments=0A+=20=20[2]=20=20= 1=20argument=0A+=20=20[3]=20=201=20argument=0A+=20=20[4]=20=201=20= argument=0A+=20=20[5]=20=201=20argument=0A+=20=20[6]=20=200=20arguments=0A= +=20=20[7]=20=200=20arguments=0A+=20=20[8]=20=200=20arguments=0A+=20=20= [9]=20=201=20argument=0A+=0A+Directory=20table:=0A+=20= /home/johnmc/hpctoolkit-gpu-samples/nvidia_extended_linemap4=0A+=0A+File=20= name=20table:=0A+=20Entry=20Dir=20=20=20Time=20=20=20=20=20=20Size=20=20=20= =20=20=20Name=0A+=201=20=20=20=20=201=20=20=20=20=201626104146=201819=20=20= =20=20=20=20main.cu=0A+=202=20=20=20=20=201=20=20=20=20=201626104111=20= 211=20=20=20=20=20=20=20bar.h=0A+=0A+Line=20number=20statements:=0A+=20[=20= =20=20=2079]=20extended=20opcode=202:=20=20set=20address=20to=200=20= =0A+=20[=20=20=20=2084]=20set=20file=20to=201=0A+=20[=20=20=20=20= 86]=20advance=20line=20by=20constant=2024=20to=2025=0A+=20[=20=20=20=20= 88]=20copy=0A+=20[=20=20=20=2089]=20special=20opcode=20240:=20address+16=20= =3D=200x10=20,=20line+1=20=3D=2026=0A+=20[=20=20=20=208a]=20= advance=20line=20by=20constant=201=20to=2027=0A+=20[=20=20=20=208c]=20= advance=20address=20by=2048=20to=200x40=20=0A+=20[=20=20=20=20= 8e]=20copy=0A+=20[=20=20=20=208f]=20advance=20line=20by=20constant=20-2=20= to=2025=0A+=20[=20=20=20=2091]=20advance=20address=20by=2080=20to=200x90=20= =0A+=20[=20=20=20=2094]=20copy=0A+=20[=20=20=20=2095]=20= special=20opcode=20242:=20address+16=20=3D=200xa0=20,=20= line+3=20=3D=2028=0A+=20[=20=20=20=2096]=20advance=20address=20by=2096=20= to=200x100=20=0A+=20[=20=20=20=2099]=20copy=0A+=20[=20=20=20= =209a]=20extended=20opcode=20144:=20=20inlined=20context=206,=20function=20= name=200x0=20=0A+=20[=20=20=20=209f]=20advance=20line=20by=20constant=20= -20=20to=208=0A+=20[=20=20=20=20a1]=20copy=0A+=20[=20=20=20=20a2]=20= advance=20line=20by=20constant=201=20to=209=0A+=20[=20=20=20=20a4]=20= advance=20address=20by=2080=20to=200x150=20=0A+=20[=20=20=20= =20a7]=20copy=0A+=20[=20=20=20=20a8]=20extended=20opcode=20144:=20=20= inlined=20context=200,=20function=20name=200x0=20=0A+=20[=20=20=20=20ad]=20= advance=20line=20by=20constant=2022=20to=2031=0A+=20[=20=20=20=20af]=20= advance=20address=20by=20144=20to=200x1e0=20=0A+=20[=20=20=20= =20b2]=20copy=0A+=20[=20=20=20=20b3]=20set=20file=20to=202=0A+=20[=20=20=20= =20b5]=20extended=20opcode=20144:=20=20inlined=20context=209,=20function=20= name=200x4=20=0A+=20[=20=20=20=20ba]=20advance=20line=20by=20constant=20= -25=20to=206=0A+=20[=20=20=20=20bc]=20copy=0A+=20[=20=20=20=20bd]=20set=20= file=20to=201=0A+=20[=20=20=20=20bf]=20extended=20opcode=20144:=20=20= inlined=20context=2010,=20function=20name=200x0=20=0A+=20[=20=20=20=20= c4]=20advance=20line=20by=20constant=202=20to=208=0A+=20[=20=20=20=20c6]=20= copy=0A+=20[=20=20=20=20c7]=20advance=20line=20by=20constant=201=20to=20= 9=0A+=20[=20=20=20=20c9]=20advance=20address=20by=2064=20to=200x220=20= =0A+=20[=20=20=20=20cc]=20copy=0A+=20[=20=20=20=20cd]=20= set=20file=20to=202=0A+=20[=20=20=20=20cf]=20extended=20opcode=20144:=20=20= inlined=20context=209,=20function=20name=200x4=20=0A+=20[=20=20=20=20d4]=20= advance=20line=20by=20constant=20-2=20to=207=0A+=20[=20=20=20=20d6]=20= advance=20address=20by=20144=20to=200x2b0=20=0A+=20[=20=20=20= =20d9]=20copy=0A+=20[=20=20=20=20da]=20advance=20line=20by=20constant=20= 1=20to=208=0A+=20[=20=20=20=20dc]=20advance=20address=20by=2064=20to=20= 0x2f0=20=0A+=20[=20=20=20=20df]=20copy=0A+=20[=20=20=20=20= e0]=20set=20file=20to=201=0A+=20[=20=20=20=20e2]=20extended=20opcode=20= 144:=20=20inlined=20context=2014,=20function=20name=200x8=20=0A+=20[=20=20= =20=20e7]=20advance=20line=20by=20constant=2010=20to=2018=0A+=20[=20=20=20= =20e9]=20copy=0A+=20[=20=20=20=20ea]=20advance=20line=20by=20constant=20= 1=20to=2019=0A+=20[=20=20=20=20ec]=20advance=20address=20by=2064=20to=20= 0x330=20=0A+=20[=20=20=20=20ef]=20copy=0A+=20[=20=20=20=20= f0]=20extended=20opcode=20144:=20=20inlined=20context=200,=20function=20= name=200x0=20=0A+=20[=20=20=20=20f5]=20advance=20line=20by=20constant=20= 14=20to=2033=0A+=20[=20=20=20=20f7]=20advance=20address=20by=20144=20to=20= 0x3c0=20=0A+=20[=20=20=20=20fa]=20copy=0A+=20[=20=20=20=20= fb]=20advance=20address=20by=20192=20to=200x480=0A+=20[=20=20=20=20fe]=20= extended=20opcode=201:=20=20end=20of=20sequence=0A+EOF=0Adiff=20--git=20= a/tests/testfile_nvidia_linemap.bz2=20= b/tests/testfile_nvidia_linemap.bz2=0Anew=20file=20mode=20100644=0Aindex=20= 0000000000000000000000000000000000000000..8a6d09fbd1419af2b4664e8751207be4= 70198f1a=0AGIT=20binary=20patch=0Aliteral=202365=0A= zcmV-D3BvY5T4*^jL0KkKSq)>6PXG%lfB*mg|L^|i|Nqm@%YXm>|9|bF;0gptplMZb=0A= z+z@oxek$MzA3=3DLe*sZ4QFf%trk<(lJVeQ+CXEdl4WbN<=0A= z003wJ222QOG|4JO$`Q^Ookzl7$XsrKr|R55rS!>07C#HCYdx~lTt}N=0A= z38AT?G}BEz6Gx~S0Av6%G&D2~0017KWB>pLfCE4P28bFNG}BB>fu@E=3DhD|gy8euXR=0A= zhCpD9Moj?FV2nlyri=3Dj$0F0Vs(Sk(*1jt54hEjf{$kR~t(lp+b(p@T+?W=3DXfGcS&L5UbU0?35a#xs8L!r-U)TF1&F!__dKhBSQp!#+wj$%m9uMNR-G!K_M%dqZ6H;=0A= zp6s^6LtA42tC>wzChpmB6xue3L}H1b!5}H>R`jsiDJG5(on{65{32{>NRWayf(z@`1E`3y{=0A= zl~q+m1VF!oZ8R)6HEO=3DU!CjHKL=3Di#lMp8Ugu|_5N>}!I}P<2H9jm?W|S`&9IL7fYl&9&Tajy_+U=0A= zco?v~b4#nESGuIQ`WznwnVcDcvISVY32sJ@;zMlYbDE<_Ci5dU5WJ7A^d;1t&%hFdjAKBEu4x*h0Wpf#4;~SW1h|NlaA3mRdio<%=0A= zGpjR0sd)xQTDw99PZxme&R|Hv~Sh-6jvSs*KAN5Z798xL3$;=0A= z9FnOe=3D%tyNnVINO5fKqInrWo~+BvML@!#9pbEQiVVg!noOb1AemW7{KqN380XnRY1=0A= z6{JWGivo+!W+h-4Y3?|6%5MW0g;{{xNZkBE)Ja^Fk-a=3DDk=0A= zS=3DwXMwrouPmhh`=3D=3D%Vz67fDh|NyHUm+g!3v8g!M10QsMnf&`Qk+^IDn5Z;=3DPj1~a5= =0AzH&O@Dx5OLVo51JwnP)1TKRjw}r3i|mBC4vaL`EVgtVLB-h=3D{~hRw5{4IBBKH!Y!!n8(v!LfgK&f~C6?3$*akx+tT+~`=0A= zQ&mt=3DO;aXEkO2drE@PBN-FLcr75GzJg+W0&@WT#_C_bl!Qmkb@|P;)P6=3DsVtW;lDLBoVZy4hQ58{8Mk=3DbRAgk!m5)flbxZQ3X+O!1lp@o(X=0A= z+SMs00cDV_Ba9V5-r^D{G#CoWD#*P+kpPw8M6zZih>HSCTG3%@-dffX$!=3DA)MiVAu=0A= zjx63v@7iqgAu&330$@?#DN=0A= z6NEditP%rEZN^JA8Y?;mfGz=3Da@`QwllSz_F08}3)mY~3kP&Ps_ZMmM0c!-Q49`B4#=0A= zcb+A-d|*WH1GzczT?Nf5cK!b{F_9@3pgiJJ3pWL7W>gA4=0A= zGiDm}BpCOl$LYMDSzZy{NiuK^^pSeEbtH;V1z?N>)ah6m1~G-bIK(87XT3qK5)l9x=0A= z40mqd)(~-IuM57Vl3(pymwh1aNiBL67qdt&_v%@YFH69NQHiccgh3-{yq!_dYu|g@=0A= z=3D@*8TomE+8s9{vLJ*R@(ZQtwkpx|qDhM_ZY0%9&mHga|(YR7p3b|5p@TdqM_Eg+-s=0A= zLL!iMrX_|_A~gsaL?&2rselIk+iLV;pl>wLF0}Gs9l=3DWS)!Yq_pXg3`#*M}(Q-g2@=0A= z1`~`<3%;7Tx%_a8VyAZl!6_V$UBw`=3D4iMR4eXP@L*K7((7gR*|jKtwYBx*=3D67Nb8((Hm10=0A= zTeLcBi18~G1vRWQDD}RujxL{FF1l1;K}-aDVK9GC32vRua)mg)2*#^e6+Jh`NDdNs=0A= zn#lrvt*a9C4j5hys&rMN&Pg;`(RCy8V3aTH7)tkQALtOK1(%p_BZdf^uW4^<3GX)mdW&zZuC%MyCDnGxGg7=0A= j?