File tree Expand file tree Collapse file tree 3 files changed +37
-19
lines changed Expand file tree Collapse file tree 3 files changed +37
-19
lines changed Original file line number Diff line number Diff line change @@ -953,26 +953,9 @@ psymtab_to_fullname (struct partial_symtab *ps)
953953 to handle cases like the file being moved. */
954954 if (ps -> fullname == NULL )
955955 {
956- gdb ::unique_xmalloc_ptr < char > fullname ;
957- scoped_fd fd = find_and_open_source (ps -> filename , ps -> dirname ,
958- & fullname );
956+ gdb ::unique_xmalloc_ptr < char > fullname
957+ = find_source_or_rewrite (ps -> filename , ps -> dirname );
959958 ps -> fullname = fullname .release ();
960-
961- if (fd .get () < 0 )
962- {
963- /* rewrite_source_path would be applied by find_and_open_source, we
964- should report the pathname where GDB tried to find the file. */
965-
966- if (ps -> dirname == NULL || IS_ABSOLUTE_PATH (ps -> filename ))
967- fullname .reset (xstrdup (ps -> filename ));
968- else
969- fullname .reset (concat (ps -> dirname , SLASH_STRING ,
970- ps -> filename , (char * ) NULL ));
971-
972- ps -> fullname = rewrite_source_path (fullname .get ()).release ();
973- if (ps -> fullname == NULL )
974- ps -> fullname = fullname .release ();
975- }
976959 }
977960
978961 return ps -> fullname ;
Original file line number Diff line number Diff line change @@ -1193,6 +1193,34 @@ open_source_file (struct symtab *s)
11931193 return fd ;
11941194}
11951195
1196+ /* See source.h. */
1197+
1198+ gdb ::unique_xmalloc_ptr < char >
1199+ find_source_or_rewrite (const char * filename , const char * dirname )
1200+ {
1201+ gdb ::unique_xmalloc_ptr < char > fullname ;
1202+
1203+ scoped_fd fd = find_and_open_source (filename , dirname , & fullname );
1204+ if (fd .get () < 0 )
1205+ {
1206+ /* rewrite_source_path would be applied by find_and_open_source, we
1207+ should report the pathname where GDB tried to find the file. */
1208+
1209+ if (dirname == nullptr || IS_ABSOLUTE_PATH (filename ))
1210+ fullname .reset (xstrdup (filename ));
1211+ else
1212+ fullname .reset (concat (dirname , SLASH_STRING ,
1213+ filename , (char * ) nullptr ));
1214+
1215+ gdb ::unique_xmalloc_ptr < char > rewritten
1216+ = rewrite_source_path (fullname .get ());
1217+ if (rewritten != nullptr )
1218+ fullname = std ::move (rewritten );
1219+ }
1220+
1221+ return fullname ;
1222+ }
1223+
11961224/* Finds the fullname that a symtab represents.
11971225
11981226 This functions finds the fullname and saves it in s->fullname.
Original file line number Diff line number Diff line change @@ -72,6 +72,13 @@ extern scoped_fd find_and_open_source (const char *filename,
7272 const char *dirname,
7373 gdb::unique_xmalloc_ptr<char > *fullname);
7474
75+ /* A wrapper for find_and_open_source that returns the full name. If
76+ the full name cannot be found, a full name is constructed based on
77+ the parameters, passing them through rewrite_source_path. */
78+
79+ extern gdb::unique_xmalloc_ptr<char > find_source_or_rewrite
80+ (const char *filename, const char *dirname);
81+
7582/* Open a source file given a symtab S. Returns a file descriptor or
7683 negative number for error. */
7784extern scoped_fd open_source_file (struct symtab *s);
You can’t perform that action at this time.
0 commit comments