26 * attach to arguments in argc, argv
29 attachargs(int argc, char **argv, int omode, int verbose)
42 for(i=0; i<argc; i++){
45 fprint(2, "already have corpid %d; ignoring corpid %d\n", corpid, argv[i]);
49 fprint(2, "already have core %s; ignoring corpid %d\n", corfil, corpid);
52 corpid = atoi(argv[i]);
55 if((hdr = crackhdr(argv[i], omode)) == nil){
56 fprint(2, "crackhdr %s: %r\n", argv[i]);
60 fprint(2, "%s: %s %s %s\n", argv[i], hdr->aname, hdr->mname, hdr->fname);
61 if(hdr->ftype == FCORE){
63 fprint(2, "already have corpid %d; ignoring core %s\n", corpid, argv[i]);
68 fprint(2, "already have core %s; ignoring core %s\n", corfil, argv[i]);
76 fprint(2, "already have text %s; ignoring text %s\n", symfil, argv[i]);
86 symfil = "a.out"; /* default */
87 if(corpid){ /* try from corpid */
88 if((s = proctextfile(corpid)) != nil){
90 fprint(2, "corpid %d: text %s\n", corpid, s);
94 if(corhdr && corhdr->cmdline){ /* try from core */
96 * prog gives only the basename of the command,
97 * so try the command line for a path.
99 if((s = strdup(corhdr->cmdline)) != nil){
103 if((t = searchpath(s)) != nil){
105 fprint(2, "core: text %s\n", t);
111 if((symhdr = crackhdr(symfil, omode)) == nil){
112 fprint(2, "crackhdr %s: %r\n", symfil);
128 if(symmap == nil || cormap == nil)
129 sysfatal("allocating maps: %r");
132 if(mapfile(symhdr, 0, symmap, nil) < 0)
133 fprint(2, "mapfile %s: %r\n", symfil);
134 mapfile(symhdr, 0, cormap, nil);
142 attachdynamic(verbose);
146 static int thecorpid;
147 static Fhdr *thecorhdr;
153 unmapfile(corhdr, cormap);
169 if(mapproc(pid, cormap, &correg) < 0){
170 fprint(2, "attachproc %d: %r\n", pid);
179 attachcore(Fhdr *hdr)
184 if(mapfile(hdr, 0, cormap, &correg) < 0){
185 fprint(2, "attachcore %s: %r\n", hdr->filename);
190 corfil = hdr->filename;
195 attachdynamic(int verbose)
197 extern void elfdl386mapdl(int);
199 if(mach && mach->type == M386 && symhdr && symhdr->elf)
200 elfdl386mapdl(verbose);